Package java.security.cert
Class CertificateFactory
- java.lang.Object
-
- java.security.cert.CertificateFactory
-
public class CertificateFactory extends Object
This class implements the functionality of a certificate factory algorithm, relying on parsing a stream of bytes.It defines methods for parsing certificate chains (certificate paths) and Certificate Revocation Lists (CRLs).
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type)Creates a newCertificateFactoryinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CertificategenerateCertificate(InputStream inStream)Generates and initializes aCertificatefrom the provided input stream.Collection<? extends Certificate>generateCertificates(InputStream inStream)Generates and initializes a collection of (unrelated) certificates from the provided input stream.CertPathgenerateCertPath(InputStream inStream)Generates aCertPath(a certificate chain) from the providedInputStream.CertPathgenerateCertPath(InputStream inputStream, String encoding)Generates aCertPath(a certificate chain) from the giveninputStream, assuming the givenencodingfromgetCertPathEncodings().CertPathgenerateCertPath(List<? extends Certificate> certificates)Generates aCertPathfrom the provided list of certificates.CRLgenerateCRL(InputStream inStream)Generates and initializes a Certificate Revocation List (CRL) from the provided input stream.Collection<? extends CRL>generateCRLs(InputStream inStream)Generates and initializes a collection of Certificate Revocation List (CRL) from the provided input stream.Iterator<String>getCertPathEncodings()Returns anIteratorover the supportedCertPathencodings (as Strings).static CertificateFactorygetInstance(String type)Creates a newCertificateFactoryinstance that provides the requested certificate type.static CertificateFactorygetInstance(String type, String provider)Creates a newCertificateFactoryinstance from the specified provider that provides the requested certificate type.static CertificateFactorygetInstance(String type, Provider provider)Creates a newCertificateFactoryinstance from the specified provider that provides the requested certificate type.ProvidergetProvider()Returns theProviderof the certificate factory represented by the certificate.StringgetType()Returns the Certificate type.
-
-
-
Constructor Detail
-
CertificateFactory
protected CertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type)
Creates a newCertificateFactoryinstance.- Parameters:
certFacSpi- the implementation delegate.provider- the associated provider.type- the certificate type.
-
-
Method Detail
-
getInstance
public static final CertificateFactory getInstance(String type) throws CertificateException
Creates a newCertificateFactoryinstance that provides the requested certificate type.- Parameters:
type- the certificate type.- Returns:
- the new
CertificateFactoryinstance. - Throws:
CertificateException- if the specified certificate type is not available at any installed provider.NullPointerException- iftype == null
-
getInstance
public static final CertificateFactory getInstance(String type, String provider) throws CertificateException, NoSuchProviderException
Creates a newCertificateFactoryinstance from the specified provider that provides the requested certificate type.- Parameters:
type- the certificate type.provider- the name of the provider providing certificates of the specified type.- Returns:
- the new
CertificateFactoryinstance. - Throws:
CertificateException- if the specified certificate type is not available by the specified provider.NoSuchProviderException- if no provider with the specified name can be found.IllegalArgumentException- ifprovider == null || provider.isEmpty()NullPointerException- ittypeisnull.
-
getInstance
public static final CertificateFactory getInstance(String type, Provider provider) throws CertificateException
Creates a newCertificateFactoryinstance from the specified provider that provides the requested certificate type. Theprovidersupplied does not have to be registered.- Parameters:
type- the certificate type.provider- the name of the provider providing certificates of the specified type.- Returns:
- the new
CertificateFactoryinstance. - Throws:
CertificateException- if the specified certificate type is not available at the specified provider.IllegalArgumentException- if the specified provider isnull.NullPointerException- iftype == nullIllegalArgumentException- ifprovider == null
-
getProvider
public final Provider getProvider()
Returns theProviderof the certificate factory represented by the certificate.- Returns:
- the provider of this certificate factory.
-
getType
public final String getType()
Returns the Certificate type.- Returns:
- type of certificate being used.
-
generateCertificate
public final Certificate generateCertificate(InputStream inStream) throws CertificateException
Generates and initializes aCertificatefrom the provided input stream.- Parameters:
inStream- the stream from where data is read to create theCertificate.- Returns:
- an initialized Certificate.
- Throws:
CertificateException- if parsing problems are detected.
-
getCertPathEncodings
public final Iterator<String> getCertPathEncodings()
Returns anIteratorover the supportedCertPathencodings (as Strings). The first element is the default encoding scheme to apply.- Returns:
- an iterator over supported
CertPathencodings (as Strings).
-
generateCertPath
public final CertPath generateCertPath(InputStream inStream) throws CertificateException
Generates aCertPath(a certificate chain) from the providedInputStream. The default encoding scheme is applied.- Parameters:
inStream-InputStreamwith encoded data.- Returns:
- a
CertPathinitialized from the provided data. - Throws:
CertificateException- if parsing problems are detected.
-
generateCertPath
public final CertPath generateCertPath(InputStream inputStream, String encoding) throws CertificateException
Generates aCertPath(a certificate chain) from the giveninputStream, assuming the givenencodingfromgetCertPathEncodings().- Throws:
CertificateException- if parsing problems are detected.UnsupportedOperationException- if the provider does not implement this method.
-
generateCertPath
public final CertPath generateCertPath(List<? extends Certificate> certificates) throws CertificateException
Generates aCertPathfrom the provided list of certificates. The encoding is the default encoding.- Parameters:
certificates- the list containing certificates in a format supported by theCertificateFactory.- Returns:
- a
CertPathinitialized from the provided data. - Throws:
CertificateException- if parsing problems are detected.UnsupportedOperationException- if the provider does not implement this method.
-
generateCertificates
public final Collection<? extends Certificate> generateCertificates(InputStream inStream) throws CertificateException
Generates and initializes a collection of (unrelated) certificates from the provided input stream.- Parameters:
inStream- the stream from which the data is read to create the collection.- Returns:
- an initialized collection of certificates.
- Throws:
CertificateException- if parsing problems are detected.
-
generateCRL
public final CRL generateCRL(InputStream inStream) throws CRLException
Generates and initializes a Certificate Revocation List (CRL) from the provided input stream.- Parameters:
inStream- the stream from where data is read to create the CRL.- Returns:
- an initialized CRL.
- Throws:
CRLException- if parsing problems are detected.
-
generateCRLs
public final Collection<? extends CRL> generateCRLs(InputStream inStream) throws CRLException
Generates and initializes a collection of Certificate Revocation List (CRL) from the provided input stream.- Parameters:
inStream- the stream from which the data is read to create the CRLs.- Returns:
- an initialized collection of CRLs.
- Throws:
CRLException- if parsing problems are detected.
-
-