001 /* CertificateFactorySpi.java --- Certificate Factory Class
002 Copyright (C) 1999,2003 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package java.security.cert;
040
041 import java.io.InputStream;
042
043 import java.util.Collection;
044 import java.util.Iterator;
045 import java.util.List;
046
047 /**
048 CertificateFactorySpi is the abstract class Service Provider
049 Interface (SPI) for the CertificateFactory class. A provider
050 must implement all the abstract methods if they wish to
051 supply a certificate factory for a particular certificate
052 type. Ex: X.509
053
054 Certificate factories are used to generate certificates and
055 certificate revocation lists (CRL) from their encoding.
056
057 @since 1.2
058
059 @author Mark Benvenuto
060 */
061 public abstract class CertificateFactorySpi
062 {
063
064 // Constructor.
065 // ------------------------------------------------------------------------
066
067 /**
068 * Constructs a new CertificateFactorySpi
069 */
070 public CertificateFactorySpi()
071 {}
072
073 // Abstract methods.
074 // ------------------------------------------------------------------------
075
076 /**
077 Generates a Certificate based on the encoded data read
078 from the InputStream.
079
080 The input stream must contain only one certificate.
081
082 If there exists a specialized certificate class for the
083 certificate format handled by the certificate factory
084 then the return Ceritificate should be a typecast of it.
085 Ex: A X.509 CertificateFactory should return X509Certificate.
086
087 For X.509 certificates, the certificate in inStream must be
088 DER encoded and supplied in binary or printable (Base64)
089 encoding. If the certificate is in Base64 encoding, it must be
090 bounded by -----BEGIN CERTIFICATE-----, and
091 -----END CERTIFICATE-----.
092
093 @param inStream an input stream containing the certificate data
094
095 @return a certificate initialized with InputStream data.
096
097 @throws CertificateException Certificate parsing error
098 */
099 public abstract Certificate engineGenerateCertificate(InputStream inStream)
100 throws CertificateException;
101
102 /**
103 Returns a collection of certificates that were read from the
104 input stream. It may be empty, have only one, or have
105 multiple certificates.
106
107 For a X.509 certificate factory, the stream may contain a
108 single DER encoded certificate or a PKCS#7 certificate
109 chain. This is a PKCS#7 <I>SignedData</I> object with the
110 most significant field being <I>certificates</I>. If no
111 CRLs are present, then an empty collection is returned.
112
113 @param inStream an input stream containing the certificates
114
115 @return a collection of certificates initialized with
116 the InputStream data.
117
118 @throws CertificateException Certificate parsing error
119 */
120 public abstract Collection<? extends Certificate> engineGenerateCertificates(InputStream inStream)
121 throws CertificateException;
122
123 /**
124 Generates a CRL based on the encoded data read
125 from the InputStream.
126
127 The input stream must contain only one CRL.
128
129 If there exists a specialized CRL class for the
130 CRL format handled by the certificate factory
131 then the return CRL should be a typecast of it.
132 Ex: A X.509 CertificateFactory should return X509CRL.
133
134 @param inStream an input stream containing the CRL data
135
136 @return a CRL initialized with InputStream data.
137
138 @throws CRLException CRL parsing error
139 */
140 public abstract CRL engineGenerateCRL(InputStream inStream)
141 throws CRLException;
142
143 /**
144 Generates CRLs based on the encoded data read
145 from the InputStream.
146
147 For a X.509 certificate factory, the stream may contain a
148 single DER encoded CRL or a PKCS#7 CRL set. This is a
149 PKCS#7 <I>SignedData</I> object with the most significant
150 field being <I>crls</I>. If no CRLs are present, then an
151 empty collection is returned.
152
153 @param inStream an input stream containing the CRLs
154
155 @return a collection of CRLs initialized with
156 the InputStream data.
157
158 @throws CRLException CRL parsing error
159 */
160 public abstract Collection<? extends CRL> engineGenerateCRLs(InputStream inStream)
161 throws CRLException;
162
163 // 1.4 instance methods.
164 // ------------------------------------------------------------------------
165
166 /**
167 * Generate a {@link CertPath} and initialize it with data parsed from
168 * the input stream. The default encoding of this factory is used.
169 *
170 * @param inStream The InputStream containing the CertPath data.
171 * @return A CertPath initialized from the input stream data.
172 * @throws CertificateException If an error occurs decoding the
173 * CertPath.
174 */
175 public CertPath engineGenerateCertPath(InputStream inStream)
176 throws CertificateException
177 {
178 throw new UnsupportedOperationException("not implemented");
179 }
180
181 /**
182 * Generate a {@link CertPath} and initialize it with data parsed from
183 * the input stream, using the specified encoding.
184 *
185 * @param inStream The InputStream containing the CertPath data.
186 * @param encoding The encoding of the InputStream data.
187 * @return A CertPath initialized from the input stream data.
188 * @throws CertificateException If an error occurs decoding the
189 * CertPath.
190 */
191 public CertPath engineGenerateCertPath(InputStream inStream, String encoding)
192 throws CertificateException
193 {
194 throw new UnsupportedOperationException("not implemented");
195 }
196
197 /**
198 * Generate a {@link CertPath} and initialize it with the certificates
199 * in the {@link java.util.List} argument.
200 *
201 * @param certificates The list of certificates with which to create
202 * the CertPath.
203 * @return A CertPath initialized from the certificates.
204 * @throws CertificateException If an error occurs generating the
205 * CertPath.
206 */
207 public CertPath engineGenerateCertPath(List<? extends Certificate> certificates)
208 throws CertificateException
209 {
210 throw new UnsupportedOperationException("not implemented");
211 }
212
213 /**
214 * Returns an Iterator of CertPath encodings supported by this
215 * factory, with the default encoding first. The returned Iterator
216 * cannot be modified.
217 *
218 * @return The Iterator of supported encodings.
219 */
220 public Iterator<String> engineGetCertPathEncodings()
221 {
222 throw new UnsupportedOperationException("not implemented");
223 }
224 }