Path: blob/master/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Transform.java
43754 views
/*1* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25* $Id: Transform.java,v 1.5 2005/05/10 16:03:48 mullan Exp $26*/27package javax.xml.crypto.dsig;2829import java.io.OutputStream;30import java.security.spec.AlgorithmParameterSpec;31import javax.xml.crypto.AlgorithmMethod;32import javax.xml.crypto.Data;33import javax.xml.crypto.OctetStreamData;34import javax.xml.crypto.XMLCryptoContext;35import javax.xml.crypto.XMLStructure;36import javax.xml.crypto.dsig.spec.TransformParameterSpec;3738/**39* A representation of the XML <code>Transform</code> element as40* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">41* W3C Recommendation for XML-Signature Syntax and Processing</a>.42* The XML Schema Definition is defined as:43*44* <pre>45* <element name="Transform" type="ds:TransformType"/>46* <complexType name="TransformType" mixed="true">47* <choice minOccurs="0" maxOccurs="unbounded">48* <any namespace="##other" processContents="lax"/>49* <!-- (1,1) elements from (0,unbounded) namespaces -->50* <element name="XPath" type="string"/>51* </choice>52* <attribute name="Algorithm" type="anyURI" use="required"/>53* </complexType>54* </pre>55*56* A <code>Transform</code> instance may be created by invoking the57* {@link XMLSignatureFactory#newTransform newTransform} method58* of the {@link XMLSignatureFactory} class.59*60* @author Sean Mullan61* @author JSR 105 Expert Group62* @since 1.663* @see XMLSignatureFactory#newTransform(String, TransformParameterSpec)64*/65public interface Transform extends XMLStructure, AlgorithmMethod {6667/**68* The <a href="http://www.w3.org/2000/09/xmldsig#base64">Base64</a>69* transform algorithm URI.70*/71static final String BASE64 = "http://www.w3.org/2000/09/xmldsig#base64";7273/**74* The <a href="http://www.w3.org/2000/09/xmldsig#enveloped-signature">75* Enveloped Signature</a> transform algorithm URI.76*/77static final String ENVELOPED =78"http://www.w3.org/2000/09/xmldsig#enveloped-signature";7980/**81* The <a href="http://www.w3.org/TR/1999/REC-xpath-19991116">XPath</a>82* transform algorithm URI.83*/84static final String XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";8586/**87* The <a href="http://www.w3.org/2002/06/xmldsig-filter2">88* XPath Filter 2</a> transform algorithm URI.89*/90static final String XPATH2 = "http://www.w3.org/2002/06/xmldsig-filter2";9192/**93* The <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">XSLT</a>94* transform algorithm URI.95*/96static final String XSLT = "http://www.w3.org/TR/1999/REC-xslt-19991116";9798/**99* Returns the algorithm-specific input parameters associated with this100* <code>Transform</code>.101* <p>102* The returned parameters can be typecast to a103* {@link TransformParameterSpec} object.104*105* @return the algorithm-specific input parameters (may be <code>null</code>106* if not specified)107*/108AlgorithmParameterSpec getParameterSpec();109110/**111* Transforms the specified data using the underlying transform algorithm.112*113* @param data the data to be transformed114* @param context the <code>XMLCryptoContext</code> containing115* additional context (may be <code>null</code> if not applicable)116* @return the transformed data117* @throws NullPointerException if <code>data</code> is <code>null</code>118* @throws TransformException if an error occurs while executing the119* transform120*/121public abstract Data transform(Data data, XMLCryptoContext context)122throws TransformException;123124/**125* Transforms the specified data using the underlying transform algorithm.126* If the output of this transform is an <code>OctetStreamData</code>, then127* this method returns <code>null</code> and the bytes are written to the128* specified <code>OutputStream</code>. Otherwise, the129* <code>OutputStream</code> is ignored and the method behaves as if130* {@link #transform(Data, XMLCryptoContext)} were invoked.131*132* @param data the data to be transformed133* @param context the <code>XMLCryptoContext</code> containing134* additional context (may be <code>null</code> if not applicable)135* @param os the <code>OutputStream</code> that should be used to write136* the transformed data to137* @return the transformed data (or <code>null</code> if the data was138* written to the <code>OutputStream</code> parameter)139* @throws NullPointerException if <code>data</code> or <code>os</code>140* is <code>null</code>141* @throws TransformException if an error occurs while executing the142* transform143*/144public abstract Data transform145(Data data, XMLCryptoContext context, OutputStream os)146throws TransformException;147}148149150