Skip Headers
Oracle® Security Developer Tools Reference
10g (10.1.4.0.1)

Part Number B28165-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

12 Oracle XKMS

XKMS (XML Key Management Specification) is a W3C specification for public key management. It provides a convenient way to handle public key infrastructures by enabling developers to write XML transactions for digital signature processing.

This chapter contains these topics:

12.1 Oracle XKMS Features and Benefits

Oracle XKMS is a pure Java solution which consists of a toolkit for locating keys and verifying user identities across businesses and applications. It supports the secure, trusted messaging required for web services, and provides a way to sidestep some of the costs and complexity associated with PKI.

Oracle XKMS provides the following features:

12.1.1 Oracle XKMS Packages

The Oracle XKMS library contains the following packages:

Table 12-1 Packages in the Oracle XKMS Library

Package Description

oracle.security.xmlsec.xkms

Contains the main XKMS message elements

oracle.security.xmlsec.xkms.xkiss

Contains the classes for the Key Information Service Specification

oracle.security.xmlsec.xkms.xkrss

Contains the classes for the Key Registration Service Specification

oracle.security.xmlsec.xkms.util

Contains constants and utility classes


12.2 Setting Up Your Oracle XKMS Environment

The Oracle Security Developer Tools are installed with Oracle Application Server in ORACLE_HOME. This section explains how to set up your environment for Oracle XKMS. It contains these topics:

12.2.1 System Requirements for Oracle XKMS

In order to use Oracle XKMS, your system must have the following components installed:

  • The Java Development Kit (JDK) version 1.2.2 or higher

  • A JAXP-compatible XML parser and XSLT processor

  • the Oracle XML Security toolkit

12.2.2 Setting the CLASSPATH Environment Variable

Your CLASSPATH environment variable must contain the full path and file names to the required jar and class files. Make sure that the following files are included in your CLASSPATH:

  • osdt_core.jar

  • osdt_cert.jar

  • osdt_xmlsec.jar

  • jaxen.jar, which is included in the $ORACLE_HOME/jlib directory of the security tools distribution. Oracle XML Security relies on the Jaxen XPath engine for XPath processing.

  • The appropriate XML parser and XSLT processor implementations, unless you have installed them in your JRE's /lib/ext or /lib/endorsed directory.


Note:

The Jaxen library included in the Oracle XML Security distribution is a modified version of the Jaxen 1.0 FCS release. If you also have an earlier Jaxen release in your CLASSPATH, you must ensure that the version from this distribution appears first.

12.2.2.1 Setting the CLASSPATH on Windows

To set your CLASSPATH on Windows:

  1. In your Windows Control Panel, select System.

  2. In the System Properties dialog, select the Advanced tab.

  3. Click Environment Variables.

  4. In the User Variables section, click New to add a CLASSPATH environment variable for your user profile. If a CLASSPATH environment variable already exists, select it and click Edit.

  5. Add the full path and file names for all of the required jar and class files to the CLASSPATH.

    For example, your CLASSPATH might look like this:

    C:\ORACLE_HOME\jlib\osdt_core.jar;
    C:\ORACLE_HOME\jlib\osdt_cert.jar
    C:\ORACLE_HOME\jlib\osdt_xmlsec.jar
    
    
  6. Click OK.

12.2.2.2 Setting the CLASSPATH on UNIX

On UNIX, set your CLASSPATH environment variable to include the full path and file name of all of the required jar and class files. For example:

setenv CLASSPATH $CLASSPATH:$ORACLE_HOME/jlib/osdt_core.jar:\
C:\ORACLE_HOME\jlib\osdt_cert.jar
C:\ORACLE_HOME\jlib\osdt_xmlsec.jar

12.3 Core Classes and Interfaces

This section provides information and code samples for using the key classes and interfaces of Oracle XKMS. The core classes are:

12.3.1 oracle.security.xmlsec.xkms.xkiss.LocateRequest

This class represents the XKMS LocateRequest element.

Example 12-1 shows how to create an instance of LocateRequest:

Example 12-1 Creating an Instance of LocateRequest

// Parse the XML document containing the dsig:Signature.
Document sigDoc = //Instance of org.w3c.dom.Document;
 
//Create Query Key Binding
QueryKeyBinding queryKeyBinding = new QueryKeyBinding(sigDoc);
queryKeyBinding.setTimeInstant(new Date());
 
// Create the xkms:LocateRequest.
LocateRequest loc = new LocateRequest(sigDoc, queryKeyBinding);

Client requests of type LocateRequest must include an xkms:RespondWith attribute.

