1 17 package com.sun.org.apache.xml.internal.security.transforms.implementations; 18 19 20 21 import java.io.OutputStream ; 22 23 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; 24 import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments; 25 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 26 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; 27 import com.sun.org.apache.xml.internal.security.transforms.TransformSpi; 28 import com.sun.org.apache.xml.internal.security.transforms.Transforms; 29 import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces; 30 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; 31 import org.w3c.dom.Element ; 32 33 34 40 public class TransformC14NExclusiveWithComments extends TransformSpi { 41 42 43 public static final String implementedTransformURI = 44 Transforms.TRANSFORM_C14N_EXCL_WITH_COMMENTS; 45 46 47 52 protected String engineGetURI() { 53 return implementedTransformURI; 54 } 55 56 59 protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input) 60 throws CanonicalizationException { 61 return enginePerformTransform(input,null); 62 } 63 protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os) 64 throws CanonicalizationException { 65 try { 66 String inclusiveNamespaces = null; 67 68 if (this._transformObject 69 .length(InclusiveNamespaces 70 .ExclusiveCanonicalizationNamespace, InclusiveNamespaces 71 ._TAG_EC_INCLUSIVENAMESPACES) == 1) { 72 Element inclusiveElement = 73 XMLUtils.selectNode( 74 this._transformObject.getElement().getFirstChild(), 75 InclusiveNamespaces.ExclusiveCanonicalizationNamespace, 76 InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,0); 77 78 inclusiveNamespaces = new InclusiveNamespaces(inclusiveElement, 79 this._transformObject.getBaseURI()).getInclusiveNamespaces(); 80 } 81 82 Canonicalizer20010315ExclWithComments c14n = 83 new Canonicalizer20010315ExclWithComments(); 84 if (os!=null) { 85 c14n.setWriter( os); 86 } 87 input.setNeedsToBeExpanded(true); 88 byte []result; 89 result =c14n.engineCanonicalize(input, inclusiveNamespaces); 90 XMLSignatureInput output=new XMLSignatureInput(result); 91 92 return output; 93 } catch (XMLSecurityException ex) { 94 throw new CanonicalizationException("empty", ex); 95 } 96 } 97 } 98 | Popular Tags |