∟Using CertificateFactory Class to Read in Certificates
This section provides a tutorial example on how to write a sample program to read in certificate files with the java.security.cert.CertificateFactory class.
java.security.cert.CertificateFactory is a class to read in different types
of certificates from certificate files.
getIntance() - Returns a CertificateFactory object of the specified certificate type
using the implementation of the specified security package provider. If not specified,
the default provider will used.
generateCertificate() - Read in a certificate from the specified input stream,
and returns it as a Certificate object. It can read certificate in both binary
(DER encoded) and printable (RFC standard) formats. Note that only the first certificate
in the input stream will be processed.
generateCertificates() - Read in multiple certificates from the specified input stream,
and returns them as a Certificate array. It can read certificate in both binary
(DER encoded) and printable (RFC standard) formats.
getType() - Returns the type of this certificate factory.
getProvider() - Returns the security package provider.
In the following sample program, I want to show you how to read in a certificate
from a certificate file, and write it out to a certificate file in the default encoding
format.