KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > algorithms > SignatureAlgorithmSpi


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.algorithms;
18
19
20
21 import java.security.Key JavaDoc;
22 import java.security.SecureRandom JavaDoc;
23 import java.security.spec.AlgorithmParameterSpec JavaDoc;
24
25 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
26 import org.w3c.dom.Document JavaDoc;
27 import org.w3c.dom.Element JavaDoc;
28
29
30 /**
31  *
32  * @author $Author: raul $
33  */

34 public abstract class SignatureAlgorithmSpi {
35
36    /** {@link java.util.logging} logging facility */
37     static java.util.logging.Logger JavaDoc log =
38         java.util.logging.Logger.getLogger(SignatureAlgorithmSpi.class.getName());
39
40    /**
41     * Returns the URI representation of <code>Transformation algorithm</code>
42     *
43     * @return the URI representation of <code>Transformation algorithm</code>
44     */

45    protected abstract String JavaDoc engineGetURI();
46
47    /**
48     * Proxy method for {@link java.security.Signature#getAlgorithm}
49     * which is executed on the internal {@link java.security.Signature} object.
50     *
51     * @return the result of the {@link java.security.Signature#getAlgorithm} method
52     */

53    protected abstract String JavaDoc engineGetJCEAlgorithmString();
54
55    /**
56     * Method engineGetJCEProviderName
57     *
58     * @return the JCE ProviderName
59     */

60    protected abstract String JavaDoc engineGetJCEProviderName();
61
62    /**
63     * Proxy method for {@link java.security.Signature#update(byte[])}
64     * which is executed on the internal {@link java.security.Signature} object.
65     *
66     * @param input
67     * @throws XMLSignatureException
68     */

69    protected abstract void engineUpdate(byte[] input)
70       throws XMLSignatureException;
71
72    /**
73     * Proxy method for {@link java.security.Signature#update(byte[])}
74     * which is executed on the internal {@link java.security.Signature} object.
75     *
76     * @param input
77     * @throws XMLSignatureException
78     */

79    protected abstract void engineUpdate(byte input)
80       throws XMLSignatureException;
81
82    /**
83     * Proxy method for {@link java.security.Signature#update(byte[], int, int)}
84     * which is executed on the internal {@link java.security.Signature} object.
85     *
86     * @param buf
87     * @param offset
88     * @param len
89     * @throws XMLSignatureException
90     */

91    protected abstract void engineUpdate(byte buf[], int offset, int len)
92       throws XMLSignatureException;
93
94    /**
95     * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
96     * which is executed on the internal {@link java.security.Signature} object.
97     *
98     * @param signingKey
99     * @throws XMLSignatureException if this method is called on a MAC
100     */

101    protected abstract void engineInitSign(Key JavaDoc signingKey)
102       throws XMLSignatureException;
103
104    /**
105     * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey, java.security.SecureRandom)}
106     * which is executed on the internal {@link java.security.Signature} object.
107     *
108     * @param signingKey
109     * @param secureRandom
110     * @throws XMLSignatureException if this method is called on a MAC
111     */

112    protected abstract void engineInitSign(
113       Key JavaDoc signingKey, SecureRandom JavaDoc secureRandom) throws XMLSignatureException;
114
115    /**
116     * Proxy method for {@link javax.crypto.Mac}
117     * which is executed on the internal {@link javax.crypto.Mac#init(Key)} object.
118     *
119     * @param signingKey
120     * @param algorithmParameterSpec
121     * @throws XMLSignatureException if this method is called on a Signature
122     */

123    protected abstract void engineInitSign(
124       Key JavaDoc signingKey, AlgorithmParameterSpec JavaDoc algorithmParameterSpec)
125          throws XMLSignatureException;
126
127    /**
128     * Proxy method for {@link java.security.Signature#sign()}
129     * which is executed on the internal {@link java.security.Signature} object.
130     *
131     * @return the result of the {@link java.security.Signature#sign()} method
132     * @throws XMLSignatureException
133     */

134    protected abstract byte[] engineSign() throws XMLSignatureException;
135
136    /**
137     * Method engineInitVerify
138     *
139     * @param verificationKey
140     * @throws XMLSignatureException
141     */

142    protected abstract void engineInitVerify(Key JavaDoc verificationKey)
143       throws XMLSignatureException;
144
145    /**
146     * Proxy method for {@link java.security.Signature#verify(byte[])}
147     * which is executed on the internal {@link java.security.Signature} object.
148     *
149     * @param signature
150     * @return true if the signature is correct
151     * @throws XMLSignatureException
152     */

153    protected abstract boolean engineVerify(byte[] signature)
154       throws XMLSignatureException;
155
156    /**
157     * Proxy method for {@link java.security.Signature#setParameter(java.security.spec.AlgorithmParameterSpec)}
158     * which is executed on the internal {@link java.security.Signature} object.
159     *
160     * @param params
161     * @throws XMLSignatureException
162     */

163    protected abstract void engineSetParameter(AlgorithmParameterSpec JavaDoc params)
164       throws XMLSignatureException;
165
166    /** Field _doc */
167    Document JavaDoc _doc = null;
168
169    /**
170     * Method engineSetDocument
171     *
172     * @param doc
173     */

174    protected void engineSetDocument(Document JavaDoc doc) {
175       this._doc = doc;
176    }
177
178    /** Field _constructionElement */
179    Element JavaDoc _constructionElement = null;
180
181    /**
182     * Method engineGetContextFromElement
183     *
184     * @param element
185     */

186    protected void engineGetContextFromElement(Element JavaDoc element) {
187       this._constructionElement = element;
188    }
189
190    /**
191     * Method engineSetHMACOutputLength
192     *
193     * @param HMACOutputLength
194     * @throws XMLSignatureException
195     */

196    protected abstract void engineSetHMACOutputLength(int HMACOutputLength)
197       throws XMLSignatureException;
198 }
199
Popular Tags