FileDocCategorySizeDatePackage
Transforms.javaAPI DocJava SE 6 API12304Tue Jun 10 00:23:04 BST 2008com.sun.org.apache.xml.internal.security.transforms

Transforms

public class Transforms extends SignatureElementProxy
Holder of the {@link com.sun.org.apache.xml.internal.security.transforms.Transform} steps to be performed on the data. The input to the first Transform is the result of dereferencing the URI attribute of the Reference element. The output from the last Transform is the input for the DigestMethod algorithm
author
Christian Geuer-Pollmann
see
Transform
see
com.sun.org.apache.xml.internal.security.signature.Reference

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
public static final String
TRANSFORM_C14N_OMIT_COMMENTS
Canonicalization - Required Canonical XML (omits comments)
public static final String
TRANSFORM_C14N_WITH_COMMENTS
Canonicalization - Recommended Canonical XML with Comments
public static final String
TRANSFORM_C14N_EXCL_OMIT_COMMENTS
Canonicalization - Required Exclusive Canonicalization (omits comments)
public static final String
TRANSFORM_C14N_EXCL_WITH_COMMENTS
Canonicalization - Recommended Exclusive Canonicalization with Comments
public static final String
TRANSFORM_XSLT
Transform - Optional XSLT
public static final String
TRANSFORM_BASE64_DECODE
Transform - Required base64 decoding
public static final String
TRANSFORM_XPATH
Transform - Recommended XPath
public static final String
TRANSFORM_ENVELOPED_SIGNATURE
Transform - Required Enveloped Signature
public static final String
TRANSFORM_XPOINTER
Transform - XPointer
public static final String
TRANSFORM_XPATH2FILTER04
Transform - XPath Filter v2.0
public static final String
TRANSFORM_XPATH2FILTER
Transform - XPath Filter
public static final String
TRANSFORM_XPATHFILTERCHGP
Transform - XPath Filter CHGP private
Element[]
transforms
Constructors Summary
public Transforms(Document doc)
Consturcts {@link Transforms}

param
doc the {@link Document} in which XMLsignature will be placed

                     
      

      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);
   
public Transforms(Element element, String BaseURI)
Consturcts {@link Transforms} from {@link Element} which is Transforms Element

param
element is Transforms element
param
BaseURI the URI where the XML instance was stored
throws
DOMException
throws
InvalidTransformException
throws
TransformationException
throws
XMLSecurityException
throws
XMLSignatureException


      super(element, BaseURI);

      int numberOfTransformElems = this.getLength();

      if (numberOfTransformElems == 0) {

         // At least ont Transform element must be present. Bad.
         Object exArgs[] = { Constants._TAG_TRANSFORM,
                             Constants._TAG_TRANSFORMS };

         throw new TransformationException("xml.WrongContent", exArgs);
      }
   
Methods Summary
public voidaddTransform(java.lang.String transformURI)
Adds the Transform with the specified Transform algorithm URI

param
transformURI the URI form of transform that indicates which transformation is applied to data
throws
TransformationException


      try {
         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");

         Transform transform = Transform.getInstance(this._doc, transformURI);

         this.addTransform(transform);
      } catch (InvalidTransformException ex) {
         throw new TransformationException("empty", ex);
      }
   
public voidaddTransform(java.lang.String transformURI, org.w3c.dom.Element contextElement)
Adds the Transform with the specified Transform algorithm URI

param
transformURI the URI form of transform that indicates which transformation is applied to data
param
contextElement
throws
TransformationException
see
Transform#getInstance(Document doc, String algorithmURI, Element childElement)


      try {
         if (true)
        	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");

         Transform transform = Transform.getInstance(this._doc, transformURI,
                                                     contextElement);

         this.addTransform(transform);
      } catch (InvalidTransformException ex) {
         throw new TransformationException("empty", ex);
      }
   
