When context.getMessage is called JAXWS builds a DOM representation of
the message, could be a error when converting.
who is adding this header to the message.
<sp:Header Name="Timestamp"
Namespace="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
If you want to sign timestamp then all you have to do is add
<sp:IncludeTimestamp /> assertion into the message, timestamps are
signed by default if present under the
SecurityHeader of the message.
As far as Nullpointer is concerned looks like a bug in JAXWS . I have
cc'ed them . Can you send us a reproducible testcase .
Thanks,
Venu
Mark Shure wrote:
> I've run into a NullPointerException in the sign operation.
>
> I've got a Handler that I've cut back that does nothing but call
> "context.getMessage()" (handler code pasted below). Calling
> "context.getMessage()" causes a NPE in the sign operation (log
> messages pasted below handler code). If I comment out the
> context.getMessage(), there's no NPE.
>
> I also found out that if only the timestamp is signed, there's no NPE.
> So if I changed my Message Policy to below and still called
> "context.getMessage()" in the handler, there's no NPE. (Maybe it's
> because the Timestamp is in the same namespace as the Id attribute.)
>
> <wsp:Policy wsu:Id="MessagePolicy">
> <wsp:ExactlyOne>
> <wsp:All>
> <sp:EncryptedParts>
> <sp:Body/>
> </sp:EncryptedParts>
> <sp:SignedParts>
> <!--
> <sp:Body/>
> <sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
> -->
> <sp:Header Name="Timestamp"
>
> Namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
>
> </sp:SignedParts>
> </wsp:All>
> </wsp:ExactlyOne>
> </wsp:Policy>
>
> Oh, and I'm still using JAX-WS 2.1 with WSIT.
>
> Mark
>
> ======================================
> JAX-WS Handler
>
> public class DoNothingHandler implements
> SOAPHandler<SOAPMessageContext> {
>
> private static final Logger LOG = Logger.getLogger(
> DoNothingHandler.class.getName());
>
> public Set<QName> getHeaders() {
> return null;
> }
>
> public boolean handleMessage(SOAPMessageContext context) {
> LOG.info("DoNothingHandler:handleMessage:point 1");
> context.getMessage();
> LOG.info("DoNothingHandler:handleMessage:point 2");
>
> return true;
> }
>
> public boolean handleFault(SOAPMessageContext context) {
> return true;
> }
>
> public void close(MessageContext context) {
> }
>
> }
>
> ======================================
> Logs
>
> 15/02/2007 10:51:26 au.gov.nehta.common.DoNothingHandler handleMessage
> INFO: DoNothingHandler:handleMessage:point 1
> 15/02/2007 10:51:26 au.gov.nehta.common.DoNothingHandler handleMessage
> INFO: DoNothingHandler:handleMessage:point 2
> 15/02/2007 10:51:26
> com.sun.xml.ws.security.opt.impl.dsig.SignatureProcessor sign
> SEVERE: WSS1316: Sign operation failed.
> java.lang.NullPointerException
> at com.sun.xml.ws.util.DOMUtil.isPrefixDeclared(DOMUtil.java:199)
> at
> com.sun.xml.ws.util.DOMUtil.writeTagWithAttributes(DOMUtil.java:138)
> at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:103)
> at com.sun.xml.ws.message.DOMHeader.writeTo(DOMHeader.java:89)
> at
> com.sun.xml.ws.security.opt.impl.dsig.SignedMessageHeader.writeTo(SignedMessageHeader.java:146)
>
> at
> com.sun.xml.ws.security.opt.impl.crypto.JAXBDataImpl.writeTo(JAXBDataImpl.java:96)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Exc14nCanonicalizer.transform(Exc14nCanonicalizer.java:158)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Transform.transform(Transform.java:133)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Reference.transform(Reference.java:143)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Reference.digest(Reference.java:96)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Signature.sign(Signature.java:194)
>
> at
> com.sun.xml.ws.security.opt.impl.dsig.SignatureProcessor.sign(SignatureProcessor.java:104)
>
> at
> com.sun.xml.wss.impl.filter.SignatureFilter.sign(SignatureFilter.java:450)
>
> at
> com.sun.xml.wss.impl.filter.SignatureFilter.process(SignatureFilter.java:412)
>
> at
> com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:79)
> at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:249)
> at
> com.sun.xml.wss.impl.SecurityAnnotator.processMessagePolicy(SecurityAnnotator.java:172)
>
> at
> com.sun.xml.wss.impl.SecurityAnnotator.secureMessage(SecurityAnnotator.java:133)
>
> at
> com.sun.xml.wss.jaxws.impl.SecurityPipeBase.secureOutboundMessage(SecurityPipeBase.java:379)
>
> at
> com.sun.xml.wss.jaxws.impl.SecurityClientPipe.process(SecurityClientPipe.java:164)
>
> at
> com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:79)
>
> at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:559)
> at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:518)
> at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503)
> at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:400)
> at com.sun.xml.ws.client.Stub.process(Stub.java:228)
> at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:120)
> at
> com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:226)
>
> at
> com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:206)
>
> at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
> at $Proxy44.ping(Unknown Source)
> at
> au.gov.nehta.dischargesummaryreceiver.client.AbstractWebServiceTest.testPing(Unknown
> Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:228)
> at junit.framework.TestSuite.run(TestSuite.java:223)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
>
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
>
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
>
> com.sun.xml.wss.XWSSecurityException: java.lang.NullPointerException
> at
> com.sun.xml.ws.security.opt.impl.dsig.SignatureProcessor.sign(SignatureProcessor.java:121)
>
> at
> com.sun.xml.wss.impl.filter.SignatureFilter.sign(SignatureFilter.java:450)
>
> at
> com.sun.xml.wss.impl.filter.SignatureFilter.process(SignatureFilter.java:412)
>
> at
> com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:79)
> at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:249)
> at
> com.sun.xml.wss.impl.SecurityAnnotator.processMessagePolicy(SecurityAnnotator.java:172)
>
> at
> com.sun.xml.wss.impl.SecurityAnnotator.secureMessage(SecurityAnnotator.java:133)
>
> at
> com.sun.xml.wss.jaxws.impl.SecurityPipeBase.secureOutboundMessage(SecurityPipeBase.java:379)
>
> at
> com.sun.xml.wss.jaxws.impl.SecurityClientPipe.process(SecurityClientPipe.java:164)
>
> at
> com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:79)
>
> at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:559)
> at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:518)
> at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503)
> at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:400)
> at com.sun.xml.ws.client.Stub.process(Stub.java:228)
> at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:120)
> at
> com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:226)
>
> at
> com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:206)
>
> at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
> at $Proxy44.ping(Unknown Source)
> at
> au.gov.nehta.dischargesummaryreceiver.client.AbstractWebServiceTest.testPing(Unknown
> Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:228)
> at junit.framework.TestSuite.run(TestSuite.java:223)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
>
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
>
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
>
> Caused by: java.lang.NullPointerException
> at com.sun.xml.ws.util.DOMUtil.isPrefixDeclared(DOMUtil.java:199)
> at
> com.sun.xml.ws.util.DOMUtil.writeTagWithAttributes(DOMUtil.java:138)
> at com.sun.xml.ws.util.DOMUtil.serializeNode(DOMUtil.java:103)
> at com.sun.xml.ws.message.DOMHeader.writeTo(DOMHeader.java:89)
> at
> com.sun.xml.ws.security.opt.impl.dsig.SignedMessageHeader.writeTo(SignedMessageHeader.java:146)
>
> at
> com.sun.xml.ws.security.opt.impl.crypto.JAXBDataImpl.writeTo(JAXBDataImpl.java:96)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Exc14nCanonicalizer.transform(Exc14nCanonicalizer.java:158)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Transform.transform(Transform.java:133)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Reference.transform(Reference.java:143)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Reference.digest(Reference.java:96)
>
> at
> com.sun.xml.ws.security.opt.crypto.dsig.Signature.sign(Signature.java:194)
>
> at
> com.sun.xml.ws.security.opt.impl.dsig.SignatureProcessor.sign(SignatureProcessor.java:104)
>
> ... 35 more
>
> _________________________________________________________________
> Advertisement: 50% off on Xbox 360, PS and Nintendo Wii titles!
> http://www.play-asia.com/SOap-23-83-4lab-71-bn-49-en-84-k-40-extended.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_xwss.dev.java.net
> For additional commands, e-mail: users-help_at_xwss.dev.java.net
>