You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jose María Zaragoza <de...@gmail.com> on 2013/06/18 09:54:39 UTC

WSS4J random NullPointerException when signing message

Hello:

I'm using Apache CXF 2.7.3

I'm getting this exception sometimes.
It's a NullPointerException in
org.apache.jcp.xml.dsig.internal.dom.DOMReference.marshal method
Is there any problem with xmlsec-1.5.3 + wss4j-1.6.9 ?


But other times, usually after restart Tomcat server, it works fine ( with
the same test )
I've pasted .WSS4JOutInterceptor's configuration below

Caused by: org.apache.ws.security.WSSecurityException: Signature creation
failed
at
org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:558)
~[wss4j-1.6.9.jar:1.6.9]
 at
org.apache.ws.security.action.SignatureAction.execute(SignatureAction.java:99)
~[wss4j-1.6.9.jar:1.6.9]
... 52 common frames omitted
Caused by: java.lang.NullPointerException: null
at
org.apache.jcp.xml.dsig.internal.dom.DOMReference.marshal(DOMReference.java:297)
~[xmlsec-1.5.3.jar:1.5.3]
 at
org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo.marshal(DOMSignedInfo.java:268)
~[xmlsec-1.5.3.jar:1.5.3]
at
org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.marshal(DOMXMLSignature.java:216)
~[xmlsec-1.5.3.jar:1.5.3]
 at
org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(DOMXMLSignature.java:329)
~[xmlsec-1.5.3.jar:1.5.3]
at
org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:553)
~[wss4j-1.6.9.jar:1.6.9]


<bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
id="sign">
        <constructor-arg>
            <map>
                <entry key="action" value="Signature"/>
                <entry key="user" value="me"/>
                <entry key="signatureUser" value="me"/>

                <entry key="passwordCallbackClass"
value="com.prosodie.ws.fijo.util.KeystorePasswordCallback"/>
                <entry key="signaturePropFile" value="keystore.properties"/>
                <entry key="signatureKeyIdentifier"
value="DirectReference"/>
                <entry key="signatureParts" value="{Content}{
http://schemas.xmlsoap.org/soap/envelope/}Body"/>
                <entry key="signatureAlgorithm" value="
http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>

                <entry key="sigCanonicalization" value="
http://www.w3.org/2001/10/xml-exc-c14n#"/>
                <entry key="signatureDigestAlgorithm" value="
http://www.w3.org/2000/09/xmldsig#sha1"/>

            </map>
        </constructor-arg>
    </bean>

Re: WSS4J random NullPointerException when signing message

Posted by Jose María Zaragoza <de...@gmail.com>.
I've observed that  i need to restart Tomcat server after deploying , when
I use WSS4J
If I don't do it, java.lang.NullPointerException in DOMReference.java is
thrown

Does anyone know why ?

Thanks and regards



2013/6/18 Jose María Zaragoza <de...@gmail.com>

>
> Hello:
>
> I'm using Apache CXF 2.7.3
>
> I'm getting this exception sometimes.
> It's a NullPointerException in
> org.apache.jcp.xml.dsig.internal.dom.DOMReference.marshal method
> Is there any problem with xmlsec-1.5.3 + wss4j-1.6.9 ?
>
>
> But other times, usually after restart Tomcat server, it works fine ( with
> the same test )
> I've pasted .WSS4JOutInterceptor's configuration below
>
> Caused by: org.apache.ws.security.WSSecurityException: Signature creation
> failed
> at
> org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:558)
> ~[wss4j-1.6.9.jar:1.6.9]
>  at
> org.apache.ws.security.action.SignatureAction.execute(SignatureAction.java:99)
> ~[wss4j-1.6.9.jar:1.6.9]
> ... 52 common frames omitted
> Caused by: java.lang.NullPointerException: null
> at
> org.apache.jcp.xml.dsig.internal.dom.DOMReference.marshal(DOMReference.java:297)
> ~[xmlsec-1.5.3.jar:1.5.3]
>  at
> org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo.marshal(DOMSignedInfo.java:268)
> ~[xmlsec-1.5.3.jar:1.5.3]
> at
> org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.marshal(DOMXMLSignature.java:216)
> ~[xmlsec-1.5.3.jar:1.5.3]
>  at
> org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(DOMXMLSignature.java:329)
> ~[xmlsec-1.5.3.jar:1.5.3]
> at
> org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:553)
> ~[wss4j-1.6.9.jar:1.6.9]
>
>
> <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
> id="sign">
>         <constructor-arg>
>             <map>
>                 <entry key="action" value="Signature"/>
>                 <entry key="user" value="me"/>
>                 <entry key="signatureUser" value="me"/>
>
>                 <entry key="passwordCallbackClass"
> value="com.prosodie.ws.fijo.util.KeystorePasswordCallback"/>
>                 <entry key="signaturePropFile"
> value="keystore.properties"/>
>                 <entry key="signatureKeyIdentifier"
> value="DirectReference"/>
>                 <entry key="signatureParts" value="{Content}{
> http://schemas.xmlsoap.org/soap/envelope/}Body"/>
>                 <entry key="signatureAlgorithm" value="
> http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
>
>                 <entry key="sigCanonicalization" value="
> http://www.w3.org/2001/10/xml-exc-c14n#"/>
>                 <entry key="signatureDigestAlgorithm" value="
> http://www.w3.org/2000/09/xmldsig#sha1"/>
>
>             </map>
>         </constructor-arg>
>     </bean>
>

