KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > crypto > dsig > Transform


1 /*
2  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3  */

4 /*
5  * $Id: Transform.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
6  */

7 package javax.xml.crypto.dsig;
8
9 import java.io.OutputStream JavaDoc;
10 import java.security.spec.AlgorithmParameterSpec JavaDoc;
11 import javax.xml.crypto.AlgorithmMethod;
12 import javax.xml.crypto.Data;
13 import javax.xml.crypto.OctetStreamData;
14 import javax.xml.crypto.XMLCryptoContext;
15 import javax.xml.crypto.XMLStructure;
16 import javax.xml.crypto.dsig.spec.TransformParameterSpec;
17
18 /**
19  * A representation of the XML <code>Transform</code> element as
20  * defined in the <a HREF="http://www.w3.org/TR/xmldsig-core/">
21  * W3C Recommendation for XML-Signature Syntax and Processing</a>.
22  * The XML Schema Definition is defined as:
23  *
24  * <pre>
25  * &lt;element name="Transform" type="ds:TransformType"/&gt;
26  * &lt;complexType name="TransformType" mixed="true"&gt;
27  * &lt;choice minOccurs="0" maxOccurs="unbounded"&gt;
28  * &lt;any namespace="##other" processContents="lax"/&gt;
29  * &lt;!-- (1,1) elements from (0,unbounded) namespaces --&gt;
30  * &lt;element name="XPath" type="string"/&gt;
31  * &lt;/choice&gt;
32  * &lt;attribute name="Algorithm" type="anyURI" use="required"/&gt;
33  * &lt;/complexType&gt;
34  * </pre>
35  *
36  * A <code>Transform</code> instance may be created by invoking the
37  * {@link XMLSignatureFactory#newTransform newTransform} method
38  * of the {@link XMLSignatureFactory} class.
39  *
40  * @author Sean Mullan
41  * @author JSR 105 Expert Group
42  * @since 1.6
43  * @see XMLSignatureFactory#newTransform(String, TransformParameterSpec)
44  */

45 public interface Transform extends XMLStructure, AlgorithmMethod {
46
47     /**
48      * The <a HREF="http://www.w3.org/2000/09/xmldsig#base64">Base64</a>
49      * transform algorithm URI.
50      */

51     final static String JavaDoc BASE64 = "http://www.w3.org/2000/09/xmldsig#base64";
52
53     /**
54      * The <a HREF="http://www.w3.org/2000/09/xmldsig#enveloped-signature">
55      * Enveloped Signature</a> transform algorithm URI.
56      */

57     final static String JavaDoc ENVELOPED =
58         "http://www.w3.org/2000/09/xmldsig#enveloped-signature";
59
60     /**
61      * The <a HREF="http://www.w3.org/TR/1999/REC-xpath-19991116">XPath</a>
62      * transform algorithm URI.
63      */

64     final static String JavaDoc XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";
65
66     /**
67      * The <a HREF="http://www.w3.org/2002/06/xmldsig-filter2">
68      * XPath Filter 2</a> transform algorithm URI.
69      */

70     final static String JavaDoc XPATH2 = "http://www.w3.org/2002/06/xmldsig-filter2";
71
72     /**
73      * The <a HREF="http://www.w3.org/TR/1999/REC-xslt-19991116">XSLT</a>
74      * transform algorithm URI.
75      */

76     final static String JavaDoc XSLT = "http://www.w3.org/TR/1999/REC-xslt-19991116";
77
78     /**
79      * Returns the algorithm-specific input parameters associated with this
80      * <code>Transform</code>.
81      * <p>
82      * The returned parameters can be typecast to a
83      * {@link TransformParameterSpec} object.
84      *
85      * @return the algorithm-specific input parameters (may be <code>null</code>
86      * if not specified)
87      */

88     AlgorithmParameterSpec JavaDoc getParameterSpec();
89
90     /**
91      * Transforms the specified data using the underlying transform algorithm.
92      *
93      * @param data the data to be transformed
94      * @param context the <code>XMLCryptoContext</code> containing
95      * additional context (may be <code>null</code> if not applicable)
96      * @return the transformed data
97      * @throws NullPointerException if <code>data</code> is <code>null</code>
98      * @throws TransformException if an error occurs while executing the
99      * transform
100      */

101     public abstract Data transform(Data data, XMLCryptoContext context)
102         throws TransformException;
103
104     /**
105      * Transforms the specified data using the underlying transform algorithm.
106      * If the output of this transform is an <code>OctetStreamData</code>, then
107      * this method returns <code>null</code> and the bytes are written to the
108      * specified <code>OutputStream</code>. Otherwise, the
109      * <code>OutputStream</code> is ignored and the method behaves as if
110      * {@link #transform(Data, XMLCryptoContext)} were invoked.
111      *
112      * @param data the data to be transformed
113      * @param context the <code>XMLCryptoContext</code> containing
114      * additional context (may be <code>null</code> if not applicable)
115      * @param os the <code>OutputStream</code> that should be used to write
116      * the transformed data to
117      * @return the transformed data (or <code>null</code> if the data was
118      * written to the <code>OutputStream</code> parameter)
119      * @throws NullPointerException if <code>data</code> or <code>os</code>
120      * is <code>null</code>
121      * @throws TransformException if an error occurs while executing the
122      * transform
123      */

124     public abstract Data transform
125         (Data data, XMLCryptoContext context, OutputStream JavaDoc os)
126         throws TransformException;
127 }
128
Popular Tags