1 7 8 package java.security.cert; 9 10 import java.io.InputStream ; 11 import java.util.Collection ; 12 import java.util.Iterator ; 13 import java.util.List ; 14 import java.security.Provider ; 15 import java.security.AccessController ; 16 import java.security.PrivilegedAction ; 17 import java.security.NoSuchAlgorithmException ; 18 import java.security.NoSuchProviderException ; 19 20 import sun.security.jca.*; 21 import sun.security.jca.GetInstance.Instance; 22 23 89 90 public class CertificateFactory { 91 92 private String type; 94 95 private Provider provider; 97 98 private CertificateFactorySpi certFacSpi; 100 101 109 protected CertificateFactory(CertificateFactorySpi certFacSpi, 110 Provider provider, String type) 111 { 112 this.certFacSpi = certFacSpi; 113 this.provider = provider; 114 this.type = type; 115 } 116 117 138 public static final CertificateFactory getInstance(String type) 139 throws CertificateException { 140 try { 141 Instance instance = GetInstance.getInstance("CertificateFactory", 142 CertificateFactorySpi .class, type); 143 return new CertificateFactory ((CertificateFactorySpi )instance.impl, 144 instance.provider, type); 145 } catch (NoSuchAlgorithmException e) { 146 throw new CertificateException (type + " not found", e); 147 } 148 } 149 150 167 public static final CertificateFactory getInstance(String type, 168 String provider) throws CertificateException , 169 NoSuchProviderException { 170 try { 171 Instance instance = GetInstance.getInstance("CertificateFactory", 172 CertificateFactorySpi .class, type, provider); 173 return new CertificateFactory ((CertificateFactorySpi )instance.impl, 174 instance.provider, type); 175 } catch (NoSuchAlgorithmException e) { 176 throw new CertificateException (type + " not found", e); 177 } 178 } 179 180 200 public static final CertificateFactory getInstance(String type, 201 Provider provider) throws CertificateException { 202 try { 203 Instance instance = GetInstance.getInstance("CertificateFactory", 204 CertificateFactorySpi .class, type, provider); 205 return new CertificateFactory ((CertificateFactorySpi )instance.impl, 206 instance.provider, type); 207 } catch (NoSuchAlgorithmException e) { 208 throw new CertificateException (type + " not found", e); 209 } 210 } 211 212 217 public final Provider getProvider() { 218 return this.provider; 219 } 220 221 228 public final String getType() { 229 return this.type; 230 } 231 232 268 public final Certificate generateCertificate(InputStream inStream) 269 throws CertificateException 270 { 271 return certFacSpi.engineGenerateCertificate(inStream); 272 } 273 274 290 public final Iterator <String > getCertPathEncodings() { 291 return(certFacSpi.engineGetCertPathEncodings()); 292 } 293 294 307 public final CertPath generateCertPath(InputStream inStream) 308 throws CertificateException 309 { 310 return(certFacSpi.engineGenerateCertPath(inStream)); 311 } 312 313 329 public final CertPath generateCertPath(InputStream inStream, 330 String encoding) throws CertificateException 331 { 332 return(certFacSpi.engineGenerateCertPath(inStream, encoding)); 333 } 334 335 349 public final CertPath 350 generateCertPath(List <? extends Certificate > certificates) 351 throws CertificateException 352 { 353 return(certFacSpi.engineGenerateCertPath(certificates)); 354 } 355 356 391 public final Collection <? extends Certificate > generateCertificates 392 (InputStream inStream) throws CertificateException { 393 return certFacSpi.engineGenerateCertificates(inStream); 394 } 395 396 425 public final CRL generateCRL(InputStream inStream) 426 throws CRLException 427 { 428 return certFacSpi.engineGenerateCRL(inStream); 429 } 430 431 464 public final Collection <? extends CRL > generateCRLs(InputStream inStream) 465 throws CRLException { 466 return certFacSpi.engineGenerateCRLs(inStream); 467 } 468 } 469 | Popular Tags |