Re: WSS4J random NullPointerException when signing message

Posted by Jose María Zaragoza <de...@gmail.com>.
I've looked at DOMReference.java , line 297

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.santuario/xmlsec/1.5.3/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java#DOMReference.marshal%28org.w3c.dom.Node%2Cjava.lang.String%2Cjavax.xml.crypto.dom.DOMCryptoContext%29


and it is

297   if(log.isDebugEnabled()) {

298   log.debug("Marshalling Reference");

299   }


If I enable debug logging, that log ( "Marshalling Reference" ) is not shown
If I restart Tomcat server, and retry the same test, all works fine and
that log is shown

Why do I need to restart server ?
How is possible that log variable throws a NullPointerException ?

Thanks







2013/6/18 Jose María Zaragoza <de...@gmail.com>

>
> Hello:
>
> I'm using Apache CXF 2.7.3
>
> I'm getting this exception sometimes.
> It's a NullPointerException in
> org.apache.jcp.xml.dsig.internal.dom.DOMReference.marshal method
> Is there any problem with xmlsec-1.5.3 + wss4j-1.6.9 ?
>
>
> But other times, usually after restart Tomcat server, it works fine ( with
> the same test )
> I've pasted .WSS4JOutInterceptor's configuration below
>
> Caused by: org.apache.ws.security.WSSecurityException: Signature creation
> failed
> at
> org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:558)
> ~[wss4j-1.6.9.jar:1.6.9]
>  at
> org.apache.ws.security.action.SignatureAction.execute(SignatureAction.java:99)
> ~[wss4j-1.6.9.jar:1.6.9]
> ... 52 common frames omitted
> Caused by: java.lang.NullPointerException: null
> at
> org.apache.jcp.xml.dsig.internal.dom.DOMReference.marshal(DOMReference.java:297)
> ~[xmlsec-1.5.3.jar:1.5.3]
>  at
> org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo.marshal(DOMSignedInfo.java:268)
> ~[xmlsec-1.5.3.jar:1.5.3]
> at
> org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.marshal(DOMXMLSignature.java:216)
> ~[xmlsec-1.5.3.jar:1.5.3]
>  at
> org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(DOMXMLSignature.java:329)
> ~[xmlsec-1.5.3.jar:1.5.3]
> at
> org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:553)
> ~[wss4j-1.6.9.jar:1.6.9]
>
>
> <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
> id="sign">
>         <constructor-arg>
>             <map>
>                 <entry key="action" value="Signature"/>
>                 <entry key="user" value="me"/>
>                 <entry key="signatureUser" value="me"/>
>
>                 <entry key="passwordCallbackClass"
> value="com.prosodie.ws.fijo.util.KeystorePasswordCallback"/>
>                 <entry key="signaturePropFile"
> value="keystore.properties"/>
>                 <entry key="signatureKeyIdentifier"
> value="DirectReference"/>
>                 <entry key="signatureParts" value="{Content}{
> http://schemas.xmlsoap.org/soap/envelope/}Body"/>
>                 <entry key="signatureAlgorithm" value="
> http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
>
>                 <entry key="sigCanonicalization" value="
> http://www.w3.org/2001/10/xml-exc-c14n#"/>
>                 <entry key="signatureDigestAlgorithm" value="
> http://www.w3.org/2000/09/xmldsig#sha1"/>
>
>             </map>
>         </constructor-arg>
>     </bean>
>