|
Download
FAQ History |
|
API
Search Feedback |
Understanding and Running the Simple Sample Application
This example is a fully-developed sample application that demonstrates various configurations that can be used to exercise XWS-Security framework code. By modifying one property in the
build.propertiesfile for the example, you can change the type of security that is being used for the client and/or the server. The types of security configurations possible in this example include XML Digital Signature, XML Encryption, and UserName-Token verification. This example allows and demonstrates combinations of these basic security mechanisms through the specification of the appropriate security configuration files.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
/simple/server/src/simple/directory. Client-side code is found in the/simple/client/src/simple/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 (orant)at the command line in the/simple/directory.This example uses keystores and truststores which are included in the
/xws-security/etc/directory. For more information on using keystore and truststore files, read thekeytooldocumentation at the following URL:Plugging in Security Configurations
This example makes it simple to plug in different client and server-side configurations describing security settings. This example has support for digital signatures, XML encryption/decryption, and username/token verification. This example allows and demonstrates combinations of these basic security mechanisms through configuration files. See Sample Security Configuration File Options, for further description of the security configuration options defined for the
simplesample application.To specify which security configuration option to use when the sample application is run (see Running the Simple Sample Application), follow these steps:
- Open the
build.propertiesfile for the example. This file is located at<JWSDP_HOME>/xws-security/samples/simple/build.properties.- To set the security configuration that you want to run for the client, locate the
client.security.configproperty, and enter one of the client security configuration options contained in the<JWSDP_HOME>/xws-security/samples/simple/config/directory. The client configuration options are listed in Sample Security Configuration File Options. This section also lists which client and server configurations work together. For example, if you want to use XML Encryption for the client, you would set this property as follows:
# Client Security Config. file
client.security.config=config/encrypt-client.xml- To set the security configuration that you want to run for the server, locate the
server.security.configproperty, and enter one of the server security configuration options listed in the<JWSDP_HOME>/xws-security/samples/simple/config/directory. The server configuration options, and which server options are valid for a given client configuration, are listed in Sample Security Configuration File Options. For example, if you want to use XML Encryption for the server, you would set this property as follows:
# Server Security Config. file
server.security.config=config/encrypt-server.xml- Save and exit the
build.propertiesfile.- Run the sample application as described in Running the Simple Sample Application.
Sample Security Configuration File Options
The configuration files available for this example are located in the
/xws-security/samples/simple/config/directory. The configuration pairs available under this sample include configurations for both the client and server side. Any combination of the*-client.xmland*-server.xmlconfigurations can be used. Some possible combinations are discussed in more detail in the referenced sections.
dump-client.xml,dump-server.xmlencrypt-client.xml,encrypt-server.xmlsign-client.xml,sign-server.xmlsign-encrypt-client.xml,sign-encrypt-server.xmlencrypt-sign-client.xml,encrypt-sign-server.xmluser-pass-authenticate-client.xml, dump-server.xmlencrypted-user-pass-also-client.xml, dump-server.xmlsign-ticket-also-client.xml, dump-server.xmlDumping the Request and/or the Response
The security configuration pair
dump-client.xmlanddump-server.xmlhave no security operations. These options enable the following tasks:The container's server logs also contain the dumps of the server request and response. See Running the Simple Sample Application for more information on viewing the server logs.
Encrypting the Request and/or the Response
The security configuration pair
encrypt-client.xmlandencrypt-server.xmlenable the following tasks:The
encrypt-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" useTimestamps="true" dumpMessages="true"><xwss:EncryptreceiverCertificateAlias="s1as"/> </xwss:SecurityConfiguration>Signing and Verifying the Signature
The security configuration pair
sign-client.xmlandsign-server.xmlenable the following tasks:The
sign-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" dumpMessages="true"><xwss:SignsenderCertificateAlias="xws-security-client"/> </xwss:SecurityConfiguration>Signing then Encrypting the Request, Decrypting then Verifying the Signature
The security configuration pair
sign-encrypt-client.xmlandsign-encrypt-server.xmlenable the following tasks:The
sign-encrypt-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" useTimestamps="true" dumpMessages="true"><xwss:Sign/><xwss:EncryptkeyReferenceType="Identifier" receiverCertificateAlias="s1as"/> </xwss:SecurityConfiguration>Encrypting then Signing the Request, Verifying then Decrypting the Signature
The security configuration pair
encrypt-sign-client.xmlandencrypt-sign-server.xmlenable the following tasks:The
encrypt-sign-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" useTimestamps="true" dumpMessages="true"><xwss:EncryptkeyReferenceType="IssuerSerialNumber" receiverCertificateAlias="s1as"/><xwss:Sign/></xwss:SecurityConfiguration>Adding a UserName Password Token
The security configuration pair
user-pass-authenticate-client.xmlanddump-server.xmlenable the following tasks:The username-password database must be set up before this security configuration pair will run properly. Refer to Setting Up the Application Server For the Examples for instructions on setting up this database.
The
user-pass-authenticate-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" dumpMessages="true"><xwss:Authenticate> <xwss:UsernameAndPasswordname="Ron" password="noR" /> </xwss:Authenticate> </xwss:SecurityConfiguration>Adding a UserName Password Token, then Encrypting the UserName Token
The security configuration pair
encrypted-user-pass-also-client.xmlanddump-server.xmlenable the following tasks:The user name-password database must be set up before this security configuration pair will run properly. Refer to Setting Up the Application Server For the Examples for instructions on setting up this database.
The
encrypted-user-pass-also-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" dumpMessages="true"> <xwss:Authenticate> <xwss:UsernameAndPassword name="Ron" password="noR"> <xwss:Encrypt keyReferenceType="Identifier" receiverCertificateAlias="s1as"/> </xwss:UsernameAndPassword> </xwss:Authenticate> </xwss:SecurityConfiguration>Signing the Ticket Element
The security configuration pair
sign-ticket-also-client.xmlanddump-server.xmlenable the following tasks:The
sign-ticket-also-client.xmlfile looks like this:<xwss:SecurityConfiguration xmlns:xwss= "http://com.sun.xml.wss.configuration" useTimestamps="true" dumpMessages="true"> <xwss:Sign target="{http://xmlsoap.org/Ping}ticket" keyReferenceType="Identifier"/> <xwss:Sign/> </xwss:SecurityConfiguration>Running the Simple Sample Application
Before the sample application will run correctly, you must have completed the tasks defined in the following sections of this addendum:
To run the
simplesample application, follow these steps:
- Start the selected container and make sure the server is running. To start the Application Server,
- Modify the
build.propertiesfile to set up the security configuration that you want to run for the client and/or server. See Sample Security Configuration File Options for more information on the security configurations options that are already defined for the sample application.- Build and run the application from a terminal window or command prompt.
Note: To run the sample against a remote server containing the deployed endpoint, use the
run-remote-sampletarget in place of therun-sampletarget. In this situation, make sure that theendpoint.host,endpoint.port,http.proxyHost,http.proxyPort, andservice.urlproperties are set correctly in thebuild.propertiesfile (as discussed in Setting Build Properties) before running the sample.
If the application runs successfully, you will see a message similar to the following:
[echo] Running the client program.... [java] ==== Sending Message Start ==== ... [java] ==== Sending Message End ==== [java] ==== Received Message Start ==== ... [java] ==== Received Message 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.