Announcement Announcement Module
Collapse
No announcement yet.
XMLSecurityException: Cannot create ds:SignatureMethod from SignatureMethod. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • XMLSecurityException: Cannot create ds:SignatureMethod from SignatureMethod.

    Hello,

    I am trying to use Apache XML Security through Spring web services 1.5.6 (WSS4JInterceptor) to digitally sign messages.

    At runtime I get the following exception: (I have to suppress the XML URL in the exception as the forum do not let you post URLs for your first post.)

    ERROR o.a.w.s.message.WSSecSignature -
    org.apache.xml.security.exceptions.XMLSecurityExce ption: Cannot create a xmldsig#:ds:SignatureMethod from a xmldsig#:SignatureMethod element
    at org.apache.xml.security.utils.ElementCheckerImpl$I nternedNsChecker.guaranteeThatElementInCorrectSpac e(Unknown Source)
    at org.apache.xml.security.utils.ElementProxy.guarant eeThatElementInCorrectSpace(Unknown Source)
    at org.apache.xml.security.utils.ElementProxy.<init>( Unknown Source)
    at org.apache.xml.security.utils.SignatureElementProx y.<init>(Unknown Source)
    at org.apache.xml.security.algorithms.Algorithm.<init >(Unknown Source)
    at org.apache.xml.security.algorithms.SignatureAlgori thm.<init>(Unknown Source)
    at org.apache.xml.security.signature.SignedInfo.<init >(Unknown Source)
    at org.apache.xml.security.signature.XMLSignature.<in it>(Unknown Source)
    at org.apache.ws.security.message.WSSecSignature.prep are(WSSecSignature.java:366)
    at org.apache.ws.security.message.WSSecSignature.buil d(WSSecSignature.java:746)
    at org.apache.ws.security.action.SignatureAction.exec ute(SignatureAction.java:54)
    at org.apache.ws.security.handler.WSHandler.doSenderA ction(WSHandler.java:201)
    at org.springframework.ws.soap.security.wss4j.Wss4jHa ndler.doSenderAction(Wss4jHandler.java:162)
    at org.springframework.ws.soap.security.wss4j.Wss4jSe curityInterceptor.secureMessage(Wss4jSecurityInter ceptor.java:457)


    I downloaded wssj-1.5.5 and xmlsec-1.4.2 source code to understand what's going on. Trying to construct XMLSignature in WSSecSignature.java throws the exception:

    SignatureAlgorithm signatureAlgorithm = new SignatureAlgorithm(doc, sigAlgo);
    sig = new XMLSignature(doc, null, signatureAlgorithm.getElement(), canonElem);

    _constructionElement of signatureAlgorithm instance looks something like: <ds:SignatureMethod...../>. I am assuming, while creating instance of XMLSignature the guaranteeThatElementInCorrectSpace() method tries to compare <SignatureMethod.../> with <ds:SignatureMethod../> and hence the exception. For some reason the "ds" prefix does not get set in the call to XMLSignature's constructor.

    Not sure if this is due to Wss4JInterceptor configuration, or conflicting jars or plain bug in wss4j-1.5.5 or xmlsec-1.4.2.

    Could some one please guide.

    Thanks,
    Mihir
Working...
X