使用wss4j插入X509证书时出现异常

时间:2013-10-23 13:43:30

标签: java soap x509certificate wss4j

当我使用wss4j在soap标头中对X509进行签名时,存在异常。 我的代码在这里:

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    Document document = msg.getSOAPPart().getEnvelope().getOwnerDocument(); 



    Crypto crypto = CryptoFactory.getInstance();   

    WSSecSignature signature = new WSSecSignature();


    WSSecHeader secuHeader = new WSSecHeader("",false);
    secuHeader.insertSecurityHeader(document);

    String user = "16c73ab6-b892-458f-abf5-2f875f74882e";
    String password ="security";

    signature.setUserInfo(user, password);
    signature.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
    signature.build(document, crypto, secuHeader);

我只使用wss4j中的默认crypto.properties。但是,存在一个例外:

Exception in thread "main" java.lang.AssertionError: UNIMPLEMENTED
    at weblogic.xml.domimpl.ElementBase.setIdAttributeNS(ElementBase.java:327)
    at org.jcp.xml.dsig.internal.dom.DOMUtils.setAttributeID(Unknown Source)
    at org.jcp.xml.dsig.internal.dom.DOMKeyInfo.marshal(Unknown Source)
    at org.jcp.xml.dsig.internal.dom.DOMKeyInfo.marshal(Unknown Source)
    at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.marshal(Unknown Source)
    at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(Unknown Source)
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:554)
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:479)
    at org.apache.ws.security.message.WSSecSignature.build(WSSecSignature.java:385)

我想知道如何解决这个异常。谢谢你的帮助!

0 个答案:

没有答案