您的位置:首页 > 其它

Cxf+wss4j的WS-Security实现(异常解决续篇)

2011-08-22 15:43 357 查看
在http://blog.csdn.net/wangchsh2008/article/details/6708270中,我做了一个最简单的cxf安全认证的demo,在其过程中,出现了很多问题。

一开始lib下缺少xalan-2.7.1.jar、opensaml-1.1.jar、serializer-2.7.1.jar,老是报错。

以上3个jar的下载地址分别为:

http://www.jarfinder.com/index.php/jars/versionInfo/69677

http://d.download.csdn.net/down/337408/wuwenlong527

http://www.jarfinder.com/index.php/jars/versionInfo/69675

后来又出现以下异常:

org.apache.ws.security.WSSecurityException: WSHandler: Encryption: error during message processingorg.apache.ws.security.WSSecurityException: An unsupported signature or encryption algorithm was used (unsupported key transport encryption algorithm: No such algorithm: http://www.w3.org/2001/04/xmlenc#rsa-1_5) 	at org.apache.ws.security.action.EncryptionAction.execute(EncryptionAction.java:65)
	at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:197)
	at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$200(WSS4JOutInterceptor.java:47)
	at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:219)
	... 8 more
在网上做了一些工作之后,发现是因为系统环境中默认的jre的JCE(Java Cryptography Extension)是受限的,应把它替换成不受限的版本。

解决方法:

下载bcprov-jdk15-1.44.jar包置于%JRE_HOME%/lib/ext目录下。

下载jce_policy-1_5_0.zip,把解压得到的US_export_policy.jar和local_policy.jar两个jar包置于%JRE_HOME%/lib/security目录下。(替换原来的)

修改%JRE_HOME%/lib/security/java.security文件,新增配置:security.provider.7=org.bouncycastle.jce.provider.BouncyCastleProvider。

把bcprov-jdk15-1.44.jar导入工程。

我从网上找了bcprov-jdk13-132.jar和jce_policy-1_4_2,已上传至:http://download.csdn.net/source/3539611

虽然版本比上面的低,但是经测试是可用的。

本文参考文章地址如下:
http://wxu.iteye.com/blog/284884 http://blog.163.com/jxguo_05/blog/static/71940100201151654322361/ http://magicbear.iteye.com/blog/234125
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