0N/A/*
0N/A * reserved comment block
0N/A * DO NOT REMOVE OR ALTER!
0N/A */
0N/A/*
0N/A * Copyright 1999-2004 The Apache Software Foundation.
0N/A *
0N/A * Licensed under the Apache License, Version 2.0 (the "License");
0N/A * you may not use this file except in compliance with the License.
0N/A * You may obtain a copy of the License at
0N/A *
0N/A * http://www.apache.org/licenses/LICENSE-2.0
0N/A *
0N/A * Unless required by applicable law or agreed to in writing, software
0N/A * distributed under the License is distributed on an "AS IS" BASIS,
0N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0N/A * See the License for the specific language governing permissions and
0N/A * limitations under the License.
0N/A *
0N/A */
0N/Apackage com.sun.org.apache.xml.internal.security.transforms.implementations;
0N/A
0N/Aimport java.io.OutputStream;
0N/A
0N/Aimport com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
0N/Aimport com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments;
0N/Aimport com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
0N/Aimport com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
661N/Aimport com.sun.org.apache.xml.internal.security.transforms.Transform;
0N/Aimport com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
0N/Aimport com.sun.org.apache.xml.internal.security.transforms.Transforms;
0N/Aimport com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
0N/Aimport com.sun.org.apache.xml.internal.security.utils.XMLUtils;
0N/Aimport org.w3c.dom.Element;
0N/A
0N/A/**
0N/A * Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments</CODE>
0N/A * transform.
0N/A *
0N/A * @author Christian Geuer-Pollmann
0N/A */
0N/Apublic class TransformC14NExclusiveWithComments extends TransformSpi {
0N/A
0N/A /** Field implementedTransformURI */
0N/A public static final String implementedTransformURI =
0N/A Transforms.TRANSFORM_C14N_EXCL_WITH_COMMENTS;
0N/A
0N/A /**
0N/A * Method engineGetURI
0N/A *@inheritDoc
0N/A *
0N/A */
0N/A protected String engineGetURI() {
0N/A return implementedTransformURI;
0N/A }
0N/A
0N/A /**
0N/A * @inheritDoc
0N/A */
661N/A protected XMLSignatureInput enginePerformTransform
661N/A (XMLSignatureInput input, Transform _transformObject)
0N/A throws CanonicalizationException {
661N/A return enginePerformTransform(input, null, _transformObject);
0N/A }
661N/A
661N/A protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os, Transform _transformObject)
0N/A throws CanonicalizationException {
0N/A try {
0N/A String inclusiveNamespaces = null;
0N/A
661N/A if (_transformObject
0N/A .length(InclusiveNamespaces
0N/A .ExclusiveCanonicalizationNamespace, InclusiveNamespaces
0N/A ._TAG_EC_INCLUSIVENAMESPACES) == 1) {
0N/A Element inclusiveElement =
0N/A XMLUtils.selectNode(
661N/A _transformObject.getElement().getFirstChild(),
0N/A InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
0N/A InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,0);
0N/A
0N/A inclusiveNamespaces = new InclusiveNamespaces(inclusiveElement,
661N/A _transformObject.getBaseURI()).getInclusiveNamespaces();
0N/A }
0N/A
0N/A Canonicalizer20010315ExclWithComments c14n =
0N/A new Canonicalizer20010315ExclWithComments();
0N/A if (os!=null) {
0N/A c14n.setWriter( os);
0N/A }
0N/A byte []result;
0N/A result =c14n.engineCanonicalize(input, inclusiveNamespaces);
0N/A XMLSignatureInput output=new XMLSignatureInput(result);
0N/A
0N/A return output;
0N/A } catch (XMLSecurityException ex) {
0N/A throw new CanonicalizationException("empty", ex);
0N/A }
0N/A }
0N/A}