org.idoox.xml.security
Class Transform

java.lang.Object
  extended byorg.idoox.xml.security.Transform

public abstract class Transform
extends java.lang.Object

Class that provides transformation that may be used when signing. All transformation classes must be derived from this base class and override the method transform(byte[] input). There are two implemented transforms:

Example of using the implemented transform when creating signature:

   SignatureCreator sc = SignatureFactory.getInstance().getSignatureCreator();
   sc.addTransformAlgorithm("http://www.w3.org/2000/09/xmldsig#base64");
   ...
   sc.createSignature(...);
 

Application may implement the further transformation class derived from this base class and plug it into the WSO2 SOA Enablement Server using: addTransform method as in the example follows.

      public class MyTransform extends Transform{
          public MyTransform(){
              super("DummyTransform");
          }

          public byte[] transform(byte[] input) throws SignatureException{
              byte output[];
              ...
              // transform input to output
              ...
              return output;
          }

      }

      ...
      //register MyTransform
      Transform.addTransform("DummyTransform", new MyTransform());
      ...

      // using it when creating signature
      SignatureCreator sc = SignatureFactory.getInstance().getSignatureCreator();
      sc.addTransformAlgorithm("DummyTransform");
      ...
      sc.createSignature(...);
 

Component:
Security-Providers

Constructor Summary
protected Transform(java.lang.String algorithm)
          Constructor for the Transform object.
 
Method Summary
static void addTransform(java.lang.String algorithm, Transform transform)
          Registers new transform.
static Transform getInstance(java.lang.String algorithm)
          Gets transform instance specified by the algorithm.
static java.lang.String[] getTransforms()
          Returns names of the registered transform.
 java.lang.String toCanonicalXMLString(java.lang.String signaturePrefix)
          Return the canonical XML representation of transform.
abstract  ReferencedData transform(ReferencedData input)
          Executes transformation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transform

protected Transform(java.lang.String algorithm)
Constructor for the Transform object.

Parameters:
algorithm - the transform algorithm
Method Detail

getInstance

public static Transform getInstance(java.lang.String algorithm)
                             throws SignatureException
Gets transform instance specified by the algorithm.

Parameters:
algorithm - transform algorithm
Returns:
The Instance of the Transform
Throws:
SignatureException - thrown when error occurs.

transform

public abstract ReferencedData transform(ReferencedData input)
                                  throws SignatureException
Executes transformation.

Parameters:
input - an input data source
Returns:
transformed data
Throws:
SignatureException - thrown when error occurs

toCanonicalXMLString

public java.lang.String toCanonicalXMLString(java.lang.String signaturePrefix)
                                      throws SignatureException
Return the canonical XML representation of transform. For example:

  <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315">

  </Transform>
  

Parameters:
signaturePrefix - prefix of the being created signature
Returns:
the canonical XML representation of this object.
Throws:
SignatureException - thrown when error occurs.

addTransform

public static void addTransform(java.lang.String algorithm,
                                Transform transform)
Registers new transform.

Parameters:
algorithm - the algorithm to be added.
transform - the Transform object associated with algorithm to be added.

getTransforms

public static java.lang.String[] getTransforms()
Returns names of the registered transform.