Client Callback Handlers
When creating the web service project, the
-Dsecurity.policy=usernameAuthSymmetricKeys property was supplied. This instructed the framework to explicitly secure the web service with the security policy, which is described in
Username Authentication with Symmetric Keys. If this property had not been explicitly provided, then the security policy would have defaulted to the value of the
security.policy property as configured in
<Windchill>/bin/adminTools/WebServices/security.properties.
When generating the client portion of the project, this policy causes a default client-side callback handler configuration to be used. This is specified in the handler.config property of the src_client/build.xml build script. To view the format of the handler.config property, run the ant usage command from within the src_client directory.
The com.ptc.jws.client.handler package also contains some basic callback handlers for your web service client to use for the supported security policies (these handler classes are automatically packaged for you when you build your client). You can choose to use these classes to provide security information for your web service clients, or you can choose to author your own by providing a class that implements javax.security.auth.callback.CallbackHandler and then providing that class as part of the handler.config property.
The default callback handler supplied for usernameAuthSymmetricKeys prompts for credentials on the command line. It can be configured to prompt the user for credentials using swing dialogs or to fetch the credentials from system properties. It only prompts for credentials once per thread, and reuses the credentials until you programatically clear them.
If you want to programmagically provide credentials, you should do so using the com.ptc.jws.client.handler.Credentials class using the setUsername and setPassword methods.
The web services framework makes use of two separate callback mechanisms:
• The WSIT (Web Services Interoperability Technologies) mechanism uses the javax.security.auth.callback.CallbackHandler implementations.
These handlers are used for security policies other than webServerAuthenticated to gather the credentials or security tokens that are passed to the web service. If these implementations do not meet the needs of your application, you can implement your own and supply them using the handler.config property in the build.xml file.
• The JAX-WS handler chain is essentially a list of Java classes typically implementing the following:
javax.xml.ws.handler.soap.SOAPHandler<javax.xml.ws.handler.soap.SOAPMessageContext>
Instead of implementing the client code, these handler classes can provide generic functionality and conditioning for SOAP interactions. The web services framework provides some basic handlers to handle details, such as supplying the URL to your web service and adding credentials to requests when web server authentication is used.
These handlers can also be written to perform additional functions, such as add headers to SOAP requests or handle faults in a generic fashion. You can tailor the handler chain of you client by changing the values of the handler.chain properties in the build.xml file. These properties are described in greater detail within the build.xml file.