Frames | No Frames |
1: /* CertificateFactorySpi.java --- Certificate Factory Class 2: Copyright (C) 1999,2003 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package java.security.cert; 40: 41: import java.io.InputStream; 42: 43: import java.util.Collection; 44: import java.util.Iterator; 45: import java.util.List; 46: 47: /** 48: CertificateFactorySpi is the abstract class Service Provider 49: Interface (SPI) for the CertificateFactory class. A provider 50: must implement all the abstract methods if they wish to 51: supply a certificate factory for a particular certificate 52: type. Ex: X.509 53: 54: Certificate factories are used to generate certificates and 55: certificate revocation lists (CRL) from their encoding. 56: 57: @since 1.2 58: 59: @author Mark Benvenuto 60: */ 61: public abstract class CertificateFactorySpi 62: { 63: 64: // Constructor. 65: // ------------------------------------------------------------------------ 66: 67: /** 68: * Constructs a new CertificateFactorySpi 69: */ 70: public CertificateFactorySpi() 71: {} 72: 73: // Abstract methods. 74: // ------------------------------------------------------------------------ 75: 76: /** 77: Generates a Certificate based on the encoded data read 78: from the InputStream. 79: 80: The input stream must contain only one certificate. 81: 82: If there exists a specialized certificate class for the 83: certificate format handled by the certificate factory 84: then the return Ceritificate should be a typecast of it. 85: Ex: A X.509 CertificateFactory should return X509Certificate. 86: 87: For X.509 certificates, the certificate in inStream must be 88: DER encoded and supplied in binary or printable (Base64) 89: encoding. If the certificate is in Base64 encoding, it must be 90: bounded by -----BEGIN CERTIFICATE-----, and 91: -----END CERTIFICATE-----. 92: 93: @param inStream an input stream containing the certificate data 94: 95: @return a certificate initialized with InputStream data. 96: 97: @throws CertificateException Certificate parsing error 98: */ 99: 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: }