Class 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 Detail

      • CertificateFactory

        protected CertificateFactory​(CertificateFactorySpi certFacSpi,
                                     Provider provider,
                                     String type)
        Creates a new CertificateFactory instance.
        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 new CertificateFactory instance that provides the requested certificate type.
        Parameters:
        type - the certificate type.
        Returns:
        the new CertificateFactory instance.
        Throws:
        CertificateException - if the specified certificate type is not available at any installed provider.
        NullPointerException - if type == null
      • getInstance

        public static final CertificateFactory getInstance​(String type,
                                                           Provider provider)
                                                    throws CertificateException
        Creates a new CertificateFactory instance from the specified provider that provides the requested certificate type. The provider supplied 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 CertificateFactory instance.
        Throws:
        CertificateException - if the specified certificate type is not available at the specified provider.
        IllegalArgumentException - if the specified provider is null.
        NullPointerException - if type == null
        IllegalArgumentException - if provider == null
      • getProvider

        public final Provider getProvider()
        Returns the Provider of 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 a Certificate from the provided input stream.
        Parameters:
        inStream - the stream from where data is read to create the Certificate.
        Returns:
        an initialized Certificate.
        Throws:
        CertificateException - if parsing problems are detected.
      • getCertPathEncodings

        public final Iterator<String> getCertPathEncodings()
        Returns an Iterator over the supported CertPath encodings (as Strings). The first element is the default encoding scheme to apply.
        Returns:
        an iterator over supported CertPath encodings (as Strings).
      • generateCertPath

        public final CertPath generateCertPath​(InputStream inStream)
                                        throws CertificateException
        Generates a CertPath (a certificate chain) from the provided InputStream. The default encoding scheme is applied.
        Parameters:
        inStream - InputStream with encoded data.
        Returns:
        a CertPath initialized from the provided data.
        Throws:
        CertificateException - if parsing problems are detected.
      • generateCertPath

        public final CertPath generateCertPath​(List<? extends Certificate> certificates)
                                        throws CertificateException
        Generates a CertPath from the provided list of certificates. The encoding is the default encoding.
        Parameters:
        certificates - the list containing certificates in a format supported by the CertificateFactory.
        Returns:
        a CertPath initialized 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.