com.rsa.certj.xml

Class C14NTransformer

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

public class C14NTransformer
extends Transformer
implements Cloneable, Serializable

This class implements the canonical XML transformation without comments. It converts the input XML document or document subset to a canonical form. The input can be an octet stream or an XPath node-set. The canonical form of an XML document is described as follows:

  • The document is encoded in UTF-8.
  • Line breaks are normalized to #xA on input, before parsing.
  • Attribute values are normalized, as if by a validating processor.
  • Character and parsed entity references are replaced.
  • CDATA sections are replaced with their character content.
  • The XML declaration and document-type declaration (DTD) are removed.
  • Empty elements are converted to start-end tag pairs.
  • White space outside of the document element and within start and end tags is normalized.
  • All white space in character content is retained (excluding characters removed during line feed normalization).
  • Attribute-value delimiters are set to double quotation marks.
  • Special characters in attribute values and character content are replaced by character references.
  • Superfluous namespace declarations are removed from each element.
  • Default attributes are added to each element.
  • Lexicographic order is imposed on the namespace declarations and attributes of each element.

    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

    C14NTransformer()

    Generates a C14NTransformer instance by initializing the transformation algorithm to the default algorithm, which is the first one in Transformer.C14N_LIST.

     

    Method Summary

     Object

    clone()

    Overrides the default clone method to get a deeper clone.

     String

    getEncoding()

    Returns the encoding.

     String

    getTransformAlgorithm()

    Returns the transformation algorithm.

     byte[]

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

    Applies the canonicalization operation to the content data.

     org.w3c.dom.NodeList

    performTransformation(org.w3c.dom.NodeList inputNodes)

    Processes the canonicalization operation on the content data.

     org.w3c.dom.NodeList

    performTransformation(org.w3c.dom.NodeList inputNodes, String xpathExpression)

    Processes the canonicalization operation on the content data based on the document subset expressions.

     void

    setEncoding(String encoding)

    Sets the encoding.

     
    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

    C14NTransformer

    public C14NTransformer()
    Generates a C14NTransformer instance by initializing the transformation algorithm to the default algorithm, which is the first one in Transformer.C14N_LIST.
    Method Detail

    getTransformAlgorithm

    public String getTransformAlgorithm()
    Returns the transformation algorithm.

    Overrides

    getTransformAlgorithm in class Transformer

    Returns

    The transformation operation name as a String object.

    performTransformation

    public byte[] performTransformation(byte[] input,
                                        int inOffset,
                                        int inputLength)
                                 throws XMLException
    Applies the canonicalization operation to the content data. This method takes a byte array as input data and produces a byte array as output.

    Overrides

    performTransformation in class Transformer

    Parameters

             input  

    A byte array containing the data to transform.

             inOffset  

    The starting index of the input data.

             inputLength  

    The size of the input data.

    Returns

    A byte array containing the output of the transformation.

    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 canonicalization operation on the content data. It takes a node-set as input data and produces a node-set as output.

    Overrides

    performTransformation in class Transformer

    Parameters

             inputNodes  

    A node-set on which to perform canonicalization.

    Returns

    A NodeList object containing the canonical form of the node-set.

    Throws

    XMLException - If an error occurs while performing the canonicalization.

    performTransformation

    public org.w3c.dom.NodeList performTransformation(org.w3c.dom.NodeList inputNodes,
                                                      String xpathExpression)
                                               throws XMLException
    Processes the canonicalization operation on the content data based on the document subset expressions. It takes a node-set as input data and produces a node-set as output.

    Parameters

             inputNodes  

    A node-set on which to perform canonicalization.

             xpathExpression  

    A subset expression, which is a String, to perform on the node-set.

    Returns

    A NodeList object containing the canonical form of the node-set.

    Throws

    XMLException - If an error occurs while performing the canonicalization.

    setEncoding

    public void setEncoding(String encoding)
    Sets the encoding.

    Parameters

             encoding  

    A String containing the encoding name of the node-set to canonicalize.


    getEncoding

    public String getEncoding()
    Returns the encoding.

    Returns

    The encoding name of the node-set to canonicalize.

    clone

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

    Returns

    A new C14NTransformer object, a copy of this object.

    Throws

    CloneNotSupportedException - If the cloning operation is not successful.


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