WebSphere Application Server Version 6.1 Feature Pack for Web Services
             Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows, z/OS

             Personalize the table of contents and search results
             New or updated topic for this feature pack

Configuring the generator security tokens using the WSS API

You can secure the SOAP messages, without using policy sets, by using the Web Services Security APIs. To configure the token on the generator side, use the Web Services Security APIs (WSS API). The generator security tokens are part of the com.ibm.websphere.wssecurity.wssapi.token interface package.

Before you begin

The pluggable token framework in WebSphere Application Server has been redesigned so that the same framework from the WSS API can be reused. The same implementation of creating and validating security token can be used both for the Web Services Security runtime and for the WSS API application code. The redesigned framework also simplifies the SPI programming model and will make it easier to add security token types.

You can use the WSS API or you can configure the tokens by using the administrative console. To configure tokens, you must complete the following token tasks:

About this task

The JAAS CallbackHandler and JAAS LoginModule are responsible for creating the security token on the generator side.

On the generator side, the token is created by using the JAAS LoginModule and by using JAAS CallbackHandler to pass authentication data. Then, the JAAS LoginModule creates the securityToken object, such as the UsernameToken, and passes it to the Web Service Security runtime.

On the consumer side, the XML format is passed to the JAAS LoginModule for validation or authentication. then the JAAS CallbackHandler is used to pass authentication data from the Web Service Security runtime to the LoginModule. After the token is authenticated, a security token object is created, and the token is passed it to the Web Service Security runtime.

When using the WSS API for generator token creation, certain default behaviors occur. The simplest way to use the WSS API is to use the default behavior (see the example code). The WSS API provide default values for the token type, the token value, and the JAAS confirmation name. The default token behaviors include:

Generator token decisions Default behavior
Which token type to use

The token type specifies which type of token to use for message integrity, message confidentiality, or message authenticity.

WebSphere Application Server provides the following pre-configured generator token types for message integrity and message confidentiality:
  • Derived key token
  • X509 tokens
You can also create custom token types, as needed.

WebSphere Application Server also provides the following pre-configured generator token types for the message authenticity:

  • Username token
  • LTPA tokens
  • X509 tokens

You can also create custom token types, as needed.

What JAAS login configuration name to specify

The JAAS login configuration name specifies which JAAS login configuration name to use.

Which configuration type to use The JAAS login module specifies the configuration type. Only the pre-configured generator configuration types can be used for generator token types.

The SecurityToken class (com.ibm.websphere.wssecurity.wssapi.token.SecurityToken) is the generic token class and represents the security token that has methods to get the identity, the XML format, and the cryptographic keys. Using the SecurityToken class, you can apply both the signature and encryption to the SOAP message. However, to apply both, you must have two SecurityToken objects, one for the signature and one for encryption, respectively.

The following tokens types are subclasses of the generic security token class:

Table 1. Subclasses of the SecurityToken
Token type JAAS login configuration name
Username token system.wss.generate.unt
Security context token system.wss.generate.sct
Derived key token system.wss.generate.dkt

The following tokens types are subclasses of the binary security token class:

Table 2. Subclasses of the BinarySecurityToken
Token type JAAS login configuration name
LTPA token system.wss.generate.ltpa
LTPA propagation token system.wss.generate.ltpaProp
X.509 token system.wss.generate.x509
X.509 PKI Path token system.wss.generate.pkiPath
X.509 PKCS7 token system.wss.generate.pkcs7

Notes:

Procedure

  1. To configure the securityToken package, com.ibm.websphere.wssecurity.wssapi.token, first ensure that the WebSphere Application Server Feature Pack is installed.
  2. Use the Web Services Security token generator process to configure the tokens. For each token type, the process is similar to the following process that demonstrates the UsernameToken token generator process:
    1. Uses WSSFactory.getInstance() to get the WSS API implementation instance.
    2. Creates the WSSGenerationContext instance from the WSSFactory instance.
    3. Creates a JAAS CallbackHandler. The authentication data, such as the user name and password are specified as part of the CallbackHandler. For example, the following code specifies Chris as the user name and sirhC as the password: UNTGenerationCallbackHandler("Chris", "sirhC");
    4. Calls any JAAS CallbackHandler parameters and reviews the token class information for which parameters are required or optional. For example, for the UsernameToken, the following parameters can be configured also:
      Nonce
      Indicates whether a nonce is included in the user name token for the token generator. Nonce is a unique, cryptographic number that is embedded in a message to help stop repeat, unauthorized attacks of user name tokens. The nonce value is valid only when the generated token type is a UsernameToken and only when it applies to the request generator binding.
      Created timestamp
      Indicates whether to insert a time stamp into the UsernameToken. The timestamp value is valid only when the generated token type is a UsernameToken and only when it applies to the request generator binding.
    5. Creates the SecurityToken from WSSFactory.

      By default, the UsernameToken API specifies the ValueType as: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken"

      By default, the UsernameToken API provides the QName of this class and specifies the NamespaceURI as http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd and also specifies the LocalPart as UsernameToken.

    6. Optional: Specifies the JAAS login module configuration name. On the generator side, the configuration type is always generate (for example, system.wss.generate.unt).
    7. Adds the SecurityToken to the WSSGenerationContext.
    8. Calls WSSGenerationContext.process() and generates the WS-Security header.

Results

If there is an error condition, a WSSException is provided. If successful, the WSSGenerationContext process() is called, and the security token for the generator binding is attached.

Example

The following example code shows how the WSS API process creates a Username security token, attaches the Username token to the SOAP message, and configures the Username token in the generator binding.

// get the message context
   Object msgcontext = getMessageContext();

// generate WSSFactory instance
   WSSFactory factory = WSSFactory.getInstance();

// generate WSSGenerationContext instance
   WSSGenerationContext gencont = factory.newWSSGenerationContext();

// generate callback handler
   UNTGenerateCallbackHandler untCallbackHandler = 
	new UNTGenerateCallbackHandler("Chris", "sirhC");

// generate the username token 
   SecurityToken unt = factory.newSecurityToken(UsernameToken.class, 
                                                untCallbackHandler);

// add the SecurityToken to the WSSGenerationContext
   gencont.add(unt);

// generate the WS-Security header
gencont.process(msgcontext);

What to do next

For each token type, configure the token using the WSS APIs or using the administrative console. Next, specify the similar consumer tokens if you have not done so.

If both the generator and consumer tokens are configured, continue securing SOAP messages either by signing the SOAP message or by encrypting the message, as needed. You can use either the WSS APIs or the administrative console to secure the SOAP messages.




In this information ...


IBM Redbooks, demos, education, and more


Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

IBM Suggests
Task topic    

Terms of Use | Feedback

Last updated: Nov 25, 2008 2:35:59 AM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/twbs_confwssgeneratortoken.html