|
Download
FAQ History |
|
API
Search Feedback |
Understanding and Running the Interop Sample Application
This example is a fully-developed sample application that demonstrates various configurations that can be used to exercise XWS-Security framework code. The types of security configurations possible in this example include Digital Signature, XML Encryption, and UserName-Token verification. This example makes use of the XWS-Security framework to implement all WSS interop scenarios.
The interop sample application demonstrates a complete implementation of the seven WSS interop scenarios, as defined in the WSS Interop Scenarios document, which can be found at the following URL:
The application prints out both the client and server request and response SOAP messages. The output from the server may be viewed in the appropriate container's log file. The output from the client may be viewed using
stdout.In this example, server-side code is found in the
/interop/server/src/interop/directory. Client-side code is found in the/interop/client/src/interop/directory. Theasant(or Ant)targets build objects under the/build/server/and/build/client/directories. You can view other usefulasant(or Ant)targets by enteringasant(or ant) at the command line in the/interop/directory.This example uses keystores and truststores which are included in the
/xws-security/etc/directory. These are the only keystore and truststore files that will work with this example.For this example, the keystore and truststore required on the server side have been packaged into the WAR (Web ARchive) file itself. It is therefore sufficient to ensure that the client sets the correct locations to the
client-keystore.jksandclient-truststore.jksin thebuild.propertiesfile in order to run this sample.Web Services Security Scenarios
This section discusses the
interopsample application, which implements the seven existing WSS interop scenarios. Using these scenarios, developers will be able to send and receive messages compliant with the WSS Soap Message Security specification. Developers can use the framework to implement applications that have security requirements similar to those defined in the WSS interop scenarios.Table 3-4 lists each of the WSS Interop Scenarios and provides a brief description of the security configuration used for each.
How is XWS-Security Implemented in the Interop Sample Application?
The
SecurityConfiguratorAPI adds a handler to the front of a handler chain on the server side. The handler contains an initially empty list of filters. Each of these filters can perform a specific, security-related, unit of work on a message. TheSecurityConfiguratorallows filters to be added to this list in order to provide security services. Theinteropsamples all use this mechanism and, taken together, illustrate the full breadth of available functionality.The following example code is from the
Scenario4Client.javafile from theinteropexample:private static void scenario4(PingService service) throws Exception { try { SecurityConfigurator secCfg = new SecurityConfigurator(service, portName); SecurityEnvironment secDomain = initializeSecurityEnvironment(); secCfg.setSecurityEnvironment(secDomain); X509Certificate certificate = (X509Certificate) ((DefaultSecurityEnvironmentImpl) secDomain).getKeyStore().getCertificate(aliases[0]); secCfg.addRequestTimestamp(); secCfg.addSignRequest("//SOAP-ENV:Body",certificate, SecurityConfigurator.DIRECT_REFERENCE_STRATEGY); secCfg.addFilterForOutgoingMessages(new ExportReferenceListFilter()); secCfg.addFilterForOutgoingMessages(new EncryptElementFilter("//SOAP-ENV:Body",true, new KeyNameStrategy())); if (debug) { // see what the request and response look like secCfg.addDumpRequest().addDumpResponse(); } /* Add filters for Incoming messages */ secCfg.addFilterForIncomingMessages(new ProcessSecurityHeaderFilter()); } catch (Exception e) { e.printStackTrace(); throw e; } }This mechanism does not handle the
mustUnderstandportion of SOAP processing properly for encrypted headers. Therefore, because thewscompileutility with the-securityoption does handle this portion of SOAP processing properly,wscompileis the preferred method for handling security in this release. Using thewscompileutility is the method described in Understanding and Running the Simple Sample Application.Running the WSS Interop Scenario Sample Applications
Before the sample application will run correctly, you must have completed the tasks defined in the following sections of this addendum:
To run the
interopsample application, follow these steps:
- Start the selected container and make sure the server is running. To start the Application Server,
- If you are using a remote proxy server, add the proxy information to the
run-client targets in thebuild.xmlfile. There are sevenrun-clienttargets, one for each of the interop scenarios, and each of these targets must have the following lines added if you are using a proxy server.To modify the
run-clienttargets,
- Open the file
/interop/build.xmlin a text editor.- Locate the run-client<
x> target definitions, which follow this format:<target name="run-client1" ....>
<target name="run-client2" ....>
...
<target name="run-client7" ....>- Add the following lines to specify the proxy information to each of the seven
run-clienttargets. Thehttp.proxyHostandhttp.proxyHostproperties should have been defined as specified in Setting Build Properties.<sysproperty key="http.proxyHost"
value="${http.proxyHost}"/>
<sysproperty key="http.proxyPort"
value="${http.proxyPort}"/>- Build and run the application from a terminal window or command prompt, for example, on the Application Server,
asantrun-allor on Tomcat or the Web Server,
antrun-all- Build and run an individual interop scenario using the following command, where
<x>is replaced by the number of the scenario to be run:
asantrun-client<x>or on a remote proxy server,asantinterop-client<x>For example, to run WSS Interop scenario 1, the command would be:
asantrun-client1
Note: When the server is a remote server and the application is already deployed on the remote server, the
interop-client<x>asant(or Ant)targets can be used instead of therun-Client<x>targets.
If the application runs successfully, you will see a message similar to the following:
[echo] Running the client program.... [java] ==== Request Start ==== ... [java] ==== Request End ==== [java] ==== Response Start ==== ... [java] ==== Response End ==== [java] Hello to Duke!You can view similar messages in the server logs:
|
Download
FAQ History |
|
API
Search Feedback |
All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.