KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > AlgorithmParametersSpi


1 /*
2  * @(#)AlgorithmParametersSpi.java 1.12 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7  
8 package java.security;
9
10 import java.io.*;
11 import java.security.spec.AlgorithmParameterSpec JavaDoc;
12 import java.security.spec.InvalidParameterSpecException JavaDoc;
13
14 /**
15  * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
16  * for the <code>AlgorithmParameters</code> class, which is used to manage
17  * algorithm parameters.
18  *
19  * <p> All the abstract methods in this class must be implemented by each
20  * cryptographic service provider who wishes to supply parameter management
21  * for a particular algorithm.
22  *
23  * @author Jan Luehe
24  *
25  * @version 1.12, 05/05/04
26  *
27  * @see AlgorithmParameters
28  * @see java.security.spec.AlgorithmParameterSpec
29  * @see java.security.spec.DSAParameterSpec
30  *
31  * @since 1.2
32  */

33
34 public abstract class AlgorithmParametersSpi {
35
36     /**
37      * Initializes this parameters object using the parameters
38      * specified in <code>paramSpec</code>.
39      *
40      * @param paramSpec the parameter specification.
41      *
42      * @exception InvalidParameterSpecException if the given parameter
43      * specification is inappropriate for the initialization of this parameter
44      * object.
45      */

46     protected abstract void engineInit(AlgorithmParameterSpec JavaDoc paramSpec)
47     throws InvalidParameterSpecException JavaDoc;
48
49     /**
50      * Imports the specified parameters and decodes them
51      * according to the primary decoding format for parameters.
52      * The primary decoding format for parameters is ASN.1, if an ASN.1
53      * specification for this type of parameters exists.
54      *
55      * @param params the encoded parameters.
56      *
57      * @exception IOException on decoding errors
58      */

59     protected abstract void engineInit(byte[] params)
60     throws IOException;
61
62     /**
63      * Imports the parameters from <code>params</code> and
64      * decodes them according to the specified decoding format.
65      * If <code>format</code> is null, the
66      * primary decoding format for parameters is used. The primary decoding
67      * format is ASN.1, if an ASN.1 specification for these parameters
68      * exists.
69      *
70      * @param params the encoded parameters.
71      *
72      * @param format the name of the decoding format.
73      *
74      * @exception IOException on decoding errors
75      */

76     protected abstract void engineInit(byte[] params, String JavaDoc format)
77     throws IOException;
78
79     /**
80      * Returns a (transparent) specification of this parameters
81      * object.
82      * <code>paramSpec</code> identifies the specification class in which
83      * the parameters should be returned. It could, for example, be
84      * <code>DSAParameterSpec.class</code>, to indicate that the
85      * parameters should be returned in an instance of the
86      * <code>DSAParameterSpec</code> class.
87      *
88      * @param paramSpec the the specification class in which
89      * the parameters should be returned.
90      *
91      * @return the parameter specification.
92      *
93      * @exception InvalidParameterSpecException if the requested parameter
94      * specification is inappropriate for this parameter object.
95      */

96     protected abstract
97     <T extends AlgorithmParameterSpec JavaDoc>
98     T engineGetParameterSpec(Class JavaDoc<T> paramSpec)
99     throws InvalidParameterSpecException JavaDoc;
100
101     /**
102      * Returns the parameters in their primary encoding format.
103      * The primary encoding format for parameters is ASN.1, if an ASN.1
104      * specification for this type of parameters exists.
105      *
106      * @return the parameters encoded using the specified encoding scheme.
107      *
108      * @exception IOException on encoding errors.
109      */

110     protected abstract byte[] engineGetEncoded() throws IOException;
111
112     /**
113      * Returns the parameters encoded in the specified format.
114      * If <code>format</code> is null, the
115      * primary encoding format for parameters is used. The primary encoding
116      * format is ASN.1, if an ASN.1 specification for these parameters
117      * exists.
118      *
119      * @param format the name of the encoding format.
120      *
121      * @return the parameters encoded using the specified encoding scheme.
122      *
123      * @exception IOException on encoding errors.
124      */

125     protected abstract byte[] engineGetEncoded(String JavaDoc format)
126     throws IOException;
127
128     /**
129      * Returns a formatted string describing the parameters.
130      *
131      * @return a formatted string describing the parameters.
132      */

133     protected abstract String JavaDoc engineToString();
134 }
135
Popular Tags