2006年6月6日
摘要: 编译Coherence 3.7.1.9的过程
阅读全文
摘要: 关于JVM的Thin Lock、Fat Lock、SPIN Lock以及Tasuki Lock等概念
阅读全文
摘要: 介绍Lazy-unLocking的概念,读这篇文章之前,建议先读一下我另外一篇Blog:http://www.blogjava.net/security/archive/2009/02/16/jvm_thin-lock_fat-lock__spin-lock_tasuki-lock.html
阅读全文
摘要: How to solve java.lang.LinkageError Problem
阅读全文
摘要: WebLogic + Hibernate 包冲突看代码重构的重要性
阅读全文
摘要: 软件盗版不但对产业造成极为负面的影响,还制约了技术公司创造新工作岗位和对新
技术的创新能力,损害了本地分销商和服务公司的利益,降低了政府税收,增加了网络犯
罪和安全问题的风险。2008 年1 月IDC 发布的降低软件盗版对经济影响的研究报告显
示,如果中国在未来的四年中,将PC 软件盗版率降低10 个百分点,将会带来355,000
个新的就业机会、205 亿美元的经济增长和16 亿美元的税收收入。
阅读全文
摘要: Spring一个关于Lock Contention的Bug引起我对Spring代码质量的忧虑
阅读全文
摘要: 介绍nested transaction的概念
阅读全文
Oracle终于收购了BEA了
http://www.oracle.com/bea/index.htmlhttp://biz.yahoo.com/ap/080116/oracle_bea.html新一轮收购,其实最值得关注的是WebLogic/Tuxedo两个拳头产品,而作为一直缺乏中间件领头产品的Oracle公司,这一次又重新开始瓜分市场,微软/IBM/SAP都会面临直接的强有力的挑战。
整个事件中,对于所有JavaEE开发者,无疑是WebLogic。
如果说,Oracle是最优秀的数据库产品,我觉得,WebLogic绝对是铁定最优秀的J2EE中间件服务器(对WAS6.1,用户普遍认为还是WebLogic 9/10更强大)。
有很多人认为WebSphere会是一个挑战者,这里面含有较多的商业因素,从技术含量上,从稳定性,可靠性和关键企业用户覆盖上,WebLogic的价值远胜于WebSphere。在中国,WebLogic关键企业用户要远胜于WebSphere。
Oracle的中间件定义范畴非常广,这次的收购,在J2EE的领域,将会是新一场中间件标准的全面对抗,如果考虑到Oracle数据库曾经完胜了IBM的DB2一回,这一次,在J2EE中间件上,Oracle又一次是IBM抛离在脑后了。
在JavaEE中间件标准上,现在,Oracle有了Sibel,PeopleSoft,
BEA,在SOA Solution的完整性上,完全可以PK IBM了。
大部分人关注,现在的IT企业,架构越来越复杂,甚至SOA,曾经一度成为我们未来最重要的IT新概念,而J2EE本身,中间件本身,有些人甚至认为不再重要了,因为SOA是面向服务的,本身并不依赖于特定的J2EE中间件。
其实,明眼人还是能看出,所有的IT概念背后,IT的基础设施仍然是IT生态链中的关键组成部分,实施一个SOA的项目,你必须购买主机硬件,购买OS,购买中间件,然后最后才在其上开发你的SOA架构。
现在,SOA对抗,虚一点看,好像是IT战略的范畴,实一点看(从技术、资金),无非是平台之争。这一次Oracle收购BEA,足以让国人重新审视J2EE中间件的巨大价值和重要地位,WebLogic,目前,一个被IT500强公认为最优秀的J2EE中间件服务器,将会收购事件背后的其中一个主要的推动因素。无论SOA是如何成为第三波IT产业革命的重要推动力,J2EE中间件平台之争就犹豫当年的OS、浏览器之争那样激烈,是每个企业决策层实施SOA的时候必定考虑到的因素。
摘要: Eclipse上开发EJB的Ant环境设置的三个习惯
阅读全文
摘要: 介绍如何配置Weblogic的Nodemanager服务
阅读全文
最近,频繁听到很多关于Weblogic乱码的问题,
其实,都是一些个人认为比较容易避免的问题。
1,如果是开发阶段的乱码,比如从屏幕上看到了一堆乱七八糟的编码
尝试在weblogic.xml文件的<jsp-descriptor>部分加入下面的描述:
<jsp-descriptor>
<jsp-param>
<param-name>compilerSupportsEncoding</param-name>
<param-value>true</param-value>
</jsp-param>
<jsp-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</jsp-param>
</jsp-descriptor>
这样,起码会告诉Weblogic容器你的应用含有中文,比如JSP页面,而它会善待你的JSP中的中文。
2,如果你是在Windows上面开发,然后部署到其他平台,比如IBM AIX上,则你要注意encoding的问题,
即文件的Encoding。比如,通常来说,各位都是Eclipse之徒,默认Eclipse上面的文件格式是基于本地的字符集,
即GBK,你是用GBK存储这些文件,甚至打包后想放到AIX上运行是不行的,解决方法太简单了,
JAVA_OPTIONS=-Dfile.encoding=GBK告诉AIX上的Weblogic上的IBM JVM,默认文件encoding不是utf-8,是GBK, 即可。
上面两种方法,前者是针对中文编码的识别问题,后者是针对文件编码的识别问题,两者是不一样的。
在Java中,任何的内容都是以Unicode存在的,看Java程序中的内存,全部String都是Unicode,另外一个问题是,
假定这些String存储成文件,则要考虑Unicode如何写入到文件中,通常用的都是utf-8编码来存储。
在Weblogic 10下面,weblogic.jar被拆分了,其中包括一些javax的接口被分解到api.jar去
所以,你发现自己的WebService无法解释下面这些引用,请务必加入api.jar。
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebParam;
import javax.jws.WebService;
摘要: 国内第一例自由软件盗用事件(Captcha开源社区的Captchio软件恶意盗用行为)
阅读全文
摘要: 发布一个简单易用的Dos插件,可以直接根据Java的package进入到Dos的相关路径,只有6KB大小
阅读全文
摘要: 2007年4月7日广州User Group活动
主 题:Portal技术最新动态与企业门户开发经验交流
时 间:2007年4月7日下午1:00到6:00
地 点:广州天河北路468号
嘉逸国际酒店(百佳超市对面) 三楼嘉逸宴会厅
随着信息化建设的逐渐深入,软件技术的不断创新,Portal技术已经成为企业信息化建设的一个重要组成部分。Portal是企业现有应用与新应用的集成节点,使用户能够与人员(People)、内容(content)、应用(Application)和流程(Processes)进行个性化的、安全的、单点式的互动交流。Portal现在已经成为企业最关注的领域之一,是实现企业整合的第一步。
阅读全文
用中国IP申请一直不行,今天无意中在公司的美国VPN线路上, 申请, 居然通过, 无话可说.
有需要使用gzug.org邮件的请跟我联系.
电子邮件 - http://mail.google.com/a/gzug.org/
日历 - http://www.google.com/calendar/a/gzug.org
另外, 发现google的Page Maker也很好用, 自己申请一个Google Hosted来写
Blog很爽啊: )
http://www.gzug.org/
摘要: 连Microsoft都在用Google广告了!
阅读全文
摘要: 创建dos/bash的简单右键快捷方式
阅读全文
单价 套数 房号 总价 日期
------------- -------------------- -------------------- -------------- ----------------------------
8420.86851628 1 1408 767899.0000 2006-05-25
8414.60879080 1 2007 461373.0000 2006-05-25
8224.28073668 1 1901 826129.0000 2006-05-25
7152.41574871 1 1605 655805.0000 2006-05-25
8184.21105027 1 1801 822104.0000 2006-05-25
8306.08572363 1 2209 761585.0000 2006-05-25
8264.34046789 1 2001 830153.0000 2006-05-26
8410.43692032 1 2206 752650.0000 2006-05-26
8364.51365281 1 2008 762760.0000 2006-05-26
8204.24388639 1 1608 748145.0000 2006-05-26
8334.47018055 1 1807 456979.0000 2006-05-26
8915.47395109 1 2002 1090095.0000 2006-05-26
8294.40087543 1 1707 454782.0000 2006-05-29
8945.53038357 1 2102 1093770.0000 2006-05-29
7933.76913621 1 1806 709993.0000 2006-05-29
8079.42756881 1 1708 736763.0000 2006-05-30
8013.91216895 1 2006 717165.0000 2006-05-30
8053.97889915 1 1603 984760.0000 2006-05-30
8092.45113273 1 1903 989464.0000 2006-05-30
7873.67215617 1 1909 721937.0000 2006-06-02
8898.69503235 1 2608 811472.0000 2006-06-02
7834.22401570 1 1609 718320.0000 2006-06-03
8534.81670618 1 2407 467964.0000 2006-06-03
8951.41345978 1 2607 490806.0000 2006-06-03
8330.19546904 1 2103 1018533.0000 2006-06-03
9286.57669159 1 2107 509183.0000 2006-06-03
7630.43952448 1 1405 699635.0000 2006-06-05
9400 1 1907 515402.0000 2006-06-05
8573.11108674 1 2408 781782.0000 2006-06-05
8000.88825529 1 1508 729601.0000 2006-06-06
8056.89866688 1 1503 985117.0000 2006-06-07
8919.78843698 1 2207 489072.0000 2006-06-07
8188.49178695 1 1601 822534.0000 2006-06-07
9541.30950209 1 2307 523150.0000 2006-06-10
8284.38425265 1 1808 755453.0000 2006-06-12
8646.58038825 1 2401 868549.0000 2006-06-12
8561.29855918 1 1407 469416.0000 2006-06-16
7662.15736541 1 2404 777096.0000 2006-06-16
8327.91972804 1 1908 759423.0000 2006-06-17
9939.42913224 1 2502 1215294.0000 2006-06-22
9642.88868896 1 1702 1179036.0000 2006-06-27
8730.00497760 1 2101 876929.0000 2006-06-27
9349.56244377 1 2202 1143171.0000 2006-06-27
9421.73483934 1 2108 859168.0000 2006-06-29
8117.63551096 1 2409 744306.0000 2006-06-30
7797.77511178 1 1505 714978.0000 2006-07-04
8299.82824895 1 2003 1014820.0000 2006-07-05
8846.39731741 1 1602 1081649.0000 2006-07-05
8927.37384476 1 1802 1091550.0000 2006-07-05
8708.90651836 1 2203 1064838.0000 2006-07-05
9129.81107385 1 2402 1116302.0000 2006-07-05
8078.39459046 1 1809 740708.0000 2006-07-05
7996.17188352 1 2009 733169.0000 2006-07-06
8099.06134763 1 1606 724785.0000 2006-07-06
7698.32042752 1 2005 705859.0000 2006-07-06
8048.23863016 1 1705 737943.0000 2006-07-07
8388.32271762 1 2406 750671.0000 2006-07-08
9050.34354891 1 2109 829826.0000 2006-07-10
7814.03642709 1 1905 716469.0000 2006-07-15
8704.54793325 1 1709 798120.0000 2006-07-18
7613.96008288 1 1805 698124.0000 2006-07-20
8307.39747457 1 1406 743429.0000 2006-07-20
9630.43264905 1 1902 1177513.0000 2006-07-21
8548.44116661 1 1506 765000.0000 2006-07-22
8933.39513578 1 2309 819103.0000 2006-07-22
9585.77694922 1 2308 874127.0000 2006-07-31
7967.82685860 1 2104 808097.0000 2006-08-03
8906.52197622 1 2509 816639.0000 2006-08-05
9345.65455450 1 2201 938771.0000 2006-08-07
8884.78042239 1 2106 795099.0000 2006-08-09
7808.04886029 1 2105 715920.0000 2006-08-12
8512.27430238 1 1607 466728.0000 2006-08-16
9015.21957760 1 2506 806772.0000 2006-08-16
8439.13185734 1 1311 773784.0000 2006-08-18
8614.89802595 1 1509 789900.0000 2006-08-21
8559.20116724 1 1507 469301.0000 2006-08-22
9706.58398686 1 2507 532212.0000 2006-08-22
7821.63265306 1 1701 785683.0000 2006-08-23
9010.86938742 1 2303 1101759.0000 2006-08-23
9043.23388088 1 2306 809279.0000 2006-08-23
9555.15955696 1 2508 871335.0000 2006-08-24
9378.25783972 1 2301 942046.0000 2006-08-28
7967.39301912 1 1704 808053.0000 2006-09-01
8976.08760577 1 1401 901648.0000 2006-09-02
8032.60988112 1 2305 736510.0000 2006-09-04
9049.89582191 1 2208 825260.0000 2006-09-04
8918.02568087 1 1803 1090407.0000 2006-09-08
8083.33515105 1 2205 741161.0000 2006-09-13
9205.92132166 1 2403 1125608.0000 2006-09-14
9238.87298601 1 2503 1129637.0000 2006-09-20
8006.44843226 1 1604 812014.0000 2006-09-20
8411.41786629 1 1804 853086.0000 2006-09-28
9872.45395719 1 2501 991688.0000 2006-10-09
7964.15894300 1 1504 807725.0000 2006-10-12
9943.45301382 1 1502 1215786.0000 2006-10-18
9221.73877484 1 1703 1127542.0000 2006-10-24
8183.14928022 1 1404 829935.0000 2006-10-28
8534.81670618 1 2407 467964.0000
8512.27430238 1 1607 466728.0000
7698.32042752 1 2005 705859.0000
1 2601
1 2405
8388.32271762 1 2406 750671.0000
8048.23863016 1 1705 737943.0000
某些价格是按揭, 某些不是
摘要: This Paper will introduce how to pass certficate to Weblogic Cluster
through Apache Proxy under SSL.
Before you read this paper, please read another blog of mine( but not
necessary).
<
>
http://www.blogjava.net/security/archive/2007/01/07/WeblogicClusterWithApacheProxyUnderSSL.html 阅读全文
摘要: 如何配置Apache与Weblogic集群走SSL协议
阅读全文
摘要: 发布一个简易的SecureXRCP,方便不使用Eclipse的管理员去处理证书库以及产生/验证XML数字签名以及数字水印。
阅读全文
请在下面的配置文档中置换以下三个字符串
BEA_HOME=D:\bea
APACHE_HOME=D:\Apache2
WEBLOGIC_CLUSTER=192.168.102.3:8001,192.168.102.4:8001,192.168.102.4:8003
配置文档:
2,安装Apache 2.0, 使用默认的80默认端口
Copy Weblogic的so到Apache目录
源位置在:%BEA_HOME%\weblogic81\server\bin\mod_wl_20.so
目标位置在:%APACHE_HOME%\modules
注意改so文件已经包含了LoadBalence算法,可以通过Weblogic的Cluster去提供权重参数反馈给mod_wl_20.so,
这样, Apache知道如何Balance Request到Cluster中处理能力更强的服务器。
修改httpd.conf配置文件(%APACHE_HOME%\conf\httpd.conf),让apache加载weblogic提供的For Apache的Plugin——
LoadModule weblogic_module mod_wl_20.so
3,配置Apache指向Weblogic集群
让Apache遇到任何请求,都转发给Weblogic
<IfModule mod_weblogic.c>
WebLogicCluster %WEBLOGIC_CLUSTER%
MatchExpression *.*
</IfModule>
4,集群测试
在weblogic集群上部署defaultWebApp
直接访问http://localhost/defaultWebApp
Apache即可重订向用户到Weblogic集群去。
建议:对于静态资源,我们可以配置让Apache去读取并解析,无须Proxy到Weblogic集群去。
BEA News
BEA Systems' Guardian Offers Pre-emptive Support -- eChannelLine.com
December 22, 2006 -- BEA Systems Inc. plans to release its BEA Guardian evaluation version followed by a general availability release. Guardian represents a departure from the traditional support model employed by the enterprise software industry and is designed to reduce the cost of reactive and proactive support services for organizations, officials said. Stuart Charlton, head enterprise architect for BEA Systems Canada, said his company is offering pre-emptive support as a means of analyzing the customer's computing environment and comparing it to BEA's knowledge base. The end result is Guardian is designed to detect problems before they occur and in turn help lower daily IT operational costs.
BEA Systems' Guardian Offers Pre-Emptive Support -- eChannelLine.ca
December 22, 2006 -- BEA Systems Inc. plans to release its BEA Guardian evaluation version followed by a general availability release. Guardian takes support services from a traditional break-fix model to a pre-emptive model, designed to help customers running business critical applications, given high availability is no longer a strategic goal but a tactical necessity in the modern world. "We're seeing a drive to reduce the diagnosis and time to resolution costs in the enterprise data centre," said Stuart Charlton, head enterprise architect for BEA Systems Canada. "This is another way of capturing knowledge in a machine-readable form and help resolve issues before they become problems."
--------------------------------------------------------------------------------
JBoss News
Red Hat 3Q Profit Drops But Beats Wall Street Expectations -- San Jose Mercury News.com
December 22, 2006 -- Stock-compensation expenses cut into profits for the second consecutive quarter for Red Hat Inc., but the company again exceeded analysts' expectations. The company's second-quarter profit dropped 34 percent on stock-compensation expenses. But company shares surged nearly 14 percent in after-hours trading Thursday. "Our brand and our reputation is world-recognized," Red Hat Chairman Matthew Szulik said after markets closed. "The continued innovation in the next quarter will allow us to compete successfully."
Red Hat Earnings Shrug Off Oracle Threat -- ZDNet.com
December 21, 2006 -- Red Hat's net income subsided in its most recent quarter, but revenue increased as the Linux seller shrugged off the arrival of Oracle as a direct competitor. For the quarter ended November 30, the company's net income was $15.5 million, down 37 percent compared with the same period a year ago. But its revenue increased 45 percent to $105.8 million. The net income of 14 cents per share, excluding various charges like stock option expenses, beat the average expectation of 12 cents per share predicted by analysts surveyed by First Call. "It looks like the world is not coming to an end for you guys after all," said Merrill Lynch analyst Kash Rangan shortly afterward.
Customer Backlash Against Oracle's Buggy Linux Product? -- SeekingAlpha.com
December 22, 2006 -- Mark Murphy, an analyst for First Albany, asked "So, I guess the question is, is it realistic to think that Oracle is just going to ride this experiment into the ground, or would you expect them to possibly withdraw their offering from the marketplace?" Matthew Szulik, CEO Red Hat, responded "we're focused on the success of our customers. We are focused on expanding the opportunity for open source software through initiatives like OLPC with RHEL 5, RHN 2.0, the expanding JBoss middleware stack, and I have to be frank with you, I don't spend a whole lot of time thinking about the operational issues and the Oracle operating system product."
--------------------------------------------------------------------------------
IBM News
Building The SOA Assembly Line -- RedOrbit.com
December 22, 2006 -- RQI is just one of a hundred such reusable SOA components that IBM has built and that are now being used to build new solutions from the ground up for each client. The components are part of a larger effort at IBM to leverage the company's deep application development and IT services expertise to create a storehouse of reusable assets that can be used with customers of all stripes. "What we are really doing by building reusable assets is allowing customers to build their solutions that much quicker and become very flexible," says Brett MacIntyre, IBM's vice president for Composite Services Development.
SAP News
SAP Fills Out 2007 Agenda -- InternetNews.com
December 22, 2006 -- At the top of SAP's agenda is the SOA initiative, its new Duet software for Microsoft Office users, and an enterprise search service still in development. SAP's answer is to provide a standard platform based on its NetWeaver software on which to allow customers, ISVs, and others innovate. While most platform vendors let customers innovate to some degree, analyst Joshua Greenbaum credits SAP for running more forcefully with the idea. "Some of SAP's competitors are known for predatory partnerships, where you also have to compete with them, and I think SAP used to be more like that too," Greenbaum, who is with Enterprise Applications Consulting, told internetnews.com.
--------------------------------------------------------------------------------
Microsoft News
Key Developer Quits Novell Over Microsoft Patent Pact -- eWeek.com
December 21, 2006 -- Jeremy Allison, a leading Samba developer and well-known open-source speaker, has decided to leave Novell because of his objections to the Microsoft/Novell patent agreement. In his public letter of resignation, Allison said, "This has been a very difficult decision, but one I feel I have no choice but to make. My main issue with this deal is I believe that even if it does not violate the letter of the license it violates the intent of the GPL license the Samba code is released under, which is to treat all recipients of the code equally."
--------------------------------------------------------------------------------
Industry News
Wall Street Beat: The Year Ahead -- InfoWorld.com
December 22, 2006 -- Get set for some surprises. With 12 months of moderate expansion expected in the global IT arena, vendors will have to get creative in 2007 to maintain the kind of growth investors want. Tech companies, however, are under pressure. Worldwide IT spending will increase by 6.6 percent in 2007, according to IDC. This is slightly better than the 2006 increase of 6.3 percent but nowhere near the double-digit levels of the dot-com boom. "You will see major vendors performing unnatural acts," quipped Frank Gens, senior vice president of research at IDC.
--------------------------------------------------------------------------------
Blog Monitoring
LEGO Blocks And SOA: Is The Singularity Near? -- ZDNet.com
December 21, 2006 -- Joe McKendrick questions whether LEGOs are becoming more like our IT systems, versus the other way around.
Auto-Generated Services Okay In Model-Driven SOA -- ZDNet.com
December 21, 2006 -- Joe McKendrick writes about how auto-generating service does not invalidate reuse or SOA: the secret sauce and key IP for businesses is the data/business models.
C With NetBeans On Linux ... Check It Out! -- Weblogs.Java.net
December 21, 2006 -- Joerg Plewe writes about how JDK6, NetBeans 5.5 and the new C/C++ development pack is smooth and very user friendly.
BEA Systems Maintains High Ranking In Application Server Software Platform Market In Asia Pacific -- Egoboss.com
December 21, 2006 -- (BEA MENTION) -- Carl Griffith writes about how BEA is a leader in the Application Server Software Platform market in Asia-Pacific region and its SOA has risen to the forefront.
--------------------------------------------------------------------------------
Feature Story
The Traditional ESB Gets Weaved Into An SOA Fabric -- SearchWebServices.com
December 21, 2006 -- In a sign of how quickly things change, the "traditional" enterprise service bus is undergoing an evolution to stay current with the demands of the service-oriented architecture, morphing from an integration/messaging tool to an infrastructure offering that includes tools for business process management (BPM) and governance, analysts say.
The introduction this week of webMethods Fabric 7.0 indicates how much the ESB product category has grown from its original integration backbone role.
"The thing that we see in webMethods Fabric 7.0 is a really straightforward development environment for building composite applications in an SOA fashion," said Bill Swanton, vice president of research for AMR Research, Inc. He said the new product integrates all the tools historically linked to integration including the original enterprise application integration (EAI) technology as well as ESB, but now includes BPM, business activity monitoring (BAM), registry/repository and governance capabilities.
Outmoded as EAI may appear to be in an SOA world, it is still important to support the legacy technology, which is still in place in many corporations, said Peter S. Kastner, vice president enterprise integration for the Aberdeen Group.
"We found almost nobody who is willing to abandon their investments in EAI just to buy an ESB to say that they own one," he said. He cited webMethods as an original EAI company that has successfully made the transition into the SOA world while providing a bridge back to old integration technology. His research of IT departments this year disproved his own belief that the old integration vendors were doomed.
"My hypothesis going into the year was that the EAI companies would take it on the chin," Kastner said. "The reality is the vast majority of their customers are fairly easily connecting SOA via adapters to their EAI fabric or infrastructure."
Kastner and Swanton agree that adding the newer technology, especially BPM, is important to the evolution of the ESB technology webMethods is packaging under its Fabric brand.
Swanton said many of the other ESB vendors are still trying to put together a comprehensive toolset that will serve the needs of both business analysts and developers. The overall ESB technology is moving to include BPM so that developers can work with business analysts on the applications for the business processes, he said.
The BPM technology is important, Kastner said, because based on his research big business is embracing it in a big way. "We're seeing at this point that roughly 50 percent of the Global 5000 are actively engaged in business process management development." He noted that webMethods is not alone in integrating BPM into its ESB technology.
"You should note that Tibco has invested heavily in BPM over the last several years," he said. "Fiorano also beefed up their ESB product significantly in the BPM space in the last six months."
ESB evolution requires a new definition and perhaps even a new name, said Marc Breissinger, CTO at webMethods Inc., noting that the industry is beginning to embrace the term "fabric," which his company and some others use in their product branding.
From webMethod's point of view, the CTO said, the definition of ESB has expanded from a set of categorical definitions of features and functionality to a general category of technology that solves business problems.
"The focus of webMethods Fabric 7.0 coming out this week has to do with the evolution of business process management systems in the context of SOA and classic integration scenarios," Breissinger said. "What we have seen is a convergence of the straight-through processing style automated BPM along with the more human-centric approaches to business process management, or what is commonly referred to as workflow, into a coherent whole, along with business activity monitoring that also needs to be delivered by the BPMS, as well as UI development."
The term fabric has become the umbrella for all the added tools and technologies. It is also used by the Burton Group, which uses terms such as middleware fabric and Web services fabric in discussing application integration using the service-oriented approach.
Breissinger said he isn't wild about the fabric terminology, but it appears to be the best way to describe the holistic approach to combining ESB with BPM and other technology for measuring, modeling and implementing SOA.
"In the past before we got into the BPM space, we were talking about integration backbones," the webMethods' CTO said in providing a brief history of terms. "Then we talked about services buses. In a sense the fabric is the same concept taken one step further to include the business process management and the analytics and the composite application development capabilities to give you that full system building infrastructure versus a pure bus or backbone."
摘要: 在2006 BEAWorld ,Workshop团队向Java开发者展示了其强大的Workshop IDE功能,Workshop宣布支持PHP, Flex开发,开发者能够在Weblogic Platform上部署PHP和Flex应用,在未来,Workshop还会支持Ruby等语言的集成开发。
阅读全文
Thread Dump:
1,Solaris OS
<ctrl>-’\’ (Control-Backslash)
kill -QUIT <pid>
2, Linux
Kill -3 PID
PID通过下面方法获取
ps -efHl | grep 'java' **. **
3,Windows
直接对MSDOS窗口的程序按Ctrl-break
摘要: 最近追Friends(老友记),想在PPC上看,顺便编写了一个HTTPClient的Sample,可以获取PDABase.com的所有下载链接,希望对PDA爱好者有所帮助,可以自己生成Flashget的Task,一次性Download整个网站。
阅读全文
摘要: 国内所有的USBKey通过CAPICOM在Web页面产生数字签名的严重安全漏洞
阅读全文
摘要: Alpha2,支持向导创建KeyStore;支持创建KeyPair;修正了Alpha1的Editor没有Titile等Bug
阅读全文
摘要: 原先是一个Keytool Eclipse Plugin功能的SecureX,经过了一些小扩展,集成了Java各种安全功能,包括XML数字签名,数字印章,CSP,USBKey等开源技术
阅读全文
摘要: 推荐仅仅因为自己编写了安全那部分:) 时间很紧,如有纰漏,请指教
阅读全文
摘要: 关于如何应用XFire JSR181到SpringSide的几个设想
阅读全文
摘要: 关于PHP与CAS做Web SSO,使用PHPCAS
阅读全文
摘要: 探讨一下Federate Portal概念以及WSRP技术
阅读全文
摘要: 如何将SpringSide配置成一个基于Acegi的CAS Client
环境是CAS Server 3.0+Acegi 1.0+Tomcat
阅读全文
第四次广州UserGroup开源技术研讨会紧张筹备中,初定10月21日下午在广州亚洲国际大酒店举行。
主题是:SOA and Agile
ThroughtWorks的高级咨询顾问Brinkey将回到广州为大家分享SOA与敏捷开发的经验
大家对SOA有兴趣的请发邮件联系我。
邮件:
david.turing@bjug.orgBEA广州UserGroup 地址:
http://dev2dev.bea.com.cn/bbs/forum.jspa?forumID=29304&start=0BEA广州UserGroup QQ群:30434538
摘要: 介绍单点登陆(SSO)的原理与实践经验,包括Yale CAS, Kerberos SPNEGO, SAML SSO等方式,并深入SSO协议与原理,最后会介绍各种SSO的基本配置方法。
阅读全文
最近有网友在Dev2dev问,
访问
https://yourmachine:8843/webapp的时候,客户端提交了空的证书窗口,如下图所示

