com.rsa.certj.xml

Class Base64Transformer

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

public class Base64Transformer
extends Transformer
implements Cloneable, Serializable

This class implements a Base64 transformation that decodes input data. This transformation is useful if an application needs to sign the raw data associated with the encoded content of an 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

Base64Transformer()

Generates a Base64Transformer instance by initializing the transform algorithm to the default Base64 algorithm in Transformer, which is the first algorithm in the BASE64_LIST.

 

Method Summary

 Object

clone()

Overrides the default clone method to get a deeper clone.

static byte[]

decodeBase64Data(byte[] input, int inputOffset, int inputLength)

Decodes the Base64-encoded input data.

static byte[]

encodeBase64(byte[] input, int inputOffset, int inputLength)

Encodes the input data with Base64 encoding.

 String

getTransformAlgorithm()

Returns the transformation algorithm.

 byte[]

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

Performs a Base64 transformation on input, where input is a byte array.

 org.w3c.dom.NodeList

performTransformation(org.w3c.dom.NodeList inputNodes)

Performs a Base64 transformation on inputNodes.

 
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

Base64Transformer

public Base64Transformer()
Generates a Base64Transformer instance by initializing the transform algorithm to the default Base64 algorithm in Transformer, which is the first algorithm in the BASE64_LIST.
Method Detail

performTransformation

public byte[] performTransformation(byte[] input,
                                    int inputOffset,
                                    int inputLength)
                             throws XMLException
Performs a Base64 transformation on input, where input is a byte array.

This method should be called only in signature verification.

Overrides

performTransformation in class Transformer

Parameters

         input  

A byte array to transform.

         inputOffset  

The starting index of the input data.

         inputLength  

The length of the input data.

Returns

A byte array buffer that holds the transformation result.

Throws

XMLException - If a Base64-encoding error occurs, or if input is null.

performTransformation

public org.w3c.dom.NodeList performTransformation(org.w3c.dom.NodeList inputNodes)
                                           throws XMLException
Performs a Base64 transformation on inputNodes. This method takes a node-set as input data. It strips away the start and end tags of the identified nodes and any of their descendant elements, including descendant comments and processing instructions, and converts it to an octet stream. Then the Base64 transformation is performed on the octet stream.

This method should be called only in signature verification.

Overrides

performTransformation in class Transformer

Parameters

         inputNodes  

A NodeList object to be transformed.

Returns

A NodeList object containing a node set, which is the transformation output.

Throws

XMLException - If an error occurs while performing the transformation.

getTransformAlgorithm

public String getTransformAlgorithm()
Returns the transformation algorithm.

Overrides

getTransformAlgorithm in class Transformer

Returns

The transform operation name as a String.

encodeBase64

public static byte[] encodeBase64(byte[] input,
                                  int inputOffset,
                                  int inputLength)
                           throws XMLException
Encodes the input data with Base64 encoding.

Parameters

         input  

A byte array containing the data to encode.

         inputOffset  

The starting index of the input data.

         inputLength  

The length of the input data.

Returns

A byte array buffer that holds the encoded data.

Throws

XMLException - If an encoding error occurs, or if input is null.

decodeBase64Data

public static byte[] decodeBase64Data(byte[] input,
                                      int inputOffset,
                                      int inputLength)
                               throws XMLException
Decodes the Base64-encoded input data.

Parameters

         input  

A byte array containing the data to decode.

         inputOffset  

The starting index of the input data.

         inputLength  

The length of the input data.

Returns

A byte array buffer that holds the decoded data.

Throws

XMLException - If a decoding error occurs, or if input is null.

clone

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

Returns

A new Base64Transformer 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