1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package java.security.cert; 19 20 import java.io.InputStream; 21 import java.util.Collection; 22 import java.util.Iterator; 23 import java.util.List; 24 25 /** 26 * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the 27 * {@code CertificateFactory} class. This SPI must be implemented for each 28 * certificate type a security provider wishes to support. 29 */ 30 31 public abstract class CertificateFactorySpi { 32 33 /** 34 * Constructs a new instance of this class. 35 */ 36 public CertificateFactorySpi() { 37 } 38 39 /** 40 * Generates and initializes a {@code Certificate} from the provided input 41 * stream. 42 * 43 * @param inStream 44 * the stream from which the data is read to create the 45 * certificate. 46 * @return an initialized certificate. 47 * @throws CertificateException 48 * if parsing problems are detected. 49 */ 50 public abstract Certificate engineGenerateCertificate(InputStream inStream) 51 throws CertificateException; 52 53 /** 54 * Generates and initializes a collection of certificates from the provided 55 * input stream. 56 * 57 * @param inStream 58 * the stream from where data is read to create the certificates. 59 * @return a collection of certificates. 60 * @throws CertificateException 61 * if parsing problems are detected. 62 */ 63 public abstract Collection<? extends Certificate> 64 engineGenerateCertificates(InputStream inStream) throws CertificateException; 65 66 /** 67 * Generates and initializes a <i>Certificate Revocation List</i> (CRL) from 68 * the provided input stream. 69 * 70 * @param inStream 71 * the stream from where data is read to create the CRL. 72 * @return an CRL instance. 73 * @throws CRLException 74 * if parsing problems are detected. 75 */ 76 public abstract CRL engineGenerateCRL(InputStream inStream) 77 throws CRLException; 78 79 /** 80 * Generates and initializes a collection of <i>Certificate Revocation 81 * List</i> (CRL) from the provided input stream. 82 * 83 * @param inStream 84 * the stream from which the data is read to create the CRLs. 85 * @return a collection of CRLs. 86 * @throws CRLException 87 * if parsing problems are detected. 88 */ 89 public abstract Collection<? extends CRL> 90 engineGenerateCRLs(InputStream inStream) throws CRLException; 91 92 /** 93 * Generates a {@code CertPath} from the provided {@code InputStream}. The 94 * default encoding scheme is applied. 95 * 96 * @param inStream 97 * an input stream with encoded data. 98 * @return a {@code CertPath} initialized from the provided data. 99 * @throws CertificateException 100 * if parsing problems are detected. 101 */ 102 public CertPath engineGenerateCertPath(InputStream inStream) 103 throws CertificateException { 104 throw new UnsupportedOperationException(); 105 } 106 107 /** 108 * Generates a {@code CertPath} (a certificate chain) from the given 109 * {@code inputStream}, assuming the given {@code encoding} from 110 * {@link #engineGetCertPathEncodings()}. 111 * 112 * @throws CertificateException 113 * if parsing problems are detected. 114 * @throws UnsupportedOperationException 115 * if the provider does not implement this method. 116 */ 117 public CertPath engineGenerateCertPath(InputStream inStream, String encoding) 118 throws CertificateException { 119 throw new UnsupportedOperationException(); 120 } 121 122 /** 123 * Generates a {@code CertPath} from the provided list of certificates. The 124 * encoding is the default encoding. 125 * 126 * @param certificates 127 * the list containing certificates in a format supported by the 128 * {@code CertificateFactory}. 129 * @return a {@code CertPath} initialized from the provided data. 130 * @throws CertificateException 131 * if parsing problems are detected. 132 * @throws UnsupportedOperationException 133 * if the provider does not implement this method. 134 */ 135 public CertPath engineGenerateCertPath(List<? extends Certificate> certificates) 136 throws CertificateException { 137 throw new UnsupportedOperationException(); 138 } 139 140 /** 141 * Returns an {@code Iterator} over the supported {@code CertPath} encodings 142 * (as Strings). The first element is the default encoding. 143 * 144 * @return an iterator over supported {@code CertPath} encodings (as 145 * Strings). 146 */ 147 public Iterator<String> engineGetCertPathEncodings() { 148 throw new UnsupportedOperationException(); 149 } 150 } 151