NullPointerException when generating WSDL for service with an empty TransportToken policy -----------------------------------------------------------------------------------------
Key: RAMPART-176 URL: https://issues.apache.org/jira/browse/RAMPART-176 Project: Rampart Issue Type: Bug Components: rampart-policy Reporter: Predrag Knezevic Assignee: Ruchith Udayanga Fernando Fix For: 1.4 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: {noformat} <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> {noformat} 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 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.