如果使用的是Tomcat,则需要检查JDK/Jre/lib/security下的cacerts是否包含了客户端用户
的Key所对应的CA证书,如果没有,则客户端出现上述窗口,因为,服务器端不
会不信任为客户端的Private Key所签名的ca证书!
如果使用Weblogic,需要要区分Use Custom Indentity和Use Java Keystore两种方式,
前者,往Weblogic的JKS导入客户端PK所对应的CA证书(链),后者,检查
Jre/lib/security的cacerts,做法跟上面一样。
摘要: 在网上收集了不少WS-Security的资料,组织了一下成都BEA UserGroup之WS-Security演讲的PPT初稿,不知道是否有遗漏,欢迎指点。
阅读全文
摘要: PGP共享平台已经建立(www.pgp.org.cn),拥有一把PGP钥匙是一件很Cool的事情,保护Privacy就从现在做起
阅读全文
摘要: 如何使用Winscp和puttygen连接Sourceforge的shell service/web
阅读全文
摘要: Explain why CAS can't logout? 解释CAS SSO一个很重要的问题
阅读全文
摘要: edu.yale.its.tp.cas.client.CASAuthenticationException: Unable to validate ProxyTicketValidator
unable to find valid certification path to requested target
阅读全文
摘要: CeltiXfire入主Apache,将如何影响Axis2的地位?
阅读全文
通常,良好的架构都会有很好的异常处理模式,Web Service也不例外。
例外的是,当你的项目比较庞大的时候,你的业务方法可能很多并且你并不了解他们的内部实现。
作为一个优秀的Web Service架构师,你需要解决Web服务跟这些业务异常的结合问题。
现实是我们都不想关心这些业务类的实现,尽管这些异常从Java类抛出,并且Web服务必须处理这些
异常,起码,你需要让客户端知道:web服务端抛出异常。
以XFire为例, 假设有一个Web服务A和一个调用A的客户端B
A服务端 B客户端
当B->A发起一个Web服务请求,A抛出异常的时候,会直接new XFireFault并扔向XFire客户端。
解耦思路带领下,应该先将异常处理剥离出来。
于是,有
A服务-A异常处理handler B客户端-B异常处理handler
这样,从架构的角度,A/B均无需考虑异常问题。
XFire客户端可以通过addFaultHandler来增加异常处理,XFire服务端则可以通过典型的AOP异常拦截来隔离
业务逻辑和Web服务之间的纽带。
摘要: AXIS2究竟要不要用, AXIS2跟XFIRE的差别是什么?
阅读全文
If your eyes follow the movement of the rotating pink dot, you will only see one color: PINK
If you stare at the black + in the center, the moving dot turns to GREEN
Now, concentrate on the black + in the center of the picture...
After a short period of time, all the pink dots will slowly disappear, and you will only see a green dot rotating.
It's amazing how our brain works. There really is no green dot, and the pink ones really don't disappear.
This gif prove the chinese famous saying: 凡事不要只看表象

