WebLogic Server 6.1 Code Examples, BEA Systems, Inc.

Package examples.security.sslclient

The SSLClient example is a short example of how to use the SSL library of WebLogic to make out-going SSL connections and the SSLSocketClient example demonstrates using the SSLSocket and the SSLSocketFactory directly to make a new SSL connection.

See:
          Description

Class Summary
NulledHostnameVerifier HostnameVerifier provides a callback mechanism so that implementers of this interface can supply a policy for handling the case where the host that's being connected to and the server name from the certificate SubjectDN must match.
NulledTrustManager Given the partial or complete certificate chain provided by the peer, build a certificate path to a trusted root and return true if it can be validated and is trusted for client SSL authentication.
SSLClient SSLClient is a short example of how to use the SSL library of WebLogic to make outgoing SSL connections.
SSLClientServlet SSLClientServlet is a simple servlet wrapper of examples.security.sslclient.SSLClient
SSLSocketClient SSLSocketClient uses the SSLSocket and SSLSocketFactory directly to use a new SSL connection.
 

Package examples.security.sslclient Description

The SSLClient example is a short example of how to use the SSL library of WebLogic to make out-going SSL connections and the SSLSocketClient example demonstrates using the SSLSocket and the SSLSocketFactory directly to make a new SSL connection.

The SSLCLient example demonstrates how to use the SSL library of WebLogic to make outgoing SSL connections from a stand-alone application as well as from within the WebLogic Server (in a servlet). This example demonstrates:

The SSLSocketClient example demonstrates:

 
Additional Resources for examples.security.sslclient.SSLClient and examples.security.sslclient.SSLSocketClient
build.xml The Java Ant build script assembles and deploys the SSLClient and the SSLSocketClient examples.
jsseWLS.bat A batch file used to run the sslclient example on the Windows 2000 platform using the JSSE API to connect to WebLogic Server. This file includes parameters that specify:
  • The JSSE API used to connect to the server.
  • The server to which to connect.
  • Either a non-secure port or secure port on the server.
  • A target object to which to connect (SnoopServlet).
jsseWLS.sh A batch file used to run the sslclient example on the UNIX platform using the JSSE API to connect to WebLogic Server. For parameters description, see the parameters listed for jsseWLS.bat.
wlsWLS.bat A batch file used to run the sslclient example on the Windows 2000 platform using the weblogic.net.http.HttpsURLConnection class to make a connection to WebLogic Server. This file includes parameters that specify:
  • The WebLogic Server API used to connect to the server.
  • The server to which to connect.
  • Either a non-secure port or secure port on the server.
  • A target object to which to connect (SnoopServlet).
wlsWLS.sh A batch file used to run the sslclient example on the UNIX platform using the weblogic.net.http.HttpsURLConnection class to make a connection to WebLogic Server. For parameters description, see the parameters listed for wlsWLS.bat.

 

SSLCLient example

The following sections describe how to build and run the SSLClient example.

  1. Prerequisites
  2. Build the Example
  3. Run the Example
  4. Check the Output

 

Prerequisites

Before you run this example, you need:

 

Build the SSLClient Example

To build the example, follow these steps:
  1. Set up your development shell as described in Setting up your environment.

  2. Compile the example by executing an ant build script.

    To run the JSSE versions of the SSLClient example, uncomment Java code in sslclient.java and rebuild the file. Information about which lines to uncomment is included in the Java source files for the SSLClient.

    An ant build script is available in the samples/examples/security/sslclient directory. Enter the following command to execute the build script:

    $ ant

    The ant command builds and deploys the files in the sslclient example to the WLS_HOME/config/examplesWebApp/serverclasses directory.

  3. Deploy the SnoopServlet.jsp. The SnoopServlet.jsp is located in the WLS_HOME/samples/examples/jsp directory. You must deploy this JSP by copying it to the WLS_HOME/config/examples/applications/examplesWebApp directory or by deploying the file through the Administration Console.

 

Run the Example

To run the SSLClient with WebLogic Server using the WebLogic Server API, execute the following command

$ wlsWLS.bat

To run the SSLClient with WebLogic Server using the JSSE API, execute the following command

$ jsseWLS.bat

 

Check the Output

The SSLClient constructs a URL with which to make the connection. First the client will try to connect to the non-secure port (i.e., 7001 on WebLogic Server) on the server and then the client will try to connect using a secure port (i.e., 7002 on WebLogic Server). The response to the connection is displayed on the screen.

The SSLClient displays the following data on the screen or in the browser:

 

SSLSocketCLient example

The following sections describe how to build and run the SSLSocketClient example.

  1. Prerequisites
  2. Build the Example
  3. Run the Example
  4. Check the Output

 

Prerequisites

Before you run this example, you need:

 

Build the SSLSocketClient Example

To build the example, follow these steps:
  1. Set up your development shell as described in Setting up your environment.

  2. Compile the example by executing an ant build script.

    An ant build script is available in the samples/examples/security/sslclient directory. Enter the following command to execute the build script:

    $ ant

    The ant command builds and deploys the files in the sslsocketclient example to the WLS_HOME/config/examplesWebApp/serverclasses directory.

 

Run the Example

To run the SSLSocketClient with WebLogic Server:

  1. Go to the config/mydomain directory and copy the following three files:

    to the samples/examples/security/sslclient directory.

  2. Enter:

    $ java examples.security.sslclient.SSLSocketClient hostname SSLPort optionalHostnameVerifierClassName

    where:

    hostname
    localhost

    SSL Port
    Port that is listening for SSL connections (for example, 7002)

    optionalHostnameVerifierClassName
    Name of your Hostname Verifier Class (for example, examples.security.sslclient.NulledHostnameVerifier)

 

Check the Output

The SSLSocketClient constructs a new SSLSocket to the hostname listed and will report back whether the connection was successful or not.

The SSLClient displays the following data on the screen or in the browser:

 

See Also

Read more about:


Documentation is available at
http://e-docs.bea.com/wls/docs61

Copyright © 2001 BEA Systems, Inc. All Rights Reserved.