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

TransformEnvelopedSignature

public class TransformEnvelopedSignature extends TransformSpi
Implements the http://www.w3.org/2000/09/xmldsig#enveloped-signature transform.
author
Christian Geuer-Pollmann

Fields Summary
public static final String
implementedTransformURI
Field implementedTransformURI
Constructors Summary
Methods Summary
protected java.lang.StringengineGetURI()
Method engineGetURI

inheritDoc


          
      
      return implementedTransformURI;
   
protected com.sun.org.apache.xml.internal.security.signature.XMLSignatureInputenginePerformTransform(com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput input)

inheritDoc




         /**
          * If the actual input is an octet stream, then the application MUST
          * convert the octet stream to an XPath node-set suitable for use by
          * Canonical XML with Comments. (A subsequent application of the
          * REQUIRED Canonical XML algorithm would strip away these comments.)
          *
          * ...
          *
          * The evaluation of this expression includes all of the document's nodes
          * (including comments) in the node-set representing the octet stream.
          */

         /*
         if (input.isOctetStream()) {
            input.setNodesetXPath(Canonicalizer.XPATH_C14N_WITH_COMMENTS);
         }
         */
         
         Element transformElement = this._transformObject.getElement();
         Node signatureElement = transformElement;
         

         signatureElement = searchSignatureElement(signatureElement);        
         	input.setExcludeNode(signatureElement);   
         	input.addNodeFilter(new EnvelopedNodeFilter(signatureElement));
         	return input;
         
         //
         
      
   
private static org.w3c.dom.NodesearchSignatureElement(org.w3c.dom.Node signatureElement)

param
signatureElement
return
the node that is the signature
throws
TransformationException

	    boolean found=false;
        
	    while (true) {
	    	if ((signatureElement == null)
	            || (signatureElement.getNodeType() == Node.DOCUMENT_NODE)) {
	    		break;
	    	}
	    	Element el=(Element)signatureElement;
	    	if (el.getNamespaceURI().equals(Constants.SignatureSpecNS)
                    && 
	               el.getLocalName().equals(Constants._TAG_SIGNATURE)) {
	    		found = true;
	    		break;
	    	}

	    	signatureElement = signatureElement.getParentNode();
	    }

	    if (!found) {
	      throw new TransformationException(
	       "envelopedSignatureTransformNotInSignatureElement");
	    }
	    return signatureElement;