Android APIs
public class

CertificateFactory

extends Object
java.lang.Object
   ↳ java.security.cert.CertificateFactory

Class Overview

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).

Summary

Protected Constructors
CertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type)
Creates a new CertificateFactory instance.
Public Methods
final CRL generateCRL(InputStream inStream)
Generates and initializes a Certificate Revocation List (CRL) from the provided input stream.
final Collection<? extends CRL> generateCRLs(InputStream inStream)
Generates and initializes a collection of Certificate Revocation List (CRL) from the provided input stream.
final CertPath generateCertPath(InputStream inputStream, String encoding)
Generates a CertPath (a certificate chain) from the given inputStream, assuming the given encoding from getCertPathEncodings().
final CertPath generateCertPath(InputStream inStream)
Generates a CertPath (a certificate chain) from the provided InputStream.
final CertPath generateCertPath(List<? extends Certificate> certificates)
Generates a CertPath from the provided list of certificates.
final Certificate generateCertificate(InputStream inStream)
Generates and initializes a Certificate from the provided input stream.
final Collection<? extends Certificate> generateCertificates(InputStream inStream)
Generates and initializes a collection of (unrelated) certificates from the provided input stream.
final Iterator<String> getCertPathEncodings()
Returns an Iterator over the supported CertPath encodings (as Strings).
final static CertificateFactory getInstance(String type, String provider)
Creates a new CertificateFactory instance from the specified provider that provides the requested certificate type.
final static CertificateFactory getInstance(String type, Provider provider)
Creates a new CertificateFactory instance from the specified provider that provides the requested certificate type.
final static CertificateFactory getInstance(String type)
Creates a new CertificateFactory instance that provides the requested certificate type.
final Provider getProvider()
Returns the Provider of the certificate factory represented by the certificate.
final String getType()
Returns the Certificate type.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected CertificateFactory (CertificateFactorySpi certFacSpi, Provider provider, String type)

Added in API level 1

Creates a new CertificateFactory instance.

Parameters
certFacSpi the implementation delegate.
provider the associated provider.
type the certificate type.

Public Methods

public final CRL generateCRL (InputStream inStream)

Added in API level 1

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.

public final Collection<? extends CRL> generateCRLs (InputStream inStream)

Added in API level 1

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.

public final CertPath generateCertPath (InputStream inputStream, String encoding)

Added in API level 1

Generates a CertPath (a certificate chain) from the given inputStream, assuming the given encoding from getCertPathEncodings().

Throws
CertificateException if parsing problems are detected.
UnsupportedOperationException if the provider does not implement this method.

public final CertPath generateCertPath (InputStream inStream)

Added in API level 1

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.

public final CertPath generateCertPath (List<? extends Certificate> certificates)

Added in API level 1

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.

public final Certificate generateCertificate (InputStream inStream)

Added in API level 1

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.

public final Collection<? extends Certificate> generateCertificates (InputStream inStream)

Added in API level 1

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.

public final Iterator<String> getCertPathEncodings ()

Added in API level 1

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).

public static final CertificateFactory getInstance (String type, String provider)

Added in API level 1

Creates a new CertificateFactory instance 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 CertificateFactory instance.
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 if provider == null || provider.isEmpty()
NullPointerException it type is null.

public static final CertificateFactory getInstance (String type, Provider provider)

Added in API level 1

Creates a new CertificateFactory instance 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 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

public static final CertificateFactory getInstance (String type)

Added in API level 1

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

public final Provider getProvider ()

Added in API level 1

Returns the Provider of the certificate factory represented by the certificate.

Returns
  • the provider of this certificate factory.

public final String getType ()

Added in API level 1

Returns the Certificate type.

Returns
  • type of certificate being used.