Example 12-2 shows how RespondWith can be added to a LocateRequest:

Example 12-2 Adding RespondWith to a LocateRequest

//Add xkms:RespondWith as X.509 Certificate.
loc.addRespondWith(XKMSURI.respondWith_X509Cert);

12.3.2 oracle.security.xmlsec.xkms.xkiss.LocateResult

This class represents the xkms:LocateResult element.

Example 12-3 shows how to create an instance of LocateResult:

Example 12-3 Creating an Instance of LocateResult

//Parse the XML document containin the dsig:Signature
Document sigDoc = //Instance of org.w3c.doc.Document;
 
// Create the xkms:LocateResult
LocateResult locRes = new LocateResult(sigDoc);
 
//Set ResultMajor to Success.
locRes.setResultCode(XKMSURI.result_major_success, null);

If the LocateRequest contained a RespondWith attribute of X509Certificate, use the following code to add an X509 Certificate to the LocateResult:

Example 12-4 Adding an X509 Certificate to LocateResult

//Creating a signature and adding X509 certificate to the KeyInfo element.
X509 userCert = //Instance of oracle.security.crypto.cert.X509
XSSignature Sig = XSSignature.newInstance(sigDoc, "MySignature");
XSKeyInfo xsInfo = sig.getKeyInfo();
X509Data xData = xsInfo.createX509Data(userCert);
 
//Add X509Data to the KeyInfo
xsInfo.addKeyInfoData(xData);
 
//Set Key Binding and add KeyInfo the the KeyBinding
UnverifiedKeyBinding keyBinding = new UnverifiedKeyBinding(sigDoc);
keyBinding.setKeyInfo(xsInfo);
 
//Add Key Binding to LocateResult
locRes.addKeyBinding(keyBinding);

12.3.3 oracle.security.xmlsec.xkms.xkiss.ValidateRequest

This class represents the XKMS xkms:ValidateRequest element.

Example 12-5 shows how to create an instance of xkms:ValidateRequest:

Example 12-5 Creating an Instance of ValidateRequest

// Parse the XML document containing the dsig:Signature.
Document sigDoc = //Instance of org.w3c.dom.Document;
 
//Create Query Key Binding
QueryKeyBinding queryKeyBinding = new QueryKeyBinding(sigDoc);
queryKeyBinding.setTimeInstant(new Date());
 
// Create the xkms:ValidateRequest.
ValidateRequest validateReq = new ValidateRequest(sigDoc, queryKeyBinding);

Requests of type ValidateRequest must include an xkms:RespondWith attribute. Example 12-6 shows how to add RespondWith to a ValidateRequest:

Example 12-6 Adding RespondWith to a ValidateRequest

//Add xkms:RespondWith as X.509 Certificate.
validateReq.addRespondWith(XKMSURI.respondWith_X509Cert);

12.3.4 oracle.security.xmlsec.xkms.xkiss.ValidateResult

This class represents the XKMS ValidateResult element.

Example 12-7 shows how to create an instance of ValidateResult:

Example 12-7 Creating an Instance of ValidateResult

//Parse the XML document containin the dsig:Signature
Document sigDoc = //Instance of org.w3c.doc.Document;
 
// Create the xkms:ValidateResult
ValidateResult valRes = new ValidateResult(sigDoc);
 
//Set ResultMajor to Success.
valRes.setResultCode(XKMSURI.result_major_success, null);

Use the following code to set a status in response to a ValidateRequest:

Example 12-8 Setting a Response Status for a ValidateRequest

//Create a status element and add reasons.
Status responseStatus = new Status(sigDoc);
responseStatus.addValidReason(XKMSURI.reasonCode_IssuerTrust);
responseStatus.addValidReason(XKMSURI.reasonCode_RevocationStatus);
responseStatus.addValidReason(XKMSURI.reasonCode_ValidityInterval);
responseStatus.addValidReason(XKMSURI.reasonCode_Signature);
 
//Create a xkms:KeyBinding to add status and X509Data
XSKeyInfo xsInfo = 
    // Instance of oracle.security.xmlsec.dsig.XSKeyInfo, 
    // which contains X509Data
KeyBinding keyBinding = new KeyBinding(sigDoc);
keyBinding.setStatus(responseStatus);
keyBinding.setKeyInfo(xsInfo);
 
// Add the key binding to the ValidateResult.
valRes.addKeyBinding(keyBinding);

12.3.5 oracle.security.xmlsec.xkms.xkrss.RecoverRequest

This class represents the XKMS RecoverRequest element.

Example 12-9 shows how to create an instance of RecoverRequest:

Example 12-9 Creating an Instance of RecoverRequest

// Parse the XML document containing the dsig:Signature.
Document sigDoc = //Instance of org.w3c.dom.Document;
 
// Create the xkms:RecoverRequest
RecoverRequest recReq = new RecoverRequest(sigDoc);
 
//Set RespondWith to PrivateKey, so that the RecoverResult 
contains the private key.
recReq.addRespondWith(XKMSURI.respondWith_PrivateKey);

A RecoverRequest must include the Authentication and RecoverKeyBinding elements. These can be added with the following code:

Example 12-10 Adding Authentication and RecoverKeyBinding to a RecoverRequest

//Create an instance of XSSignature.
XSSignature sig = 
    //Instance of oracle.security.xmlsec.dsig.XSSignature
 
//Create an instance of Authentication element.
Authentication auth = new Authentication(sigDoc);
 
//Set key binding authentication.
auth.setKeyBindingAuthentication(sig);
 
//Set Authentication for the RecoverRequest.
recReq.setAuthentication(auth);
 
//Add RecoverKeyBinding to RecoverRequest.
RecoverKeyBinding recKeyBind = new RecoverKeyBinding(sigDoc);
 
//Add Key Info on the key to be recovered.
XSKeyInfo xsInfo = 
    //Instance of oracle.security.xmlsec.dsig.XSKeyInfo
recKeyBind.setKeyInfo(xsInfo);
 
//Adding status, as known to the key holder, to the KeyBinding
Status keyStatus = new Status(sigDoc);
keyStatus.setStatusValue(XKMSURI.kbs_Indeterminate);
recKeyBind.setStatus(keyStatus);
 
//Adding RecoverKeyBinding to RecoverRequest.
recReq.setKeyBinding(recKeyBind);

12.3.6 oracle.security.xmlsec.xkms.xkrss.RecoverResult

This class represents the xkms:RecoverResult element.

Example 12-11 shows how to create an instance of RecoverResult:

Example 12-11 Creating an Instance of xkms:RecoverResult

// Parse the XML document containing the dsig:Signature.
Document sigDoc = //Instance of org.w3c.dom.Document;
 
// Create the xkms:RecoverResult
RecoverResult recResult = new RecoverResult(sigDoc);
 
//Set ResultMajor to Success.
recResult.setResultCode(XKMSURI.result_major_success, null);

The KeyBinding needs to be set for a RecoverResult. You can accomplish this with the following code:

Example 12-12 Creating a Key Binding for a RecoverResult

//Create a xkms:KeyBinding to add status and X509Data
XSKeyInfo xsInfo = 
    //Instance of oracle.security.xmlsec.dsig.XSKeyInfo, 
    //which contains X509Data
KeyBinding keyBinding = new KeyBinding(sigDoc);
keyBinding.setKeyInfo(xsInfo);
 
//Create a status element and add reasons.
//Status is set to Invalid because the service can decide
//to revoke the key binding in the case of recovery.

Status responseStatus = new Status(sigDoc);
responseStatus.addInvalidReason(XKMSURI.reasonCode_IssuerTrust);
responseStatus.addInvalidReason(XKMSURI.reasonCode_RevocationStatus);
responseStatus.addInvalidReason(XKMSURI.reasonCode_ValidityInterval);
responseStatus.addInvalidReason(XKMSURI.reasonCode_Signature);
responseStatus.setStatusValue(XKMSURI.kbs_Invalid);
 
keyBinding.setStatus(responseStatus);
 
//Set KeyBinding into RecoverResult
recResult.addKeyBinding(keyBinding);

Finally, Example 12-13 shows how to set the recovered PrivateKey into the RecoverResult:

Example 12-13 Setting the Recovered Private Key into RecoverResult

//Create an Instance of dsig:XEEncryptedData
XEEncryptedData encryptedData = //Instance of 
oracle.security.xmlsec.enc.XEEncryptedData
 
//Create an instance of oracle.security.xmlsec.xkms.xkrss.PrivateKey
PrivateKey privKey = new PrivateKey(sigDoc);
privKey.setEncryptedData(encryptedData);
 
//Add PrivateKey to RecoverResult
recResult.setPrivateKey(privKey);

12.4 The Oracle XKMS Java API Reference

The Oracle XKMS Java API Reference (Javadoc) is available at:

Oracle Security Developer Tools XKMS Java API Reference

12.5 Example Programs

For example programs using the Oracle Security Developer Tools, see the Oracle Technology Network Web Site at http://www.oracle.com/technology/index.html.