blob: 21f9907b1185d37a73bad84d4ff8d1636992a4b0 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Copyright 1999-2004 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21package com.sun.org.apache.xml.internal.security.transforms.implementations;
22
23
24
25import java.io.OutputStream;
26
27import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
28import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments;
29import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
30import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
31import com.sun.org.apache.xml.internal.security.transforms.Transforms;
32
33
34/**
35 * Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315</CODE>
36 * transform.
37 *
38 * @author Christian Geuer-Pollmann
39 */
40public class TransformC14N extends TransformSpi {
41
42 /** Field implementedTransformURI */
43 public static final String implementedTransformURI =
44 Transforms.TRANSFORM_C14N_OMIT_COMMENTS;
45
46
47 /**
48 * @inheritDoc
49 */
50 protected String engineGetURI() {
51 return TransformC14N.implementedTransformURI;
52 }
53
54 /**
55 * @inheritDoc
56 */
57 protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
58 throws CanonicalizationException {
59 return enginePerformTransform(input,null);
60 }
61 protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os)
62 throws CanonicalizationException {
63 Canonicalizer20010315OmitComments c14n = new Canonicalizer20010315OmitComments();
64 if (os!=null) {
65 c14n.setWriter(os);
66 }
67 byte[] result = null;
68 input.setNeedsToBeExpanded(true);
69 result=c14n.engineCanonicalize(input);
70 XMLSignatureInput output=new XMLSignatureInput(result);
71 if (os!=null) {
72 output.setOutputStream(os);
73 }
74 return output;
75 }
76}