[该GIF经过
Gif4J库处理]
Totodo(888669) 13:17:17
HB 和 JDBC 同一个事务?
水木-Spring(3330309) 13:17:40
jdbc也是有事务的.
水木-Spring(3330309) 13:17:54
hibernate只不过封装呢jdbc的事务而已
水木-Spring(3330309) 13:19:01
同一个数据源?
Water Ye(54422686) 13:19:56
同一个connection的话, 这样应该可以
t.beginTransaction();
a.method();
b.method();
t.commit();
Totodo(888669) 13:21:14
是滴,这个比较头疼..
Totodo(888669) 13:21:35
我们后来是传 session,然后session.getConnection.
水木-Spring(3330309) 13:22:19
如果是session.getConnection那就是同一个connection了
xxxxxxx(12345678) 13:25:24
其实我并不知道他们是怎么搞得,我觉得应该不同connection,因为只有我用了Hibernate,其他模块都没用,怎么可能同一个connection阿,头痛!
水木-Spring(3330309) 13:24:12
这个是非常麻烦的,即使使用jta都是很麻烦,因为没有spring这样的事务配置管理,jta的事务代码需要自己写.麻烦啊
Totodo(888669) 13:24:41
嘻嘻,我们现在最好的业务系统模型,,基于存储过程架构的.dao只是查查数据而已..
水木-Spring(3330309) 13:24:55
这个事前没有约定一些规则.怎么会出现这种情况?
xxxxxxx(12345678) 13:28:17
ok,假如我在HB里面用他们的connection,行不行?
水木-Spring(3330309) 13:26:16
这个说的就不专业了,大侠给说说,你怎么用他们的connection?
水木-Spring(3330309) 13:26:27
让俺学习学习.
xxxxxxx(12345678) 13:29:42
我不知道,我极少涉及到事务
Totodo(888669) 13:27:14
SessionFactroy 用的是datasource .大哥..
水木-Spring(3330309) 13:27:18
hibernate里的connection是sessionFactory产生出来的,你能用jdbc的连接,厉害.
水木-Spring(3330309) 13:27:43
跟事务是两回事啊.
xxxxxxx(12345678) 13:30:38
就是嘛,我就是这个意思
水木-Spring(3330309) 13:28:12
如果你说,jdbc用你session里产生的connection,我还觉的说的过去.
xxxxxxx(12345678) 13:30:54
我想知道怎么解决jdbc跟hb的事物
水木-Spring(3330309) 13:28:31
两种方法
xxxxxxx(12345678) 13:31:12
这是我的代码
Configuration config = new Configuration().configure();
SessionFactory sf = config.buildSessionFactory();
s = sf.openSession();
Transaction tx = s.beginTransaction();
Criteria cr = s.createCriteria(TSign.class);
xxxxxxx(12345678) 13:31:42
哦?你觉得在哪一边改动比较好?
水木-Spring(3330309) 13:29:27
哦?首先问你个问题,你的代码怎么和别人的代码交互的?
Totodo(888669) 13:30:11
好久没看到这样的代码了
Configuration ,Sf,Transaction 都能看到..
水木-Spring(3330309) 13:30:25
在你的代码里调用别人的代码?
水木-Spring(3330309) 13:31:07
准确的说,Configuration ,Sf这样的代码确实比较少见了.
水木-Spring(3330309) 13:31:25
如果不使用spring的话,Transaction是必不可少的.
xxxxxxx(12345678) 13:34:23
别人Call我的
水木-Spring(3330309) 13:31:59
话说回来,david.turing你这段代码本身就有问题的.
水木-Spring(3330309) 13:32:08
应该说效率很低的.
xxxxxxx(12345678) 13:34:48
这些代码是Workshop生成的
水木-Spring(3330309) 13:33:11
恐怖的代码生成器啊
xxxxxxx(12345678) 13:36:14
帅哥,你的思路如何,让我借鉴一下
xxxxxxx(12345678) 13:36:42
我那时候没有用JDBCTemplate,真是一个事物
xxxxxxx(12345678) 13:36:48
失误
水木-Spring(3330309) 13:34:57
no,no,即使你没用spring里的jdbcTemplate你的这段代码也大有问题的,你自己上网查查看.
水木-Spring(3330309) 13:35:03
说一下你刚才的事务的问题.
xxxxxxx(12345678) 13:38:11
恩,把问题先解决
Totodo(888669) 13:35:34
我的原则不把在tx写代码里..
不过代码都这样写,就没关系了..
带着参数互相传吧..
水木-Spring(3330309) 13:36:30
我假设你的代码(hibernate)里调用别人(jdbc),那么你可以将session里产生的connection当作参数传递给jdbc的程序.当然,事务最终在你这里做统一提交.
水木-Spring(3330309) 13:36:47
但这种情况不好的地方就是需要是同一个connection
xxxxxxx(12345678) 13:40:18
如果是别人调用我的HB呢?
水木-Spring(3330309) 13:37:41
第二种方法就是使用jta,这种情况的好处是不仅连接可以不是同一个,数据源也可以不一样.
xxxxxxx(12345678) 13:40:33
jta,复杂否?
水木-Spring(3330309) 13:38:00
如果别人调用你的,你就晕吧.
水木-Spring(3330309) 13:39:14
jta?是否复杂,两方面,首先你的的应用服务器是什么?然后你时候使用spring这样的形式来管理事务.
xxxxxxx(12345678) 13:43:35
weblogic 8.1
xxxxxxx(12345678) 13:43:44
没用用Spring
getdown(9486681) 13:41:19
现在用Spring吧...
水木-Spring(3330309) 13:41:29
呵呵,晚了.
xxxxxxx(12345678) 13:44:09
晕倒
getdown(9486681) 13:41:46
不会晚
水木-Spring(3330309) 13:41:55
应用服务器一般都实现很好的jta
getdown(9486681) 13:41:59
原来事务代码还保存没有关系..
xxxxxxx(12345678) 13:44:43
帅哥们,我是不想负这个责任
netfishx(151431) 13:42:31
对,不是说换就换的啊
xxxxxxx(12345678) 13:45:16
JTA能解决跨Connection的问题?
getdown(9486681) 13:42:38
不用换啊..
getdown(9486681) 13:42:43
JTA可以..
getdown(9486681) 13:42:48
不过JTA有点限制
getdown(9486681) 13:43:15
我有碰到代码里面直接写connection.commit()...
getdown(9486681) 13:43:22
这种情况就不能用JTA了..
水木-Spring(3330309) 13:43:36
这叫什么限制啊,呵呵.
水木-Spring(3330309) 13:43:50
这是起码的规则吧
xxxxxxx(12345678) 13:47:04
我可以改代码啊
getdown(9486681) 13:44:03
呵呵 你不知道 原有存在的很多系统都是这么控制事务的..
水木-Spring(3330309) 13:44:27
全局事务,当然不允许你自己做提交了.呵呵.
xxxxxxx(12345678) 13:47:48
tx.commit();全部更换我都可以去做
getdown(9486681) 13:44:49
最简单的还是用Spring的HibernateTransactionMananger来管理Hibernate和JDBC的事务一致.
xxxxxxx(12345678) 13:48:00
恩!
xxxxxxx(12345678) 13:48:27
但他们如果不用Spring呢? 工作量大不大?
getdown(9486681) 13:45:30
...
水木-Spring(3330309) 13:45:44
他们不用,你还做什么啊?晕
xxxxxxx(12345678) 13:49:07
我要创造条件给他们去用
getdown(9486681) 13:46:15
这是可行的
Totodo(888669) 13:46:19
老实说,我不喜欢JTA...
xxxxxxx(12345678) 13:49:23
但是要我把HB->JDBC我死活不愿意的
xxxxxxx(12345678) 13:49:42
他们也不会JDBC->HB
水木-Spring(3330309) 13:46:45
其实david.turing,你的这个改造不是很麻烦的,至少你不是跨数据源的.
xxxxxxx(12345678) 13:49:53
恩....
水木-Spring(3330309) 13:47:09
但是改造的话,风险也不小的.
xxxxxxx(12345678) 13:50:11
答案,我等不及了
getdown(9486681) 13:47:14
那就用HibernateTransactionManager来管理吧,我试过,改动最小..
getdown(9486681) 13:47:17
风险也最小..
xxxxxxx(12345678) 13:50:29
JDBC?
getdown(9486681) 13:47:30
我刚刚在一个大项目的二次开发里面用
xxxxxxx(12345678) 13:50:36
强
getdown(9486681) 13:47:52
HibernateTransactionManager可以同时保证JDBC和Hibernate的事务一致..
xxxxxxx(12345678) 13:51:47
有你这句话就行了
xxxxxxx(12345678) 13:52:00
getdown,给一个配置的sample我看看如何?
getdown(9486681) 13:48:59
呵呵 这个你放心了 我很仔细的试过了..
getdown(9486681) 13:49:07
ok
xxxxxxx(12345678) 13:52:12
thx!!!
Totodo(888669) 13:52:44
getdown(9486681) 13:44:49
最简单的还是用Spring的HibernateTransactionMananger来管理Hibernate和JDBC的事务一致.
getdown(9486681) 13:52:53
?
Totodo(888669) 13:53:02
牛了..我要学习一下.
Totodo(888669) 13:53:54
好比Spring 我有一段这样子配的..
Totodo(888669) 13:53:56
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="rscSessionFactory" />
</property>
</bean>
Totodo(888669) 13:54:40
对应的事务控制分别是..
<bean id="txAttributes" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<value>
*=PROPAGATION_REQUIRED
do*=PROPAGATION_REQUIRED
< alue>
</property>
</bean>
<bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="rscTransactionControl" />
</property>
<property name="transactionAttributeSource">
<ref bean="txAttributes" />
</property>
</bean>
Totodo(888669) 13:55:20
HB事务控制的
<bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<value>txInterceptor< alue>
</property>
<property name="beanNames">
<list>
<value>*DAO< alue>
<value>*Manager< alue>
< st>
</property>
</bean>
Totodo(888669) 13:55:45
而我另外用个JDBC的..
Totodo(888669) 13:55:49
<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="rscDataSource" />
</constructor-arg>
</bean>
Totodo(888669) 13:56:33
JDBC 怎么被 HibernateTransactionManager, 管理上?
getdown(9486681) 13:56:44
呵呵...
getdown(9486681) 13:56:59
我发给你看看
netfishx(151431) 13:57:12
贴出来都看看嘛
getdown(9486681) 13:57:27
ok 那我就贴出来看吧..
Totodo(888669) 13:57:28
要看哦..
getdown(9486681) 13:57:46
前面的简单 ..先
<bean id="baseService" lazy-init="true" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
getdown(9486681) 13:57:59
这个等于是总的Service的配置.
Totodo(888669) 13:58:07
er..
Totodo(888669) 13:58:09
en ..
getdown(9486681) 13:58:33
然后 JDBC的..
<bean id="userJdbcDao"
class="com.gfa4j.demo.jdbc.impl.UserJdbcDaoImpl">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
getdown(9486681) 13:59:09
然后是Service的...
<bean id="userJdbcService" parent="baseService">
<property name="target">
<bean
class="com.gfa4j.demo.jdbc.impl.UserJdbcServiceImpl">
<property name="jdbcDao" ref="jdbcDao" />
</bean>
</property>
</bean>
Totodo(888669) 13:59:23
OH....
getdown(9486681) 13:59:37
这个时候其实调用JDBC的时候等于用了HibernateTransactionMananger了..
Totodo(888669) 14:00:35
这里的ref de transcationManager 就是 HibernateTransactionMananger 么?
getdown(9486681) 14:00:39
嗯..
getdown(9486681) 14:00:44
两个用的都是..
Totodo(888669) 14:00:49
天才啊..
getdown(9486681) 14:00:59
<bean id="userHibernateService" parent="baseService">
<property name="target">
<bean
class="com.gfa4j.demo.service.impl.UserHibernateServiceImpl">
<property name="userJdbcService" ref="userJdbcService" />
</bean>
</property>
</bean>
getdown(9486681) 14:01:07
这个是Hibernate Service
getdown(9486681) 14:01:14
这样就可以很方便的调用了..
netfishx(151431) 14:01:19
这样就可以???
getdown(9486681) 14:01:23
嗯 ...
Totodo(888669) 15:29:45
看了JdbcTemplate 的源..
Totodo(888669) 15:29:46
//-------------------------------------------------------------------------
// Methods dealing with static SQL (java.sql.Statement)
//-------------------------------------------------------------------------
public Object execute(StatementCallback action) throws DataAccessException {
Connection con = DataSourceUtils.getConnection(getDataSource());
Statement stmt = null;
try {
Connection conToUse = con;
if (this.nativeJdbcExtractor != null &&
this.nativeJdbcExtractor.isNativeConnectionNecessaryForNativeStatements()) {
conToUse = this.nativeJdbcExtractor.getNativeConnection(con);
}
stmt = conToUse.createStatement();
DataSourceUtils.applyTransactionTimeout(stmt, getDataSource());
Statement stmtToUse = stmt;
if (this.nativeJdbcExtractor != null) {
stmtToUse = this.nativeJdbcExtractor.getNativeStatement(stmt);
}
Object result = action.doInStatement(stmtToUse);
SQLWarning warning = stmt.getWarnings();
throwExceptionOnWarningIfNotIgnoringWarnings(warning);
return result;
}
catch (SQLException ex) {
throw getExceptionTranslator().translate("executing StatementCallback", getSql(action), ex);
}
finally {
JdbcUtils.closeStatement(stmt);
DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());
}
}
Totodo(888669) 15:31:42
public static Connection doGetConnection(DataSource dataSource, boolean allowSynchronization)
throws SQLException {
Assert.notNull(dataSource, "No DataSource specified");
ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
if (conHolder != null) {
conHolder.requested();
return conHolder.getConnection();
}
logger.debug("Opening JDBC connection");
Connection con = dataSource.getConnection();
if (allowSynchronization && TransactionSynchronizationManager.isSynchronizationActive()) {
logger.debug("Registering transaction synchronization for JDBC connection");
// Use same Connection for further JDBC actions within the transaction.
// Thread-bound object will get removed by synchronization at transaction completion.
conHolder = new ConnectionHolder(con);
TransactionSynchronizationManager.bindResource(dataSource, conHolder);
TransactionSynchronizationManager.registerSynchronization(new ConnectionSynchronization(conHolder, dataSource));
conHolder.requested();
}
return con;
}
Totodo(888669) 15:35:37
jdbc 用的是 DataSourceTransactionManager
hb 用的是 HibernateTransactionManager
Totodo(888669) 15:39:51
It is possible--and sometimes useful--to have coordinated transactions for both. Your JDBC transactions will be managed by the HibernateTransactionManager if you work with the same JDBC DataSource in the same transaction. That is, create the SessionFactory using Spring's SessionFactoryBean using the same DataSource that your JdbcTemplates use.
The only issue to watch, of course, is that you may be invalidating your Hibernate cache by JDBC changes. Generally I find it best to use JDBC to update only tables that don't have Hibernate mappings.
It is possible--and sometimes useful--to have coordinated transactions for both. Your JDBC transactions will be managed by the HibernateTransactionManager if you work with the same JDBC DataSource in the same transaction. That is, create the SessionFactory using Spring's SessionFactoryBean using the same DataSource that your JdbcTemplates use.
The only issue to watch, of course, is that you may be invalidating your Hibernate cache by JDBC changes. Generally I find it best to use JDBC to update only tables that don't have Hibernate mappings.
Totodo(888669) 15:46:14
貌似可以啊....奇怪...
Totodo(888669) 15:47:36
sorry...骚扰了大家很久....
Totodo(888669) 15:47:42
我还是想问下..
Totodo(888669) 15:49:01
<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="rscDataSource" />
</constructor-arg>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="rscSessionFactory" />
</property>
</bean>
<bean id="portAssignerDAO" class="bss.resourcemanager.rscass.assport.dao.impl.PortAssignerDAOImpl">
<property name="sessionFactory">
<ref bean="rscSessionFactory" />
</property>
<property name="jdbcTemplate">
<ref bean="jdbc" />
</property>
</bean>
为什么我的portAssignerDAO ,用 hb ,和jdbc 不能保证再同一个事务中呢?
Totodo(888669) 15:49:25
getDown..
Totodo(888669) 15:55:36
至少.我能证明
<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="rscDataSource" />
</constructor-arg>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="rscSessionFactory" />
</property>
</bean>
<bean id="portAssignerDAO" class="bss.resourcemanager.rscass.assport.dao.impl.PortAssignerDAOImpl">
<property name="sessionFactory">
<ref bean="rscSessionFactory" />
</property>
<property name="jdbcTemplate">
<ref bean="jdbc" />
</property>
</bean>
这个是肯定不在一个事务里的..
Totodo(888669) 15:56:23
portAssignerDAO.updateByJdbc(xxxxxx);
portAssignerDAO.updateByHb(xxxxxx);
Totodo(888669) 15:57:30
从去年上半年开始几乎没怎么用HB了....所以关注的不多....
但是HB混用jdbctempate 记忆深刻啊...
Totodo(888669) 15:58:32
而且,我们系统在线运行的时候.websphere的日志 一支就是很多报 不在一个事务上,而且绑定不了。 ..
Totodo(888669) 15:59:36
getDown...在么?
Totodo(888669) 15:59:38
<bean id="baseService" lazy-init="true" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="userJdbcDao"
class="com.gfa4j.demo.jdbc.impl.UserJdbcDaoImpl">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="userJdbcService" parent="baseService">
<property name="target">
<bean
class="com.gfa4j.demo.jdbc.impl.UserJdbcServiceImpl">
<property name="jdbcDao" ref="userJdbcDao" />
</bean>
</property>
</bean>
<bean id="userHibernateService" parent="baseService">
<property name="target">
<bean
class="com.gfa4j.demo.service.impl.UserHibernateServiceImpl">
<property name="userJdbcService" ref="userJdbcService" />
</bean>
</property>
</bean>
Totodo(888669) 16:00:05
能否发个 UserJdbcDaoImpl 看一下..
Totodo(888669) 16:03:20
是否 UserJdbcDaoImpl 直接集成 JdbcDAOSupport?
Totodo(888669) 16:09:00
Er...
Totodo(888669) 16:09:44
千古大错啊......
Totodo(888669) 16:10:25
我误导了一波子人......
Totodo(888669) 16:10:40
非常感谢 getDown 和 水母Spring
netfishx(151431) 16:11:11
水母
无声的海浪(4485373) 16:12:28
getdown(9486681) 16:16:54
我是直接extends JdbcDAOSupport .
Totodo(888669) 16:17:12
对,继承JdbcDAOSupport
Totodo(888669) 16:17:18
我明白了.
Totodo(888669) 16:17:44
可能就是因为 我们的直接
<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="rscDataSource" />
</constructor-arg>
</bean>
Totodo(888669) 16:18:06
我拿你的配置,简单配了一个,,的确保证在一个事务中.
getdown(9486681) 16:18:15
Totodo(888669) 16:18:50
难道直接 用JdbcTemplate 和 extentds JdbcDAOSupport 有差别..
无声的海浪(4485373) 16:19:54
没有差别
从外貌上看需要的参数都是datasource
Totodo(888669) 16:20:37
我再拿getdown 那种方式换成 我原来的试一下,结果一会儿遍知
无声的海浪(4485373) 16:21:57
那你把JdbcTemplate的参数换成JdbcTemplate
再try一下
Totodo(888669) 16:22:41
是的..我另外给dao配置了一个jdbcTempalte 属性 ,set..
水木-Spring(3330309) 16:23:17
这种方式不行?
无声的海浪(4485373) 16:23:36
和你用datasource一样吗?
无声的海浪(4485373) 16:24:26
如果一样,你原来的方式也同样可以
道理是一样的
水木-Spring(3330309) 16:25:35
刚才我就说了,getdown用的那个extends是一种方式,如果不想继承的话,可以注入嘛?
水木-Spring(3330309) 16:26:22
这种注入是没有问题的.
水木-Spring(3330309) 16:26:36
和继承是一样可行的.
无声的海浪(4485373) 16:26:45
对
Totodo(888669) 16:26:55
这个知道的拉..其实,我一开始的配置,和getDown没有本质差别...
无声的海浪(4485373) 16:27:09
刚才我说的就是水母的意思
水木-Spring(3330309) 16:27:25
总之,这两种方法都是可以的.
水木-Spring(3330309) 16:27:46
有的人不喜欢继承,觉得是强耦合,那么可以选择注入.
getdown(9486681) 16:27:49
Totodo getdown 中间不要加大写 写成getDown难看....
Totodo(888669) 16:27:52
一种已经被证实有问题了..
另外一种还没有被证实..
Totodo(888669) 16:28:05
正在证实中..
水木-Spring(3330309) 16:28:31
那种有问题?
无声的海浪(4485373) 16:28:48
... ...是不是你的写法有问题呢?
水木-Spring(3330309) 16:28:51
继承还是注入?
Totodo(888669) 16:29:11
我的这种方式.. 注入.
<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="rscDataSource" />
</constructor-arg>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="rscSessionFactory" />
</property>
</bean>
<bean id="portAssignerDAO" class="bss.resourcemanager.rscass.assport.dao.impl.PortAssignerDAOImpl">
<property name="sessionFactory">
<ref bean="rscSessionFactory" />
</property>
<property name="jdbcTemplate">
<ref bean="jdbc" />
</property>
</bean>
Totodo(888669) 16:29:46
portAssignerDAO 是 extends HibernateDAOSupport 的..
Totodo(888669) 16:30:39
同时使用jdbc 和 saveOrUpdate就有问题呢...
水木-Spring(3330309) 16:31:06
你试试同时注入jdbcTemplate和HiberanteTemplate试试.
Totodo(888669) 16:31:34
先不玩了..晚上拿demo发给大家一起看一下,如果有兴趣的话...
反正现在对hb不感冒是了..
水木-Spring(3330309) 16:31:45
呵呵
Totodo(888669) 16:31:48
要忙了,,失陪一会儿.
无声的海浪(4485373) 16:32:07
恩
异常:分析器已达到由应用程序设置的实体扩展限制"64,000"
用JDOM分析一个超大的xml文件,大概20M,估计有很多Elements:
SAXBuilder saxbuilder = null;
Document doc_all=null;
saxbuilder = new SAXBuilder(); // 新建立构造器
try {
FileInputStream xmlfile=new FileInputStream("verybig.xml");
doc_all=saxbuilder.build(xmlfile); // 读入文件
} catch (FileNotFoundException e) {
System.err.println("缺少文件!请检查");
System.exit(-1);
} catch (JDOMException e) {
System.err.println("解析XML模板文件出错!请检查");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
抛出异常:
reached the entity expansion limit "64,000" set by the Application.
at TErrorHandler.fatalError(XMLError.java:198)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3342)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3333)
at org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2667)
at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2569)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1980)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
at XMLError.DOMRead(XMLError.java:101)
at XMLError.main(XMLError.java:30)
中文翻译是:分析器已达到由应用程序设置的实体扩展限制"64,000"
原来是JAXP的bug,换JDK1.5解决!
摘要: 本文介绍如何让XFire跟WebService Security结合起来,目前为止,XFire选择了WSS4J(支持WS-Security1.0标准),我为SpringSide加入了WSS4J的3个认证例子(UsernameToken模式,Encrypt模式,Sign模式),大家可以到Springside SVN下载。
阅读全文
XFire官方网站提供的基于Webservice认证的例子有问题,在新版本的XFire1.1.2中编译不通过,不过这也是小Case,我后来折腾了一下,为SpringSide提供了一个简单的Webservice认证功能。
XFire跟Spring的天然融合,让我们可以少努力10年就能简单地在Spring中使用Webservice的强大魅力,我从AXIS专向XFire有一些冲动,也吃了不少亏,但受REST一族的强力吹捧,感觉还是值得尝试的,因此,在公司的系统中也把Axis彻底换了XFire。
回到SpringSide,我大概介绍一下如何配置一个真正实用的XFire验证服务。
SpringSide中的XFire配置文件放在:
SpringSide-bookstore\src\org\springside\bookstore\plugins\webservice\applicationContext-webservice-server.xml
我们在里面定义各个Webservice,该文件其实对应于XFire官方的XFire-Servlet.xml
看看下面的BookService,这是一个典型的Webservice服务,红色的inHandlers是我挂上去的。它的意思是所有访问BookService的请求都会被先送到
authenticationHandler去处理,我们的验证逻辑可以在里面进行。
<!--Web Service 在SpringMVC中的URL 路径映射-->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>/BookService=bookWebService</value>
</property>
<property name="inHandlers">
<ref bean="authenticationHandler"/>
</property> </bean>
我们接着看看
authenticationHandler的代码:
我们在SpringSide中通过header方式向服务器提供验证信息(另外一种更简单的方式是创建一个Login的webservice服务,然后在XFire Session中建立Token信息)。
package org.springside.bookstore.plugins.webservice.authentication;
import org.apache.log4j.Logger;
import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.exchange.InMessage;
import org.codehaus.xfire.fault.XFireFault;
import org.codehaus.xfire.handler.AbstractHandler;
import org.jdom.Element;
import org.jdom.Namespace;
/**
* XFire的回调的Handler,在XFire配置文件中配置
* Server端的认证模块,回调处理模块
*
* ClientAuthHandler跟AuthenticationHandler要一起用,或者都不用
*
* @author david.turing
* @blog openssl.blogjava.net
*
*/
public class AuthenticationHandler extends AbstractHandler {
private static final Logger log = Logger.getLogger(AuthenticationHandler.class);
public void invoke(MessageContext context) throws Exception {
log.info("#AuthenticationHandler is invoked");
InMessage message=context.getInMessage();
final Namespace TOKEN_NS = Namespace.getNamespace("SpringSide","http://service.webservice.plugins.bookstore.springside.org");
if(message.getHeader()==null)
{
throw new XFireFault("GetRelation Service Should be Authenticated",
XFireFault.SENDER);
}
Element token = message.getHeader().getChild("AuthenticationToken", TOKEN_NS);
if (token == null)
{
throw new XFireFault("Request must include authentication token.",
XFireFault.SENDER);
}
String username = token.getChild("Username", TOKEN_NS).getValue();
String password = token.getChild("Password", TOKEN_NS).getValue();
System.out.println("username="+username);
System.out.println("password="+password);
if(username==null||password==null)
throw new XFireFault("Supplied Username and Password Please",
XFireFault.SENDER);
/**
* 检查用户名密码是否正确
*/
PasswordAuthenticationManager pamanager=new PasswordAuthenticationManager();
if(!pamanager.authenticate(username,password))
throw new XFireFault("Authentication Fail! Check username/password",
XFireFault.SENDER);
}
}
注意,XFireFault异常是往客户端抛的,Webservice Client应该学会catch XFireFault.
服务器端就是这么简单,看看客户端的TestCase
package org.springside.bookstore.plugins.webservice.service;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.util.List;
import org.codehaus.xfire.client.Client;
import org.codehaus.xfire.client.XFireProxy;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.springside.bookstore.commons.domain.Book;
import org.springside.bookstore.plugins.webservice.authentication.ClientAuthHandler;
import junit.framework.TestCase;
public class BookServiceWithAuthenticationTestCase extends TestCase {
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void getBookFromWebservice() throws Exception{
Service serviceModel = new ObjectServiceFactory()
.create(BookService.class);
BookService service = null;
try {
service=(BookService) new XFireProxyFactory().create(
serviceModel,
"http://localhost:8080/springside/service/BookService");
} catch (MalformedURLException e) {
e.printStackTrace();
}
Client client = ((XFireProxy) Proxy.getInvocationHandler(service)).getClient();
//挂上ClientAuthHandler,提供认证
client.addOutHandler(new ClientAuthHandler());
List list = service.findBooksByCategory(null);
assertNotNull(list);
for(int i=0;i<list.size();i++)
System.out.println(((Book)list.get(i)).getName());
}
}
你应该看到上面的client.addOutHandler(new ClientAuthHandler());
没错,它跟服务器端的AuthenticationHandler是一对,一起使用的!
也就是,每个被送往WebService服务的请求都被ClientAuthHandler处理过了。
看看ClientAuthHandler做了些什么:
package org.springside.bookstore.plugins.webservice.authentication;
import org.apache.log4j.Logger;
import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.handler.AbstractHandler;
import org.jdom.Element;
import org.jdom.Namespace;
/**
* 客户端端的认证模块,回调处理模块
* 每个需要认证的WebService方法都可以挂这个Handler
*
* 仅用于Demo,从解耦和易用性出发,
* 没有跟Acegi结合,你可以任意扩展
* 默认用户名/密码是admin/admin
*
* ClientAuthHandler跟AuthenticationHandler要一起用,或者都不用
*
* @author david.turing
*
* @blog openssl.blogjava.net
*/
public class ClientAuthHandler extends AbstractHandler {
private static final Logger log = Logger.getLogger(ClientAuthHandler.class);
//客户端自己配置用户名密码或者更安全的KeyStore方式
private String username = "admin";
private String password = "admin";
public ClientAuthHandler() {
}
public ClientAuthHandler(String username,String password) {
this.username = username;
this.password = password;
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void invoke(MessageContext context) throws Exception {
/*******************************************
* Soap Header方式
* 从Soap Header中获取用户名密码
*******************************************/
final Namespace ns = Namespace.getNamespace("SpringSide","http://service.webservice.plugins.bookstore.springside.org");
Element el = new Element("header",ns);
Element auth = new Element("AuthenticationToken", ns);
Element username_el = new Element("Username",ns);
username_el.addContent(username);
Element password_el = new Element("Password",ns);
password_el.addContent(password);
auth.addContent(username_el);
auth.addContent(password_el);
el.addContent(auth);
context.getCurrentMessage().setHeader(el);
log.info("ClientAuthHandler done!");
}
}
不就是往header里面注入username,password!
在SpringSide中,所有的Spring配置文件都被小白分散到各个Module中去了,Wuyu原先是在Plugin中提供Webservice功能,因此,我仍然在Plugin中创建XFire接口。
SpringSide的Spring配置文件放在:
SpringSide-bookstore\webapp\WEB-INF\springmvc-servlet.xml
该文件定义了Plugin的xml:
AuthenticationHandler这个Bean需要先定义在Plugins-servlet.xml中,其它很简单,大家去Try一下就知道了。
The Pheox JCAPI (
http://pheox.com/download) 提供一个JCE Provider可以直接操作Microsoft 操作系统本地证书库/私钥的。JCAPI用一个jcapi.dll封装了这些复杂性,这个dll负责调用Windows内置的CSP来完成加密签名哈希等密码运算。
JCAPI.DLL属于轻量级的中间层类库,它让Java开发者免去对待CSP的细节,比如获得一个CSP的Handle。
JCAPI.dll提供了下面的JNI调用:
00000001 10002AA0 _Java_com_pheox_jcapi_CoreCipherJNI_decrypt@24
00000002 100021A0 _Java_com_pheox_jcapi_CoreCipherJNI_encrypt@20
00000003 100027A0 _Java_com_pheox_jcapi_CoreCipherJNI_encryptWithPrivateKey@20
00000004 10001E10 _Java_com_pheox_jcapi_CoreCipherJNI_getPrivateKeySize@12
00000005 10003610 _Java_com_pheox_jcapi_CoreKeyStoreJNI_aliases@16
00000006 100039D0 _Java_com_pheox_jcapi_CoreKeyStoreJNI_containsAlias@12
00000007 10005E50 _Java_com_pheox_jcapi_CoreKeyStoreJNI_createBase64Hash@12
00000008 10003B30 _Java_com_pheox_jcapi_CoreKeyStoreJNI_deleteEntry@12
00000009 10003DA0 _Java_com_pheox_jcapi_CoreKeyStoreJNI_getCertificate@12
0000000A 10003FE0 _Java_com_pheox_jcapi_CoreKeyStoreJNI_getCertificateChain@20
0000000B 10004530 _Java_com_pheox_jcapi_CoreKeyStoreJNI_getKey@12
0000000C 10004C00 _Java_com_pheox_jcapi_CoreKeyStoreJNI_isKeyEntry@12
0000000D 10004E00 _Java_com_pheox_jcapi_CoreKeyStoreJNI_setCertificateEntry@16
0000000E 10005020 _Java_com_pheox_jcapi_CoreKeyStoreJNI_setKeyEntry@44
0000000F 10005CA0 _Java_com_pheox_jcapi_CoreKeyStoreJNI_size@16
00000010 100062A0 _Java_com_pheox_jcapi_CoreSignatureJNI_hashFinal@12
00000011 10005F80 _Java_com_pheox_jcapi_CoreSignatureJNI_hashInit@12
00000012 10006140 _Java_com_pheox_jcapi_CoreSignatureJNI_hashUpdate@16
00000013 10006430 _Java_com_pheox_jcapi_CoreSignatureJNI_sign@28
00000014 10006F60 _Java_com_pheox_jcapi_CoreSignatureJNI_verify@28
00000015 10007CF0 _Java_com_pheox_jcapi_CoreUtilJNI_addPKCS11CSP@16
00000016 10007880 _Java_com_pheox_jcapi_CoreUtilJNI_createCertEntryStore@8
00000017 10007C20 _Java_com_pheox_jcapi_CoreUtilJNI_getAddedPKCS11CSPs@8
00000018 100078E0 _Java_com_pheox_jcapi_CoreUtilJNI_getCSP@12
00000019 10008F10 _Java_com_pheox_jcapi_CoreUtilJNI_getCertStoreFriendlyName@12
0000001A 100089C0 _Java_com_pheox_jcapi_CoreUtilJNI_getCertificateFriendlyName@12
0000001B 10007500 _Java_com_pheox_jcapi_CoreUtilJNI_getJCAPIDLLVersion@8
0000001C 10007520 _Java_com_pheox_jcapi_CoreUtilJNI_getMSCSPs@8
0000001D 10009010 _Java_com_pheox_jcapi_CoreUtilJNI_getMSCertStoreNames@8
0000001E 10007E20 _Java_com_pheox_jcapi_CoreUtilJNI_getPKCS11DLLName@12
0000001F 100083F0 _Java_com_pheox_jcapi_CoreUtilJNI_getPKCS11TokenInfo@12
00000020 10007B50 _Java_com_pheox_jcapi_CoreUtilJNI_getSupportedPKCS11CSPs@8
00000021 100077A0 _Java_com_pheox_jcapi_CoreUtilJNI_init@12
00000022 10007F40 _Java_com_pheox_jcapi_CoreUtilJNI_isPKCS11PrivateKey@12
00000023 10007D90 _Java_com_pheox_jcapi_CoreUtilJNI_removePKCS11CSP@12
00000024 10008F90 _Java_com_pheox_jcapi_CoreUtilJNI_reportMemStatus@8
00000025 10008360 _Java_com_pheox_jcapi_CoreUtilJNI_setCallbackPinCode@12
00000026 100083B0 _Java_com_pheox_jcapi_CoreUtilJNI_setCertOpenStoreFlags@12
00000027 10008C80 _Java_com_pheox_jcapi_CoreUtilJNI_setCertificateFriendlyName@16
它调用的类库其实还是crypt32.dll和ADVAPI32.dll.
crypt32.dll:
0000002C CertEnumSystemStore
00000041 CertGetCertificateContextProperty
0000008B CryptFindLocalizedName
00000056 CertRegisterSystemStore
00000097 CryptHashCertificate
00000061 CertSetCertificateContextProperty
00000019 CertCreateCertificateContext
00000004 CertAddCertificateContextToStore
00000044 CertGetIssuerCertificateFromStore
0000001E CertDeleteCertificateFromStore
00000029 CertEnumCertificatesInStore
0000007C CryptDecodeObject
0000009C CryptImportPublicKeyInfo
00000050 CertOpenStore
00000032 CertFindCertificateInStore
0000000F CertCloseStore
0000003C CertFreeCertificateContext
导入, ADVAPI32.dll
顺序 (示意) 名字
000000A8 CryptSignHashA
00000099 CryptGetHashParam
0000008B CryptDestroyHash
0000009D CryptHashData
00000088 CryptCreateHash
00000094 CryptExportKey
00000089 CryptDecrypt
0000009F CryptImportKey
0000008F CryptEncrypt
0000009C CryptGetUserKey
0000009A CryptGetKeyParam
0000008C CryptDestroyKey
00000085 CryptAcquireContextA
000000A0 CryptReleaseContext
000000AA CryptVerifySignatureA
00000092 CryptEnumProvidersA
000001C9 RegCloseKey
000001EC RegQueryValueExA
000001F9 RegSetValueExA
000001CD RegCreateKeyExA
000001E2 RegOpenKeyExA
000000A1 CryptSetHashParam
在标准的CryptoAPI函数上的封装是有必要的,因为从Java程序员的角度,我们不需要太关心CSP,我们希望直接进行Cryptography运算。
JCAPI这个provider提供3个SPI的实现,
java.security.KeyStoreSpijava.security.SignatureSpijavax.crypto.CipherSpi
也就是,我们通过Java应用程序可以直接借助于JCE API来调用CryptoAPI。
这个JCE API算法支持下面的基本操作
- Add, remove, list and access X.509 certificates.
- Add, remove, access and export RSA private keys.
- Create signatures with RSA private keys using the following algorithms:
- SHA1withRSA
- MD5withRSA
- MD2withRSA
- Verify signatures with RSA public keys.
- Encrypt/decrypt data with RSA public/private keys using the following algorithm, mode and padding:
- Wrap and unwrap symmetric- and asymmetric keys with RSA key pairs through MS CAPI and PKCS#11.
- Built-in support for tested PKCS#11 CSP manufacturers that is compliant with the functions required by JCAPI.
- Dynamically adding/removing of PKCS#11 CSPs into JCAPI.
- Private key call-back interface for PKCS#11 providers. You can provide your own preferred Java call-back implementation to be called whenever a private key is accessed through PKCS#11.
- List and configure MS CAPI system (certificate) stores.
- Use a MS CAPI system (certificate) store as an un-trusted store.
- Set and get MS CAPI friendly names for certificates.
- Get MS CAPI friendly names for system (certificate) stores.
- Get detailed information about your PKCS#11 hardware token through the JCAPI PKCS#11 information class.
- Use JCAPI supported plug-ins. A JCAPI plug-in is a signed JAR file that extends or enhances the functionality of JCAPI without the need of recompiling JCAPI.
- JCAPI SSL plugin. Use this plug-in to simplify the work of integrating the JCAPI key store for SSL enabled applications. The plug-in transparently supports both the old JSSE version for Java 1.3, and the newer versions included in Java 1.4 and higher. This plug-in transparently supports the PKCS#11 implementation as defined in Java 5. Your JCAPI supported hardware keys can be plugged in and used immediately for SSL. JCAPI will automatically configure the token for you by setting the correct slot identity to use etc.
- JCAPI X.509 Factory plug-in. Use this plug-in to transparently replace any other X.509 certificate factories used by your Java system.
- JCAPI is signed with a qualified code signing certificate that is trusted by all modern web browsers which makes it suitable in trusted applets.
JCE API支持一下的系统,我只是在Windows2000上测试通过,其他平台我不能保证破解能正常使用。
- Windows 98
- Windows 98 SE
- Windows ME
- Windows 2000
- Windows XP
JCE 支持JDK1.4以上,JDK1.3稍微为麻烦,要自己配制JCE和JSSE
- Java 1.3.1 with JCE 1.2.2 and JSSE 1.0.3
- Java 1.4
- Java 1.5
我已经在吉大正元的eSafe钥匙上通过测试,其他钥匙提供商可以发邮件给我,或者给Usb钥匙我去测试。
JCAPI的时间限制比较容易去除,但由于JNI层以上的代码做了大量混淆,我不得不重写这个JCE Provider,最起码要实现KeyStoreSpi,SignatureSpi和CipherSpi。
JCAPI的JCE Provider我将会在下个月提供
摘要: 使用Gif4j实现gif图片的水印嵌入
阅读全文
SSL握手会有很多意想不到的Exception, 其中很多都是因为没有配置好cacerts导致的。
以Tomcat为例,你需要在conf/server.xml中指定你的keystore并且配置好KeyAlias,
同时,Tomcat会到JAVA_HOME/jre/lib/security目录下读取cacerts文件。
在Weblogic中,你也需要配置Trust.jks和Identity.jks(可以参考WebLoigc Security In Action)。
问题是,IE究竟根据什么来提交证书(包含私钥的证书)?
很简单,服务器提交他的证书到客户端,客户端会根据服务器的证书的DN,检索本地私钥,
选择那些由此DN签发证书X,然后确定使用X对应的本地私钥,用于SSL握手。
cacerts是JDK容器信任的证书列表,如果cacerts中没有包含客户端私钥对应的证书链中的
信任证书,则服务器会拒绝任何从客户端的SSL请求。
典型的Weblogic日志就是:
<Certificate chain received from 客户端- 192.168.10.10 was not trusted causing SSL handshake failure.>
摘要: How to use Java produce Signature by USBKey under CryptoAPI/CSP.
阅读全文
package com.pheox.jcapi.test;
import com.pheox.jcapi.CoreSignatureJNI;
import com.pheox.jcapi.CoreUtilJNI;
import com.pheox.jcapi.JCAPIJNIException;
public class getcsp {
public static void main(String[] args) {
// String g = "MIIDrTCCA2ugAwIBAgICAeYwCwYHKoZIzjgEAwUAMIGQMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEjAQBgNVBAcTCVBhbG8gQWx0bzEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJbmMxIzAhBgNVBAsTGkphdmEgU29mdHdhcmUgQ29kZSBTaWduaW5nMRwwGgYDVQQDExNKQ0UgQ29kZSBTaWduaW5nIENBMB4XDTA1MDEyMTIyNDc1MloXDTEwMDEyNTIyNDc1MlowVDEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJbmMxIzAhBgNVBAsTGkphdmEgU29mdHdhcmUgQ29kZSBTaWduaW5nMQ4wDAYDVQQDEwVQaGVveDCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3UjzvRADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQD2cHtWHnwO9pOZx9H0uUoLZGKE3iwvVAkUwzVqVEgT4fMG70icn2dII/RABPtXW6Zai87iIg7zC975qeeEznBee7ll/8HFFe8H4IL3tPCf+/TigELMORl3ySd8lzD1mEZMYUL6Rc16T3ZJ3iUxfrJJiN815SZ8qrDkHAtS1Hhot6OBjTCBijARBglghkgBhvhCAQEEBAMCBBAwDgYDVR0PAQH/BAQDAgXgMB0GA1UdDgQWBBRkqtvyzwWOJd+aZikkKKFLDTaqbDAfBgNVHSMEGDAWgBRl4vSGydNO8JFOWKJq9dh4WprBpjAlBgNVHREEHjAcgRp0b21teS5ncmFuZGVmb3JzQHBoZW94LmNvbTALBgcqhkjOOAQDBQADLwAwLAIUdTerIDsy5CLjjPffwoO4rYWZ4kECFAyrKdfe2Qj5T5MWse9EhMD951Wt";
try {
System.loadLibrary("JCAPI");
System.out.println("Load Library Successfully!");
} catch(UnsatisfiedLinkError e) {
e.printStackTrace();
}
CoreUtilJNI core=new CoreUtilJNI();
String[] mscsp=core.getMSCSP();
for(int i=0;i<mscsp.length;i++)
System.out.println(mscsp[i]);
System.out.println("done");
String content="1234567890abcdefghij+sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss";
byte[] data = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
data=content.getBytes();
try
{
int[] d= CoreSignatureJNI.hashInit("SHA1");
CoreSignatureJNI.hashUpdate(d, data);
byte abyte1[] = CoreSignatureJNI.hashFinal(d);
System.out.println(""+new String(abyte1));
return;
}
catch(JCAPIJNIException jcapijniexception)
{
jcapijniexception.printStackTrace();
}
}
}
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D3B0C4E
Function=[Unknown.]
Library=C:\j2sdk1.4.1_02\jre\bin\client\jvm.dll
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.
Current Java thread:
at jni.JNIInterface.getPrivateKeyAlias(Native Method)
at jni.JNIInterface.getRSAPrivateKey(JNIInterface.java:478)
at jni.ReadCertificates.main(ReadCertificates.java:37)
Dynamic libraries:
0x00400000 - 0x00407000 C:\j2sdk1.4.1_02\bin\javaw.exe
0x77F80000 - 0x77FFC000 C:\WINNT\system32\ntdll.dll
0x796D0000 - 0x79735000 C:\WINNT\system32\ADVAPI32.dll
0x77E60000 - 0x77F32000 C:\WINNT\system32\KERNEL32.dll
0x786F0000 - 0x7875F000 C:\WINNT\system32\RPCRT4.dll
0x77DF0000 - 0x77E59000 C:\WINNT\system32\USER32.dll
0x77F40000 - 0x77F7C000 C:\WINNT\system32\GDI32.dll
0x78000000 - 0x78045000 C:\WINNT\system32\MSVCRT.dll
0x75E00000 - 0x75E1A000 C:\WINNT\system32\IMM32.DLL
0x6C330000 - 0x6C338000 C:\WINNT\system32\LPK.DLL
0x65D20000 - 0x65D74000 C:\WINNT\system32\USP10.dll
0x10000000 - 0x1000D000 C:\WINNT\system32\OCMAPIHK.DLL
0x6D340000 - 0x6D46A000 C:\j2sdk1.4.1_02\jre\bin\client\jvm.dll
0x77530000 - 0x77560000 C:\WINNT\system32\WINMM.dll
0x6D1E0000 - 0x6D1E7000 C:\j2sdk1.4.1_02\jre\bin\hpi.dll
0x6D310000 - 0x6D31E000 C:\j2sdk1.4.1_02\jre\bin\verify.dll
0x6D220000 - 0x6D239000 C:\j2sdk1.4.1_02\jre\bin\java.dll
0x6D330000 - 0x6D33D000 C:\j2sdk1.4.1_02\jre\bin\zip.dll
0x0AC90000 - 0x0ACA0000 D:\JavaSource\SecureX\jnicert.dll
0x768D0000 - 0x768FB000 C:\WINNT\system32\WINTRUST.dll
0x79C40000 - 0x79CCC000 C:\WINNT\system32\CRYPT32.dll
0x773F0000 - 0x77401000 C:\WINNT\system32\MSASN1.dll
0x77900000 - 0x77923000 C:\WINNT\system32\IMAGEHLP.dll
0x7CF00000 - 0x7CFEF000 C:\WINNT\system32\ole32.dll
0x7CEA0000 - 0x7CEF3000 C:\WINNT\system32\NETAPI32.dll
0x77960000 - 0x77984000 C:\WINNT\system32\DNSAPI.dll
0x74FD0000 - 0x74FDA000 C:\WINNT\system32\WSOCK32.dll
0x74FB0000 - 0x74FC4000 C:\WINNT\system32\WS2_32.DLL
0x74FA0000 - 0x74FA8000 C:\WINNT\system32\WS2HELP.DLL
0x75150000 - 0x75156000 C:\WINNT\system32\NETRAP.dll
0x77BD0000 - 0x77BE1000 C:\WINNT\system32\NTDSAPI.dll
0x77930000 - 0x7795B000 C:\WINNT\system32\WLDAP32.DLL
0x797B0000 - 0x797BF000 C:\WINNT\system32\SECUR32.DLL
0x750E0000 - 0x750F0000 C:\WINNT\system32\SAMLIB.dll
0x79C00000 - 0x79C13000 C:\WINNT\system32\cryptnet.dll
0x687E0000 - 0x687EB000 C:\WINNT\system32\PSAPI.DLL
0x75A50000 - 0x75A55000 C:\WINNT\system32\SensApi.dll
0x772A0000 - 0x77306000 C:\WINNT\system32\SHLWAPI.dll
0x794D0000 - 0x79534000 C:\WINNT\system32\USERENV.dll
0x4FF90000 - 0x4FFE4000 C:\WINNT\system32\WINHTTP.dll
0x758E0000 - 0x7594F000 C:\WINNT\system32\cryptui.dll
0x71710000 - 0x71794000 C:\WINNT\system32\COMCTL32.dll
0x63000000 - 0x63095000 C:\WINNT\system32\wininet.dll
0x77990000 - 0x77A2B000 C:\WINNT\system32\OLEAUT32.dll
0x7CA00000 - 0x7CA23000 C:\WINNT\system32\rsaenh.dll
0x72960000 - 0x7298D000 C:\WINNT\system32\DBGHELP.dll
Local Time = Fri Jun 30 17:17:50 2006
Elapsed Time = 5
#
# HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION
# Error ID : 4F530E43505002E6
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Client VM (1.4.1_02-b06 mixed mode)
#
# An error report file has been saved as hs_err_pid2024.log.
# Please refer to the file for further information.
#
It happens when I want to call the CryptoAPI through JNI, Can anyone give some advice?
今天运气很好,被广州电台新闻风云榜记者钟慧采访了,并且领取了Team5 Hair Salon的洗头礼券。钟慧是一个很Nice and Pretty的女孩,如果我没google错,她应该来自于中山大学国际法的05届研究生,呵呵。女研究生俺还是有能力去应付的......
《新闻风云榜》是一个娱乐化包装的新闻节目(6:30pm-7:00pm),是广州电台一台就转型打造成新闻资讯广播的重要节目。
对于现代的IT人,繁忙的工作后,经常需要吸收一些社会新闻信息,有两个非常棒的悠闲节目,一个是广州电视台的《新闻日日睇》和广州电台的《新闻风云榜》。
我回忆了几个采访片断:
钟慧:对新闻风云榜的看法
我:很不错,能接受众多群众的反馈和观点,下一个陈扬节目。
钟慧:觉得新闻风云榜有什么可以改进的地方
我:已经很好,该节目有潜力,将会越来越好,但需要处理好中立的观点立场,观点不要过于偏激;同时,要大胆一些,敢于接受批评,正面观点固然需要,但也不要拒绝持对立观点的听众的意见,否则媒体的中立立场就缺乏前提条件了: )
钟慧:昨天你在电台类比黄建翔的“意大利万岁”成“国民党万岁”,给我们造成了不少压力,我们都被批评了。
我:我觉得我的表达有问题,我可能口快说错了(附:当时我打电话去新闻风云榜,发表我对黄建翔作为一个中央台解说员发表过激观点的非理性,我的观点当然不是“国民党万岁”,而是用“国民党万岁”来类比黄建翔观点的偏激性,在此,我再次澄清我的观点,如果你是一个台湾选民,你可能会呼喊“国民党万岁”或者“民进党万岁”,你有这样的权利,但黄建翔当时的角色不是一个“选民”,他难道没有想到电视观众中有“澳大利亚万岁”的球迷?仅代表个人观点和立场,并希望用此类比批评黄健翔做法的不适时性,并非批评黄健翔的个人品质问题。
除了对我的采访被她录音了,我也录了音,真不错,想不到《新闻风云榜》的节目组会这么榜,现在收听率已经升至本地区中游,FM96.2,作为我自己,下班时候(6点到6点半)可以听听电台,偶尔还可以发表一下言论,而且还能听到别人的观点和发表自己的观点,真是件快事。
Captcha项目是Completely Automated Public Turing Test to Tell Computers and Humans Apart (全自动区分计算机和人类的图灵测试)的简称。
CAPTCHA的目的是区分计算机和人类的一种程序算法,这种程序必须能生成并评价人类能很容易通过但计算机却通不过的测试。这个要求本身就是悖论,因为这意味着一个CAPTCHA必须能生成一个它自己不能通过的测试。
大家可以看看CAPTCHA的一个例子:

人类能够比较容易识别图片中的字母,但如果编写计算机程序,难度就非常大了。
按照Lenore Blum的说法,任何的图片中的内容都能被识别,不存在一种计算程序生成的图片不能被计算机程序识别出来。
于是,比赛开始了,有人站到Captcha一方,有人站到破译Captcha的一方.......
如今,GZUG的两位牛人已经开始了这个游戏,有兴趣的朋友请加入到我们的对抗比赛(QQ群:16699048):
CYT(Coremail的主要设计者)加入了Captcha一方。
灵感之源 (Guardio/Definio的Designer)加入了破译Captcha的一方。
游戏规则是:Captcha方公布一系列的图片,破译Captcha的一方提供程序能够分析这些图片中的内容,如果破译方提供的应用程序能够以高于10%的识别率识别出图片内容,则判定破译方获胜。获胜方将得到BEA UG礼品一份!
游戏奖品参见:
http://dev2dev.bea.com.cn/bbs/gift!default.jspa
关于Captcha的信息,参考下面的链接
Captcha方:
Captcha项目:http://www.captcha.net/
jCaptcha项目:http://jcaptcha.sourceforge.net/
破译Captcha方:
http://www.cs.sfu.ca/~mori/research/gimpy/
http://sam.zoy.org/pwntcha/
http://www.brains-n-brawn.com/default.aspx?vDir=aicaptcha
摘要: 第三次BEA UserGroup总结
阅读全文
郭昶,康祈宗,我谨代表广州UserGroup永远怀念你,你很出色,你已经深深印入我们的脑海!
郭昶扮演的康祈宗是《外来媳妇本地郎》最搞笑的角色,而郭昶本人与剧中角色反差很大,剧中的康祈宗,市侩狡猾,追名逐利,郭昶本人则称自己对名利看得不重,认为自己只是一名普通的演员,拍戏空闲时,喜欢独处,潜心研究角色。
郭昶认为对艺术的态度要精益求精,这样才能做到每一个环节都不能让人看出破绽,他说:“我是一个有什么说什么的人,所谓明星,只不过是给你一个定位,演员只是一个职业,与工人、医生没什么区别,如果把自己定位为明星,那就大错特错。”

姓名 : 郭昶
英文名 : guochang
性别 : 男
年龄 : 45
身高 : 173
体重 : 55
三围 : --
星座 : 天歇座
所在省份 : 广东
职业 : 演艺业
演出经验 :
从艺十五年,经验丰富,受广大观众欢迎。
幕后工作经验 :
导演,副导演,编剧,剧务等等卖力的工作。
生日日期 : 10月1日xxxx年
出生地点 : 沈阳
家庭成员 : 妻子,女儿
所懂语言 : 普通话,粤语
教育水平 : 初中
收入水平 : 1001-2000
最想告诉大家的特别事情 : 一分耕耘,一分收获
自我推荐 :
瘦高,人又老,又黑又瘦,又鞋揪。
我的兴趣 :
娱乐活动, 旅行, 演戏, 户外活动, 阅读, 广泛
我的专长 :
语言天才, 演戏, 文学创作, 样样专
我最想加入的行列 :
演员, 导演, 有钱就行
摘要: 本文设计了一个Java的随机序列,在此基础上产生了一个数字水印,并提供了水印图片,悬赏能破解水印信息的破解者。
阅读全文
全体奥一网球迷:
最近,奥一网的"讲波佬"评选中,我们分别设计了针对罗荣满的投票机程序(for .net和for Java),该程序可能在网上被滥用而导致极个别人选票数非正常变动,对此,我们感到非常非常抱歉。
最初,我们编写投票机纯粹是出于对已故的罗指导(罗荣满)的深切缅怀,希望借世界杯之际,怀念一下已故的人。但这件事发生之后,我们的行为遭到广泛的批评,经过仔细思考,我们发现我们的最初的想法非常不成熟,有可能对参与投票的其他网友做成困扰,对此我们表示深切的内疚。
我们是广州的老球迷并一直怀念着那些属于广州足球的光荣岁月,我们非常欣赏每一个讲波佬,事实上,他们都非常专业以及具备非常独特的讲波艺术,进入了讲波评选的讲波佬,证明他们已经得到广泛球迷的认同。
这次我们的投票行为给贵站和其他工作人员做成了不便,我们希望能得到你们的谅解。我们已经在所有网站和BBS上删除了设计投票机的源代码和程序,并愿意提供一切必要的手段(包括技术手段)弥补已造成的影响。
灵感之源(http://unruledboy.cnblogs.com/)
David.Turing(http://openssl.blogjava.net)
Timill(http://blog.csdn.net/timiil/)
00000000h: 89 50 4E 47 0D 0A 1A 0A00 00 00 0D49 48 44 52 ; 塒NG........IHDR
00000010h: 00 00 00 CE 00 00 00 CE 08 02 00 00 00 F9 7D AA ; ...?..?....鶀?
00000020h: 93 00 00 00 09 70 48 59 73 00 00 0A 75 00 00 0A ; ?...pHYs...u...
00000030h: 75 01 4A 25 DD FD 00 00 0C 91 49 44 41 54 78 9C ; u.J%蔟...慖DATx?
00000040h: ED 9D D9 96 DC 2A 0C 45 A9 AC FC FF 2F D7 7D 70 ; 頋贃?.E┈?/讅p
00000050h: C7 97 66 10 9A 98 CF 7E C8 EA 54 95 6D 86 83 24 ; 菞f.殬蟸汝T昺唭$
00000060h: 04 B6 3F DF EF 37 00 D0 9F 3F B3 0B 00 6E 01 52 ; .?唢7.袩??.n.R
00000070h: 03 83 F8 3B BB 00 AB F2 F9 98 0E 47 58 92 01 A9 ; .凐;?鶚.GX??
89 50 4E 47 0D 0A 1A 0A 是PNG头部署名域,表示这是一个PNG图片
00 00 00 0D 描述IHDR头部的大小
49 48 44 52 是Chunk Type Code, 这里Chunk Type Code=IHDR
00 00 00 CE 00 00 00 CE 08 02 00 00 00 描述了Chunk Data,它是可变长度数据,00 00 00 0D 定义了长度为13个Bytes,所以,这里,你看到是13个字节)
F9 7D AA 93 是对IHDR的CRC校验
紧接着下面的就是pHys数据块,原理也是一样。
http://catcode.com/pngencoder/
http://prdownloads.sourceforge.net/javapng/javapng-2.0-rc4-src.jar?download
PNG格式
PNG是20世纪90年代中期开始开发的图像文件存储格式,其目的是企图替代GIF和TIFF文件格式,同时增加一些GIF文件格式所不具备的特性。流式网络图形格式(Portable Network Graphic Format,PNG)名称来源于非官方的“PNG's Not GIF”,是一种位图文件(bitmap file)存储格式,读成“ping”。PNG用来存储灰度图像时,灰度图像的深度可多到16位,存储彩色图像时,彩色图像的深度可多到48位,并且还可存储多到16位的α通道数据。PNG使用从LZ77派生的无损数据压缩算法。
PNG文件格式保留GIF文件格式的下列特性:
使用彩色查找表或者叫做调色板可支持256种颜色的彩色图像。
流式读/写性能(streamability):图像文件格式允许连续读出和写入图像数据,这个特性很适合于在通信过程中生成和显示图像。
逐次逼近显示(progressive display):这种特性可使在通信链路上传输图像文件的同时就在终端上显示图像,把整个轮廓显示出来之后逐步显示图像的细节,也就是先用低分辨率显示图像,然后逐步提高它的分辨率。
透明性(transparency):这个性能可使图像中某些部分不显示出来,用来创建一些有特色的图像。
辅助信息(ancillary information):这个特性可用来在图像文件中存储一些文本注释信息。
独立于计算机软硬件环境。
使用无损压缩。
PNG文件格式中要增加下列GIF文件格式所没有的特性:
每个像素为48位的真彩色图像。
每个像素为16位的灰度图像。
可为灰度图和真彩色图添加α通道。
添加图像的γ信息。
使用循环冗余码(cyclic redundancy code,CRC)检测损害的文件。
加快图像显示的逐次逼近显示方式。
标准的读/写工具包。
可在一个文件中存储多幅图像。
文件结构
PNG图像格式文件(或者称为数据流)由一个8字节的PNG文件署名(PNG file signature)域和按照特定结构组织的3个以上的数据块(chunk)组成。
PNG定义了两种类型的数据块,一种是称为关键数据块(critical chunk),这是标准的数据块,另一种叫做辅助数据块(ancillary chunks),这是可选的数据块。关键数据块定义了4个标准数据块,每个PNG文件都必须包含它们,PNG读写软件也都必须要支持这些数据块。虽然PNG文件规范没有要求PNG编译码器对可选数据块进行编码和译码,但规范提倡支持可选数据块。
(1) PNG文件署名域
8字节的PNG文件署名域用来识别该文件是不是PNG文件。该域的值是:
|
十进制数
|
137
|
80
|
78
|
71
|
13
|
10
|
26
|
10
|
|
十六进制数
|
89
|
50
|
4e
|
47
|
0d
|
0a
|
1a
|
0a
|
(2) 数据块的结构
每个数据块都由表6-07所示的的4个域组成。
表6-07 PNG文件数据块的结构
|
名称
|
字节数
|
说明
|
|
Length(长度)
|
4字节
|
指定数据块中数据域的长度,其长度不超过 (231-1)字节
|
|
Chunk Type Code(数据块类型码)
|
4字节
|
数据块类型码由ASCII字母(A-Z和a-z)组成
|
|
Chunk Data(数据块数据)
|
可变长度
|
存储按照Chunk Type Code指定的数据
|
|
CRC(循环冗余检测)
|
4字节
|
存储用来检测是否有错误的循环冗余码
|
在表6-07中,CRC(cyclic redundancy check)域中的值是对Chunk Type Code域和Chunk Data域中的数据进行计算得到的。CRC具体算法定义在ISO 3309和ITU-T V.42中,其值按下面的CRC码生成多项式进行计算:
x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
数据块结构
1. 关键数据块
关键数据块中的4个标准数据块是:
(1) 文件头数据块IHDR(header chunk):它包含有PNG文件中存储的图像数据的基本信息,并要作为第一个数据块出现在PNG数据流中,而且一个PNG数据流中只能有一个文件头数据块。
文件头数据块由13字节组成,它的格式如表6-08所示。
表6-08 PNG文件头键数据块的结构
|
域的名称
|
字节数
|
说明
|
|
Width
|
4 bytes
|
图像宽度,以像素为单位
|
|
Height
|
4 bytes
|
图像高度,以像素为单位
|
|
Bit depth
|
1 byte
|
图像深度: 索引彩色图像:1,2,4或8 灰度图像:1,2,4,8或16 真彩色图像:8或16
|
|
ColorType
|
1 byte
|
颜色类型: 0:灰度图像, 1,2,4,8或16 2:真彩色图像,8或16 3:索引彩色图像,1,2,4或8
4:带α通道数据的灰度图像,8或16 6:带α通道数据的真彩色图像,8或16
|
|
Compression method
|
1 byte
|
压缩方法(LZ77派生算法)
|
|
Filter method
|
1 byte
|
滤波器方法
|
|
Interlace method
|
1 byte
|
隔行扫描方法:
0:非隔行扫描
1: Adam7(由Adam M. Costello开发的7 遍隔行扫描方法)
|
(2) 调色板数据块PLTE(palette chunk):它包含有与索引彩色图像((indexed-color image))相关的彩色变换数据,它仅与索引彩色图像有关,而且要放在图像数据块(image data chunk)之前。真彩色的PNG数据流也可以有调色板数据块,目的是便于非真彩色显示程序用它来量化图像数据,从而显示该图像。调色板数据块结构如表6-09所示。
表6-09 调色板数据块结构
|
域的名称
|
字节数
|
说明
|
|
Red
|
1 byte
|
0 = 黑,255 = 红
|
|
Green
|
">
0 = 黑,255 = 绿
|
|
Blue
|
1 byte
|
0 = 黑,255 = 蓝
|
调色板实际是一个彩色索引查找表,它的表项数目可以是1~256中的一个数,每个表项有3字节,因此调色板数据块所包含的最大字节数为768。
(3) 图像数据块IDAT(image data chunk):它存储实际的数据,在数据流中可包含多个连续顺序的图像数据块。
(4) 图像结束数据IEND(image trailer chunk):它用来标记PNG文件或者数据流已经结束,并且必须要放在文件的尾部。
除了表示数据块开始的IHDR必须放在最前面, 表示PNG文件结束的IEND数据块放在最后面之外,其他数据块的存放顺序没有限制。
2. 辅助数据块
PNG文件格式规范制定的10个辅助数据块是:
(1) 背景颜色数据块bKGD(background color)。
(2) 基色和白色度数据块cHRM(primary chromaticities and white point)。所谓白色度是指当R=G=B=最大值时在显示器上产生的白色度。
(3) 图像γ数据块gAMA(image gamma)。
(4) 图像直方图数据块hIST(image histogram)。
(5) 物理像素尺寸数据块pHYs(physical pixel dimensions)。
(6) 样本有效位数据块sBIT(significant bits)。
(7) 文本信息数据块tEXt(textual data)。
(8) 图像最后修改时间数据块tIME (image last-modification time)。
(9) 图像透明数据块tRNS (transparency)。
(10) 压缩文本数据块zTXt (compressed textual data)。
3. 数据块摘要
关键数据块、辅助数据块和专用公共数据块(special-purpose public chunks)综合在表6-10中。
表6-10 PNG文件格式中的数据块
|
数据块符号
|
数据块名称
|
多数据块
|
可选否
|
位置限制
|
|
IHDR
|
文件头数据块
|
否
|
否
|
第一块
|
|
cHRM
|
基色和白色点数据块
|
否
|
是
|
在PLTE和IDAT之前
|
|
gAMA
|
图像γ数据块
|
否
|
是
|
在PLTE和IDAT之前
|
|
sBIT
|
样本有效位数据块
|
否
|
是
|
在PLTE和IDAT之前
|
|
PLTE
|
调色板数据块
|
否
|
是
|
在IDAT之前
|
|
bKGD
|
背景颜色数据块
|
否
|
是
|
在PLTE之后IDAT之前
|
|
hIST
|
图像直方图数据块
|
否
|
是
|
在PLTE之后IDAT之前
|
|
tRNS
|
图像透明数据块
|
否
|
是
|
在PLTE之后IDAT之前
|
|
oFFs
|
(专用公共数据块)
|
否
|
是
|
在IDAT之前
|
|
pHYs
|
物理像素尺寸数据块
|
否
|
是
|
在IDAT之前
|
|
sCAL
|
(专用公共数据块)
|
否
|
是
|
在IDAT之前
|
|
IDAT
|
图像数据块
|
是
|
否
|
与其他IDAT连续
|
|
tIME
|
图像最后修改时间数据块
|
否
|
是
|
无限制
|
|
tEXt
|
文本信息数据块
|
是
|
是
|
无限制
|
|
zTXt
|
压缩文本数据块
|
是
|
是
|
无限制
|
|
fRAc
|
(专用公共数据块)
|
是
|
是
|
无限制
|
|
gIFg
|
(专用公共数据块)
|
是
|
是
|
无限制
|
|
gIFt
|
(专用公共数据块)
|
是
|
是
|
无限制
|
|
gIFx
|
(专用公共数据块)
|
是
|
是
|
无限制
|
|
IEND
|
图像结束数据
|
否
|
否
|
最后一个数据块
|
tEXt和zTXt数据块中的标准关键字:
|
Title
|
图像名称或者标题
|
|
Author
|
图像作者名
|
|
Description
|
图像说明
|
|
Copyright
|
版权声明
|
|
CreationTime
|
原图创作时间
|
|
Software
|
创作图像使用的软件
|
|
Disclaimer
|
弃权
|
|
Warning
|
图像内容警告
|
|
Source
|
创作图像使用的设备
|
|
Comment
|
各种注释
|