The CertificateFactory Class
The CertificateFactory class is an engine class that defines
the functionality of a certificate factory, which is used to generate
certificate and certificate revocation list (CRL) objects from their
encodings.
A certificate factory for X.509 must return certificates that are
an instance of java.security.cert.X509Certificate,
and CRLs that are an instance of java.security.cert.X509CRL.
- Creating a
CertificateFactoryObject - As with all engine classes, the way to get a
CertificateFactoryobject for a particular certificate or CRL type is to call thegetInstancestatic factory method on theCertificateFactoryclass:static CertificateFactory getInstance(String type)Note: The type name is not case-sensitive.A caller can optionally specify the name of a provider or theProviderclass, which will guarantee that the implementation of the certificate factory requested is from the named provider.static CertificateFactory getInstance(String type, String provider) static CertificateFactory getInstance(String type, Provider provider) - Generating Certificate Objects
- To generate a certificate object and initialize it with the data read from an input stream, use the
generateCertificatemethod:final Certificate generateCertificate(InputStream inStream)To return a (possibly empty) collection view of the certificates read from a given input stream, use thegenerateCertificatesmethod:final Collection generateCertificates(InputStream inStream) - Generating CRL Objects
- To generate a certificate revocation list (CRL) object and initialize it with the data read from an input stream, use the
generateCRLmethod:final CRL generateCRL(InputStream inStream)To return a (possibly empty) collection view of the CRLs read from a given input stream, use thegenerateCRLsmethod:final Collection generateCRLs(InputStream inStream) - Generating
CertPathObjects - To generate a
CertPathobject and initialize it with data read from an input stream, use one of the followinggenerateCertPathmethods (with or without specifying the encoding to be used for the data):final CertPath generateCertPath(InputStream inStream) final CertPath generateCertPath(InputStream inStream, String encoding)To generate aCertPathobject and initialize it with a list of certificates, use the following method:final CertPath generateCertPath(List certificates)To retrieve a list of theCertPathencodings supported by this certificate factory, you can call thegetCertPathEncodingsmethod:final Iterator getCertPathEncodings()The default encoding will be listed first.