Uploaded image for project: 'Rampart'
  1. Rampart
  2. RAMPART-176

NullPointerException when generating WSDL for service with an empty TransportToken policy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • rampart-policy
    • None

    Description

      As the example located in samples/policy/sample01 suggests, the policy of TransportToken might be empty. Here is the snippet from the service.xml file:

      <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
      <wsp:Policy>
      <sp:TransportToken>
      <wsp:Policy>
      <!-- <sp:HttpsToken RequireClientCertificate="false"/> -->
      </wsp:Policy>
      </sp:TransportToken>
      <sp:AlgorithmSuite>
      <wsp:Policy>
      <sp:Basic256/>
      </wsp:Policy>
      </sp:AlgorithmSuite>
      <sp:Layout>
      <wsp:Policy>
      <sp:Lax/>
      </wsp:Policy>
      </sp:Layout>
      <sp:IncludeTimestamp/>
      </wsp:Policy>
      </sp:TransportBinding>

      Deploying a service with this policy goes fine, and it is available and react properly, but if you want to get the corresponding WSDL, NullPointerException is thrown and WSDL is not returned. The exception happens in serialize() method of TransportToken class, because it is not expected that the policy can be empty. A simple is fix is necessary, here is the diff:

      Index: C:/development/vw-workspace/rampart-svn/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/TransportToken.java
      ===================================================================
      — C:/development/vw-workspace/rampart-svn/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/TransportToken.java (revision 668696)
      +++ C:/development/vw-workspace/rampart-svn/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/TransportToken.java (working copy)
      @@ -87,7 +87,7 @@
      writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());

      // serialization of the token ..

      • transportToken.serialize(writer);
        + if (transportToken != null) transportToken.serialize(writer);

      // </wsp:Policy>
      writer.writeEndElement();

      If other tokens allow empty policies as well (I do not know much about the specification), they should be fixed in the similar way.

      Greetings,

      Predrag

      Attachments

        Activity

          People

            ruchith Ruchith B. Gunaratne
            predrag.knezevic Predrag Knezevic
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: