com.rsa.swsj.profiles.wss
Class WSSDocument

java.lang.Object
  extended bycom.rsa.swsj.XMLDocument
      extended bycom.rsa.swsj.profiles.wss.WSSDocument

public final class WSSDocument
extends XMLDocument

This class processes the XML document and adds security to it, according to the WSS specification.

Note: XML documents can be encrypted for multiple recipients by specifying separate KeyInfo objects. However, WSS documents cannot specify separate X509Token objects, since only one token can be attached to an XMLEncryption operation.


Constructor Summary
WSSDocument(SWSJContext context, java.io.InputStream input)

Reads and parses the SOAP message.

WSSDocument(SWSJContext context, java.io.InputStream input, java.io.OutputStream output)

Reads and parses the WSS document.

 
Method Summary

 void

addToken(Token token)

Adds a WS-Security token.

 Token[]

getTokens()

Returns all tokens in this document.

 void

process()

This method processes a security operations,such as sign or encrypt.

 void

removeToken(Token token)

Removes a WS-Security token.

 void

setTokens(Token[] tokens)

Adds an array of tokens to the document.

 
Methods inherited from class com.rsa.swsj.XMLDocument
addSecurityOperation, getContext, getSecurityOperations, removeSecurityOperation, setOutputStream, setSecurityOperations
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSSDocument

public WSSDocument(SWSJContext context,
                   java.io.InputStream input)
            throws InvalidParameterException,
                   ParseException
Reads and parses the SOAP message.

Parameters:
context - An object that collects a number of common parameters and state variables; for example, JCE provider.
input - An XML document.
Throws:
InvalidParameterException - If any parameter is invalid.
ParseException - If there is any problem parsing input.

WSSDocument

public WSSDocument(SWSJContext context,
                   java.io.InputStream input,
                   java.io.OutputStream output)
            throws InvalidParameterException,
                   ParseException
Reads and parses the WSS document. Any security items in the document are processed.

Parameters:
context - An object that collects a number of common parameters and state variables; for example, JCE provider.
input - The input XML document.
output - The output stream.
Throws:
InvalidParameterException - If any parameter is invalid.
ParseException - If there is any problem parsing input.
Method Detail

addToken

public void addToken(Token token)
              throws InvalidParameterException
Adds a WS-Security token.

Parameters:
token - An object that can carry key information, such as a user id or an X509Certificate.
Throws:
InvalidParameterException - If token is null.

setTokens

public void setTokens(Token[] tokens)
               throws InvalidParameterException
Adds an array of tokens to the document. Any pre-existing tokens that are not in this list are removed from the document.

Parameters:
tokens - An array of Token objects.
Throws:
InvalidParameterException - If the input parameter is null.

getTokens

public Token[] getTokens()
Returns all tokens in this document.

Returns:
An array of Token objects.

removeToken

public void removeToken(Token token)
                 throws InvalidParameterException
Removes a WS-Security token.

Parameters:
token - An object that can carry Key information, such as a user id or an X509Certificate.
Throws:
InvalidParameterException - If token is null.

process

public void process()
             throws ProviderException,
                    ParseException,
                    SignatureException,
                    EncryptionException,
                    TokenException
This method processes a security operations,such as sign or encrypt. Call this method only once and after all the operation have been specified. If the output stream is set, this method writes it the processed document.

Overrides:
process in class XMLDocument
Throws:
ProviderException - If there is an error parsing the input data.
ParseException - If there is any other parsing error.
SignatureException - If there is an error processing the Signature.
EncryptionException - If there is an error processing the XML encryption.
TokenException - If there is an error processing a token.