WS-Security: axis, cxf使用wss4j的中文处理问题

就我碰到的,中文问题主要是2个:
1) 传出的字符乱码
2) 出现如下异常:
引用
org.apache.ws.security.WSSecurityException: The signature or decryption was invalid; nested exception is:
org.apache.xml.security.encryption.XMLEncryptionException: An invalid XML character (Unicode: 0x10) was found in the element content of the document.
Original Exception was org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x10) was found in the element content of the document.
at org.apache.ws.security.processor.EncryptedKeyProcessor.decryptDataRef(EncryptedKeyProcessor.java:431)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:342)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:92)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleToken(EncryptedKeyProcessor.java:80)
at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:311)

升级wss4j到1.5.5可解决问题,主要有2个jar包需要替换:以1.5.4到1.5.5为例
1) wss4j-1.5.4.jar -> wss4j-1.5.5.jar
2) xmlsec-1.4.0.jar -> xmlsec-1.4.2.jar

中文处理问题可能与xmlsec-1.4.0的一个问题有关:
引用
Xml canonization - UTF-8 encoding issue in Xml security 1.4.0.
       Committed by RB. Thanks to Karol Rewera. See Issue 41462

该问题在xmlsec-1.4.1中解决。

Apache XML Security History of Changes:
http://santuario.apache.org/changes.html

你可能感兴趣的:(java,apache,xml,Security,cgi)