com.rsa.certj.xml

Class XPATHTransformer

java.lang.Object
  |
  +--com.rsa.certj.xml.Transformer
        |
        +--com.rsa.certj.xml.XPATHTransformer
All Implemented Interfaces:
Cloneable, Serializable

public class XPATHTransformer
extends Transformer
implements Cloneable, Serializable

This class implements an XPath transformation. The primary purpose of this transform is to ensure that only specifically defined changes to the input XML document are permitted after the signature is affixed. The input required by this transform is an XPath node-set. If the input is an octet stream, this class converts the octet stream to an XPath node-set first. The are two parts to the transformation.

  1. Intialize an XPath evaluation context by setting the initial node equal to the input XML document's root node, and set the context position and size to 1.

  2. Evaluate the XPath expression.

Copyright © RSA Security Inc., 2001-2002. All rights reserved.

See Also

Serialized Form

Fields inherited from class com.rsa.certj.xml.Transformer
BASE64_LIST, C14N_LIST, C14N_WITH_COMMENTS_LIST, ENVELOPED_SIGNATURE_LIST, XPATH_LIST
 

Constructor Summary

XPATHTransformer()

Generates an XPATHTransformer object by initializing the transform algorithm to the default one, which is the top one in Transformer.ENVELOPED_SIGNATURE_LIST.

 

Method Summary

 Object

clone()

Overrides the default clone method to get a deeper clone.

 String

getTransformAlgorithm()

Returns the transform algorithm.

 org.w3c.dom.Node

getXPathExpression()

Returns the XPath expression as a Node.

 String

getXPathExpressionAsString()

Returns the XPath expression as a String.

 byte[]

performTransformation(byte[] input, int inOffset, int inputLength)

Processes the XPath transformation to the content data.

 org.w3c.dom.NodeList

performTransformation(org.w3c.dom.NodeList inputNodes)

Processes the transform operation on the content data.

 void

setXPathExpression(org.w3c.dom.Node xpathExpression)

Sets the XPath evaluation expression with the given Node value.

 void

setXPathExpression(String xpathExpStr)

Sets the XPath evaluation expression with the given String values.

static org.w3c.dom.NodeList

toNodeset(org.w3c.dom.Node node, org.w3c.dom.Node exceptedNode, boolean withComments)

Converts the Node object to node-set by collecting all of its descendants.

 
Methods inherited from class com.rsa.certj.xml.Transformer
getAllTransformsInfo, getInstance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPATHTransformer

public XPATHTransformer()
Generates an XPATHTransformer object by initializing the transform algorithm to the default one, which is the top one in Transformer.ENVELOPED_SIGNATURE_LIST.
Method Detail

performTransformation

public byte[] performTransformation(byte[] input,
                                    int inOffset,
                                    int inputLength)
                             throws XMLException
Processes the XPath transformation to the content data. It takes a byte array as input data, converts it to an XPath node-set, process the transformation and produces a node-set as the result, and converts the resulting node-set to a byte array.

Overrides

performTransformation in class Transformer

Parameters

         input  

A byte array to transform.

         inOffset  

The starting index of the input data.

         inputLength  

The size of the input data to process.

Returns

A byte array containing the transform output.

Throws

XMLException - If an error occurs while performing the transformation.

performTransformation

public org.w3c.dom.NodeList performTransformation(org.w3c.dom.NodeList inputNodes)
                                           throws XMLException
Processes the transform operation on the content data. It takes a node-set as input data and produces a node-set as the result.

Overrides

performTransformation in class Transformer

Parameters

         inputNodes  

A Node object to transform.

Returns

A NodeList object containing a node-set that is the transform output.

Throws

XMLException - If an error occurs while performing the transformation.

getTransformAlgorithm

public String getTransformAlgorithm()
Returns the transform algorithm.

Overrides

getTransformAlgorithm in class Transformer

Returns

A String containing the transform algorithm name.

setXPathExpression

public void setXPathExpression(org.w3c.dom.Node xpathExpression)
Sets the XPath evaluation expression with the given Node value. This node should define namespace, which is required by the org.apache.xpath package.

Parameters

         xpathExpression  

An expression which is a Node used for XPath evaluation.


getXPathExpression

public org.w3c.dom.Node getXPathExpression()
Returns the XPath expression as a Node.

Returns

The XPath expression as a Node object.

setXPathExpression

public void setXPathExpression(String xpathExpStr)
Sets the XPath evaluation expression with the given String values. Use this method only when the expression is not namespace-related; otherwise, use the setXPathExpression method that takes a Node object.

Parameters

         xpathExpStr  

A String expression to set as the XPath evaluation expression.


getXPathExpressionAsString

public String getXPathExpressionAsString()
Returns the XPath expression as a String.

Returns

The XPath expression as a String object.

clone

public Object clone()
             throws CloneNotSupportedException
Overrides the default clone method to get a deeper clone.

Returns

A new XPATHTransforme object, a copy of this object.

Throws

CloneNotSupportedException - If the cloning operation is not successful.

toNodeset

public static org.w3c.dom.NodeList toNodeset(org.w3c.dom.Node node,
                                             org.w3c.dom.Node exceptedNode,
                                             boolean withComments)
                                      throws XMLException
Converts the Node object to node-set by collecting all of its descendants.

Internal method, do not use

Parameters

         node  

A Node object to be converted to node-set.

         exceptedNode  

The Node object to be excluded from the result node-set.

         withComments  

A Boolean variable indicating whether the resulting node-set should include comment nodes or not.

Throws

If - an error occurs during converting the input node to a node-set.


RSA BSAFE ® Cert-J 2.1.1 001-047007-211-001-000