WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

Package examples.security.jaas

This package demonstrates how to access a WebLogic Server resource (in this case, an RMI object) through the use of JAAS authentication.

See:
          Description

Interface Summary
Frobable A remote interface that illustrates access control on an RMI object.
 

Class Summary
FrobImpl Illustrates how to use an ACL to protect the methods of an RMI object's.
MyCallbackHandler Implementation of the CallbackHandler Interface
SampleAction  
SampleClient Sample client for JAAS user authentication
SampleConfig Sample configuration class for JAAS user authentication.
SampleLoginModule Sample login module that performs password authentication.
 

Package examples.security.jaas Description

This package demonstrates how to access a WebLogic Server resource (in this case, an RMI object) through the use of JAAS authentication. JAAS authentication replaces a JNDI Environment object as the way to pass authentication data from a client to WebLogic Server. The user is prompted for a username and password which is then passed through the JAAS authenticated interface. If authentication is successful the client will attempt to execute the RMI object method using the JAAS authorization doAs interface.

The JAAS code example includes the SampleClient.java class which connects to WebLogic Server using a username and password defined for joeuser User in the Administration Console. Perform the following steps in order to build, compile and run the example:

  1. Build the example
  2. Configure the weblogic server
  3. Run the example

Build the Example

  1. Set up your development shell as described in Setting up your environment.

  2. Use the following command to compile the Frobable interface and implementation class in the samples/examples/security/jaas directory:
     javac -d  %SERVER_CLASSES% Frobable.java FrobImpl.java
  3. Use the following command to run the WebLogic RMI compiler to generate a client stub and skeleton for the FrobImpl interface:
     java weblogic.rmic -d %SERVER_CLASSES% examples.security.acl.FrobImpl
  4. Use the following commands to compile the example classes:
     javac -d %CLIENT_CLASSES% SampleAction.java
     javac -d %CLIENT_CLASSES% SampleClient.java
     javac -d %CLIENT_CLASSES% SampleConfig.java
     javac -d %CLIENT_CLASSES% SampleLoginModule.java

Configure the Server

  1. Bring up the Administration Console in a browser.

  2. Register the FrobImpl instance as a RMI startup class:
    1. Click to expand the Deployments node in the left pane.
    2. Click to expand the Startup & Shutdown node in the left pane.
    3. Select the frob node.
    4. Deploy the frob startup class on the examplesServer.

  3. Define joeuser as a User in the filerealm security realm:
    1. Click to expand the Security node in the left pane.
    2. Select the Users node.
    3. Add the user joeuser with the password joepass.

  4. Create an ACL called aclexample that grants the permission frob for User joeuser:
    1. Select the Access Control Lists node in the left pane.
    2. Create a new ACL with the name acl.frob.aclexample.
    3. In the Permission field, enter frob.
    4. In the Grant to User field, enter joeuser.

Run the Example

  1. Restart the Server.

  2. Use the following command to run SampleClient:
      java examples.security.jaas.SampleClient url

    url specifies the T3 or HTTP protocol and the default port on which WebLogic Server listens for communications.

    For example:

      java examples.security.jaas.SampleClient t3://localhost:7001

There's more...

Read more using the JAAS SPI to authenticate clients in Programming WebLogic Security .


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

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