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
CertificateFactory
Object - As with all engine classes, the way to get a
CertificateFactory
object for a particular certificate or CRL type is to call thegetInstance
static factory method on theCertificateFactory
class:static CertificateFactory getInstance(String type)
Note: The type name is not case-sensitive.A caller can optionally specify the name of a provider or theProvider
class, 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
generateCertificate
method:final Certificate generateCertificate(InputStream inStream)
To return a (possibly empty) collection view of the certificates read from a given input stream, use thegenerateCertificates
method: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
generateCRL
method:final CRL generateCRL(InputStream inStream)
To return a (possibly empty) collection view of the CRLs read from a given input stream, use thegenerateCRLs
method:final Collection generateCRLs(InputStream inStream)
- Generating
CertPath
Objects - To generate a
CertPath
object and initialize it with data read from an input stream, use one of the followinggenerateCertPath
methods (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 aCertPath
object and initialize it with a list of certificates, use the following method:final CertPath generateCertPath(List certificates)
To retrieve a list of theCertPath
encodings supported by this certificate factory, you can call thegetCertPathEncodings
method:final Iterator getCertPathEncodings()
The default encoding will be listed first.