com.rsa.swsj
Class XMLDocument

java.lang.Object
  extended bycom.rsa.swsj.XMLDocument
Direct Known Subclasses:
WSSDocument

public class XMLDocument
extends java.lang.Object

This class processes the XML document and adds security to it.


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

Reads and parses an XML document.

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

Reads and parses the XML document.

 
Method Summary

 void

addSecurityOperation(XMLSecurityOperation op)

Adds an XML security operation to the document,such as XMLSignature.

 SWSJContext

getContext()

Gets the SWSJContext object that carries a number of common parameters and state variables.

 XMLSecurityOperation[]

getSecurityOperations()

Returns all XML security operations in this document.

 void

process()

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

 void

removeSecurityOperation(XMLSecurityOperation op)

Removes an XML security operation from the document.

 void

setOutputStream(java.io.OutputStream output)

Sets the output stream to which the document is written.

 void

setSecurityOperations(XMLSecurityOperation[] ops)

Sets an array of new XML security operations to the document.

 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDocument

public XMLDocument(SWSJContext context,
                   java.io.InputStream input)
            throws InvalidParameterException,
                   ParseException
Reads and parses an XML 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 - An XML document.
Throws:
InvalidParameterException - If an invalid parameter is passed to this method.
ParseException - If the input cannot be parsed.

XMLDocument

public XMLDocument(SWSJContext context,
                   java.io.InputStream input,
                   java.io.OutputStream output)
            throws InvalidParameterException,
                   ParseException
Reads and parses the XML 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 - An XML document.
output - the output stream.
Throws:
InvalidParameterException - If an invalid parameter is passed to this method.
ParseException - If the input cannot be parsed.
Method Detail

getContext

public SWSJContext getContext()
Gets the SWSJContext object that carries a number of common parameters and state variables.

Returns:
An SWSJContext object that collects a number of common parameters and state variables; for example, JCE provider.

setOutputStream

public void setOutputStream(java.io.OutputStream output)
                     throws InvalidParameterException
Sets the output stream to which the document is written.

Parameters:
output - The output stream.
Throws:
InvalidParameterException - If an invalid parameter is passed to this method.

addSecurityOperation

public void addSecurityOperation(XMLSecurityOperation op)
                          throws InvalidParameterException
Adds an XML security operation to the document,such as XMLSignature.

Parameters:
op - Any XML Security operation,such as XML signing.
Throws:
InvalidParameterException - If an invalid parameter is passed to this method.

setSecurityOperations

public void setSecurityOperations(XMLSecurityOperation[] ops)
                           throws InvalidParameterException
Sets an array of new XML security operations to the document. Any pre-existing security operations that are not in this list are removed from the document.

Parameters:
ops - An array of security operations.
Throws:
InvalidParameterException - If an invalid parameter is passed to this method.

getSecurityOperations

public XMLSecurityOperation[] getSecurityOperations()
Returns all XML security operations in this document.

Returns:
An array of security operations.

removeSecurityOperation

public void removeSecurityOperation(XMLSecurityOperation op)
                             throws InvalidParameterException
Removes an XML security operation from the document.

Parameters:
op - Any XML Security operation; for example, XML signing.
Throws:
InvalidParameterException - If an invalid parameter is passed to this method.

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.

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.