Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-841

NullPointerException on First invocation to Spring WS Service with Nonce

    Details

    • Type: Support
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1.4
    • Component/s: Security
    • Labels:
      None
    • Environment:
      JBoss 5.1 GA on GNU/Linux server 2.6.32.59
      Tested also with same AS in a Windows 7 laptop

      Description

      I have a web service implemented with Spring WS stack over a JBoss 5.1 GA.

      The service has configured as one of the interceptors the security interceptor:

      <bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
        <property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml" />
        <property name="callbackHandlers">
          <list>
            <ref bean="ldapAuthenticationHandler" />
          </list>
        </property>
      </bean>

      The content of securityPolicy.xml file is the following one:

      <xwss:RequireUsernameToken passwordDigestRequired="false" nonceRequired="true" />

      The problem is that since I set the nonceRequired attribute to true, always the first invocation sent to the service returns a NullPointerException:

      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Client</faultcode>
         <faultstring xml:lang="en">java.lang.NullPointerException; nested exception is com.sun.xml.wss.XWSSecurityException: java.lang.NullPointerException</faultstring>
      </SOAP-ENV:Fault>

      On following invocations exception is never found again.
      It seems related to the nonce cache, as it in first invocation the cache is not created yet and instead of validating any input nonce, it returns this exception.

      Is there any way to avoid this problem? The environment on which the app is installed restarts everyday so always users get this error once a day.

      I attach the full appContext file of the web service in case it helps.

      Thanks a lot and regards.

        Activity

        Hide
        sbauer89 Steven Bauer added a comment -

        I am seeing the same issue.
        Also JBOSS 5.1.
        spring-ws-core version 2.1.3.RELEASE

        Show
        sbauer89 Steven Bauer added a comment - I am seeing the same issue. Also JBOSS 5.1. spring-ws-core version 2.1.3.RELEASE
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Added code tags.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Added code tags.
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Could you give me the full stack trace of the server side? I'd like to know where the NPE occurs.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Could you give me the full stack trace of the server side? I'd like to know where the NPE occurs.
        Hide
        arjen.poutsma Arjen Poutsma added a comment - - edited

        After some more verification, it seems that the NPE occurs when a message does contain a Nonce element, but does not contain a Created element. XWSS does not like this, and throws a NullPointerException with the following stacktrace:

        Caused by: com.sun.xml.wss.XWSSecurityException: java.lang.NullPointerException
        	at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.verifyInboundMessage(XWSSProcessor2_0Impl.java:150)
        	at org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor.validateMessage(XwsSecurityInterceptor.java:164)
        	... 28 more
        Caused by: java.lang.NullPointerException
        	at java.util.Hashtable.put(Hashtable.java:394)
        	at com.sun.xml.wss.impl.misc.NonceCache.validateAndCacheNonce(NonceCache.java:93)
        	at com.sun.xml.wss.impl.misc.DefaultNonceManager.validateNonce(DefaultNonceManager.java:74)
        	at com.sun.xml.wss.impl.misc.DefaultSecurityEnvironmentImpl.validateAndCacheNonce(DefaultSecurityEnvironmentImpl.java:1506)
        	at com.sun.xml.wss.impl.filter.AuthenticationTokenFilter.getUserNameTokenFromMessage(AuthenticationTokenFilter.java:308)
        	at com.sun.xml.wss.impl.filter.AuthenticationTokenFilter.processUserNameToken(AuthenticationTokenFilter.java:106)
        	at com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:105)
        	at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:268)
        	at com.sun.xml.wss.impl.SecurityRecipient.processMessagePolicy(SecurityRecipient.java:1027)
        	at com.sun.xml.wss.impl.SecurityRecipient.processMessagePolicy(SecurityRecipient.java:815)
        	at com.sun.xml.wss.impl.SecurityRecipient.validateMessage(SecurityRecipient.java:256)
        	at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.verifyInboundMessage(XWSSProcessor2_0Impl.java:148)
        	... 29 more

        The stacktrace originates from the fact that com.sun.xml.wss.impl.misc.NonceCache.validateAndCacheNonce wants to insert a null value for the created date into a Hashtable, which does not allow null values.

        I tried to create a workaround for this, by repeating the XWSS method call twice (as suggested in the description), but this seems to have no effect.

        Closing as Won't Fix, because it appears to be a XWSS issue with no possible workaround. If more investigation is requested, please supply a reproducible test case in the same format as org.springframework.ws.soap.security.xwss.XwssMessageInterceptorUsernameTokenTest.

        Show
        arjen.poutsma Arjen Poutsma added a comment - - edited After some more verification, it seems that the NPE occurs when a message does contain a Nonce element, but does not contain a Created element. XWSS does not like this, and throws a NullPointerException with the following stacktrace: Caused by: com.sun.xml.wss.XWSSecurityException: java.lang.NullPointerException at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.verifyInboundMessage(XWSSProcessor2_0Impl.java:150) at org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor.validateMessage(XwsSecurityInterceptor.java:164) ... 28 more Caused by: java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:394) at com.sun.xml.wss.impl.misc.NonceCache.validateAndCacheNonce(NonceCache.java:93) at com.sun.xml.wss.impl.misc.DefaultNonceManager.validateNonce(DefaultNonceManager.java:74) at com.sun.xml.wss.impl.misc.DefaultSecurityEnvironmentImpl.validateAndCacheNonce(DefaultSecurityEnvironmentImpl.java:1506) at com.sun.xml.wss.impl.filter.AuthenticationTokenFilter.getUserNameTokenFromMessage(AuthenticationTokenFilter.java:308) at com.sun.xml.wss.impl.filter.AuthenticationTokenFilter.processUserNameToken(AuthenticationTokenFilter.java:106) at com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:105) at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:268) at com.sun.xml.wss.impl.SecurityRecipient.processMessagePolicy(SecurityRecipient.java:1027) at com.sun.xml.wss.impl.SecurityRecipient.processMessagePolicy(SecurityRecipient.java:815) at com.sun.xml.wss.impl.SecurityRecipient.validateMessage(SecurityRecipient.java:256) at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.verifyInboundMessage(XWSSProcessor2_0Impl.java:148) ... 29 more The stacktrace originates from the fact that com.sun.xml.wss.impl.misc.NonceCache.validateAndCacheNonce wants to insert a null value for the created date into a Hashtable, which does not allow null values. I tried to create a workaround for this, by repeating the XWSS method call twice (as suggested in the description), but this seems to have no effect. Closing as Won't Fix, because it appears to be a XWSS issue with no possible workaround. If more investigation is requested, please supply a reproducible test case in the same format as org.springframework.ws.soap.security.xwss.XwssMessageInterceptorUsernameTokenTest.

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            j.perez.nuno Jorge Perez
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: