Source code browse

Revision: 1181 (of 1181)

trigger site update
» Project Revision History

» Checkout URL

svn / branches / xwss20 / xwss-ri / wspack-samples / dynamic-response

FilenameAuthorRevisionModifiedLog Entry
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
kumarjayanti 6 over 9 years ago Adding existing code base
Copyright 2004 Sun Microsystems, Inc. All rights reserved.
SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.

Example: dynamic-response

This sample demonstrates using the certificate that arrived in a signed
request to encrypt the response back to the requestor.

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 is sent to stdout or to whichever 
stream is used by the configured log Handler. Messages are logged at the INFO level.

In this example, server-side code is found in the /dynamic-response/server/src/sample/
directory.  Client-side code is found in the /dynamic-response/client/src/sample/
directory.  The ASant or Ant targets build objects under the /build/server/ 
and /build/client/ directories.  You can view other useful ASant or Ant 
targets by entering "ant" or "asant" at the command line in the /dynamic-response/ 

This example can be deployed onto any of the following containers:
1. Sun Java System Application Server PE 8.X (SJSAS 8.X)
2. SJSWS 6.1 (Sun Java System WebServer 6.1)
3. The Apache Tomcat WebServer

Configuring a JCE Provider

If you are using JDK 1.5 (Tiger RC) then there is no need to configure a JCE provider
and this section can be skipped.

A Java Cryptography Extension (JCE) provider for J2SE 1.4 must be available
for these sample applications to run.  You must download and install this
JCE provider from one of the sources listed below because the JCE provider included
with JDK 1.4.x does not support RSA encryption.

To add a JCE provider statically as part of your JDK environment:

        1. Download a JCE provider jar. You will find a link to
        some JCE providers at this URL:


        2. Follow the instructions for installing the JAR file on its
        Web site.
        3. Copy the provider jar to the following directory:
        (where $JAVA_HOME is the location of your Java 2 Standard 
        Edition installation)
        4. Edit the $JAVA_HOME/jre/lib/security/ 
        properties file in any text editor.  Add the JCE provider you've 
        just downloaded to this file.  

        The file contains detailed instructions for adding 
        this provider. Basically, you need to add a line of the following 
        format in the location with similar properties: 
                security.provider.<n>=<provider class name>

        In the above example,  <n> is the order of preference to be used 
        by the application server.  Set the valude for the JCE provider 
        you've just added to 2.  Keep the Sun security provider at the 
        highest preference, with a value of 1.  

        Adjust the levels of the other security providers accordingly.

Configuring the Sample

Follow these steps to configure the example prior to running it.

1.  Make sure that you have installed the Java 2 Platform, Standard 
Edition version 1.5 or 1.4.2 (if you have not done this, you can download
it from  Point to the 
location of this installation when setting up the environment variable
for JAVA_HOME and for the javahome property in the

2. In the directory xws-security/samples/dynamic-response, copy the
file to

3. Many of the properties in this file need to be configured 
specifically for your system.  Find the following properties and
enter the correct value for your system.  

# java and jwsdp

#container homes (uncomment the appropriate container home property)
#Note: only one of the 3 below should be uncommented at any point of time

# Replace username and password values with the user name and
# password for a user assigned to the role of admin for
# the container instance being used for this sample

# the host and port for the server endpoint, for the default
# SJSAS installation, these values will be correct

#place where standalone JWSDP is installed
jwsdp.home=<location of standalone jwsdp>

#VS.DIR : virtual server name needed for SJSWS only

# proxy server settings in case of remote endpoints

4. If the container being used is SJSAS, add the following pemissions into the <SJSAS.home>/domains/domain1/config/server.policy file of Application server.

grant codeBase "file:${com.sun.aas.instanceRoot}/applications/j2ee-modules/dynamicresponse/WEB-INF/-" {
      	permission "modifyPrincipals";
	permission "modifyPrivateCredentials";
	permission "* * \"*\"","read";
	permission "getSubject";

  If the container being used is SJSWS, then add the following permissions into the 
  <SJSWS.home>/<Virtual-Server-Dir>/config/server.policy file.

grant codeBase "file:${com.sun.web.instanceRoot}/webapps/<Virtual-Server-Dir>/dynamicresponse/WEB-INF/-" {
      	permission "modifyPrincipals";
	permission "modifyPrivateCredentials";
	permission "* * \"*\"","read";
	permission "getSubject";

Where <Virtual-Server-Dir> denotes the name of the Virtual Server which was specified during installation.

Running the sample:

Follow these instructions to run the example after completing the 
steps in the Configuring section.

1. Start the selected container and make sure the server is running.
To start the Application Server, 

  From a command prompt: asadmin start-domain domain1
  From a Windows system: Start->Programs->Sun Microsystems->
        J2EE 1.4 SDK->Start Default Server
2. Modify the as described above

3. Build and run the client application as follows:
   % asant run-sample (on SJSAS)
   % ant run-sample (on SJSWS or Tomcat)
Note: To run the sample against a remote server containing the deployed
endpoint, make use of the run-remote-sample ant target instead of run-sample.
Make sure that the properties, endpoint.port and service.url are
set correctly and also ensure that the properties http.proxyHost and
http.proxyPort are set correctly before running the sample remotely.

You should see a message similar to the following for a successful run:
     [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 also see similar messages in the server logs at 
    ${sjsas.home}/domains/<domain-name>/logs/server.log (for SJSAS)
    ${tomcat.home}/logs/launcher.server.log (for Tomcat)