KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > transforms > implementations > TransformC14NWithComments


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package com.sun.org.apache.xml.internal.security.transforms.implementations;
18
19
20
21 import java.io.OutputStream JavaDoc;
22
23 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
24 import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315WithComments;
25 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
26 import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
27 import com.sun.org.apache.xml.internal.security.transforms.Transforms;
28
29
30 /**
31  * Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments</CODE>
32  * transform.
33  *
34  * @author Christian Geuer-Pollmann
35  */

36 public class TransformC14NWithComments extends TransformSpi {
37
38    /** Field implementedTransformURI */
39    public static final String JavaDoc implementedTransformURI =
40       Transforms.TRANSFORM_C14N_WITH_COMMENTS;
41
42
43    /** @inheritDoc */
44    protected String JavaDoc engineGetURI() {
45       return implementedTransformURI;
46    }
47    /** @inheritDoc */
48    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
49    throws CanonicalizationException {
50         return enginePerformTransform(input,null);
51    }
52    /** @inheritDoc */
53    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream JavaDoc os)
54            throws CanonicalizationException {
55       
56         Canonicalizer20010315WithComments c14n = new Canonicalizer20010315WithComments();
57         if (os!=null) {
58             c14n.setWriter( os);
59         }
60         
61          byte[] result = null;
62          input.setNeedsToBeExpanded(true);
63          result=c14n.engineCanonicalize(input);
64          XMLSignatureInput output=new XMLSignatureInput(result);
65          if (os!=null) {
66             output.setOutputStream(os);
67          }
68          return output;
69    }
70 }
71
Popular Tags