public voidaddTransform(java.lang.String transformURI, org.w3c.dom.NodeList contextNodes)
Adds the Transform with the specified Transform algorithm URI

param
transformURI the URI form of transform that indicates which transformation is applied to data
param
contextNodes
throws
TransformationException
see
Transform#getInstance(Document doc, String algorithmURI, NodeList contextNodes)


      try {
         Transform transform = Transform.getInstance(this._doc, transformURI,
                                                     contextNodes);

         this.addTransform(transform);
      } catch (InvalidTransformException ex) {
         throw new TransformationException("empty", ex);
      }
   
private voidaddTransform(com.sun.org.apache.xml.internal.security.transforms.Transform transform)
Adds a user-provided Transform step.

param
transform {@link Transform} object

      if (true)
      	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transform.getURI() + ")");

      Element transformElement = transform.getElement();

      this._constructionElement.appendChild(transformElement);
      XMLUtils.addReturnToElement(this._constructionElement);
   
public java.lang.StringgetBaseLocalName()

inheritDoc

      return Constants._TAG_TRANSFORMS;
   
public intgetLength()
Return the nonnegative number of transformations.

return
the number of transformations

		/*Element nscontext = XMLUtils.createDSctx(this._doc, "ds",
	                                              Constants.SignatureSpecNS);
	     NodeList transformElems =
	        XPathAPI.selectNodeList(this._constructionElement,
	                                "./ds:Transform", nscontext);
	     return transformElems.getLength();*/
       if (transforms==null) {
        transforms=XMLUtils.selectDsNodes(this._constructionElement.getFirstChild(),
           "Transform");
       }
       return transforms.length;       
  
public com.sun.org.apache.xml.internal.security.transforms.Transformitem(int i)
Return the ith {@link Transform}. Valid i values are 0 to {@link #getLength}-1.

param
i index of {@link Transform} to return
return
the ith transforms
throws
TransformationException

   	
	   	try {
	   		if (transforms==null) {
	   			transforms=XMLUtils.selectDsNodes(this._constructionElement.getFirstChild(),
	   			"Transform");
	   		}
	   		return new Transform(transforms[i], this._baseURI);
	   	} catch (XMLSecurityException ex) {
	   		throw new TransformationException("empty", ex);
	   	}
   
public com.sun.org.apache.xml.internal.security.signature.XMLSignatureInputperformTransforms(com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput xmlSignatureInput)
Applies all included Transforms to xmlSignatureInput and returns the result of these transformations.

param
xmlSignatureInput the input for the Transforms
return
the result of the Transforms
throws
TransformationException

   	     return performTransforms(xmlSignatureInput,null);
   
public com.sun.org.apache.xml.internal.security.signature.XMLSignatureInputperformTransforms(com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput xmlSignatureInput, java.io.OutputStream os)
Applies all included Transforms to xmlSignatureInput and returns the result of these transformations.

param
xmlSignatureInput the input for the Transforms
param
os where to output the last transformation.
return
the result of the Transforms
throws
TransformationException


      try {
        int last=this.getLength()-1;
         for (int i = 0; i < last; i++) {
            Transform t = this.item(i);
            if (true) {
            	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Preform the (" + i + ")th " + t.getURI() + " transform");
            }
			xmlSignatureInput = t.performTransform(xmlSignatureInput);
         }
         if (last>=0) {
			Transform t = this.item(last);
            xmlSignatureInput = t.performTransform(xmlSignatureInput, os);
         }


         return xmlSignatureInput;
      } catch (IOException ex) {
         throw new TransformationException("empty", ex);
      // } catch (ParserConfigurationException ex) { throw new TransformationException("empty", ex);
      // } catch (SAXException ex) { throw new TransformationException("empty", ex);
      } catch (CanonicalizationException ex) {
         throw new TransformationException("empty", ex);
      } catch (InvalidCanonicalizerException ex) {
         throw new TransformationException("empty", ex);
      }