Top Description Inners Fields Constructors Methods
org.bouncycastle.jcajce.provider.asymmetric.x509

public Class CertificateFactory

extends CertificateFactorySpi
Class Inheritance
Imports
java.io.BufferedInputStream, .ByteArrayInputStream, .IOException, .InputStream, java.security.cert.CRL, .CRLException, .CertPath, .CertificateException, .CertificateFactorySpi, .CertificateParsingException, .X509Certificate, java.util.ArrayList, .Collection, .Iterator, .List, org.bouncycastle.asn1.ASN1InputStream, .ASN1ObjectIdentifier, .ASN1Sequence, .ASN1Set, .ASN1TaggedObject, org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers, .SignedData, org.bouncycastle.asn1.x509.Certificate, .CertificateList, org.bouncycastle.jcajce.util.BCJcaJceHelper, .JcaJceHelper, org.bouncycastle.util.io.Streams

class for dealing with X509 certificates.

At the moment this will deal with "-----BEGIN CERTIFICATE-----" to "-----END CERTIFICATE-----" base 64 encoded certs, as well as the BER binaries of certificates and some classes of PKCS#7 objects.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final JcaJceHelper
private InputStream
private InputStream
private static final PEMUtil
private static final PEMUtil
private static final PEMUtil
private ASN1Set
private int
private ASN1Set
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected CRL
private Certificate
doGenerateCertificate(InputStream in, boolean isFirst)

private CRL
doGenerateCRL(InputStream in, boolean isFirst)

Generates a certificate revocation list (CRL) object and initializes it with the data read from the input stream inStream.

public Certificate
engineGenerateCertificate(InputStream
an input stream with the certificate data.
in
)

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCertificate.

Generates a certificate object and initializes it with the data read from the input stream inStream.
public Collection<E>
engineGenerateCertificates(InputStream
the input stream with the certificates.
inStream
)

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCertificates.

Returns a (possibly empty) collection view of the certificates read from the given input stream inStream.
public CertPath
engineGenerateCertPath(InputStream
an InputStream containing the data
inStream
)

Overrides java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Generates a CertPath object and initializes it with the data read from the InputStream inStream.
public CertPath
engineGenerateCertPath(InputStream
an InputStream containing the data
inStream
,
String
the encoding used for the data
encoding
)

Overrides java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Generates a CertPath object and initializes it with the data read from the InputStream inStream.
public CertPath
engineGenerateCertPath(List<E>
a List of Certificates
certificates
)

Overrides java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Generates a CertPath object and initializes it with a List of Certificates.
public CRL
engineGenerateCRL(InputStream
an input stream with the CRL data.
in
)

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCRL.

Generates a certificate revocation list (CRL) object and initializes it with the data read from the input stream inStream.
public Collection<E>
engineGenerateCRLs(InputStream
the input stream with the CRLs.
inStream
)

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCRLs.

Returns a (possibly empty) collection view of the CRLs read from the given input stream inStream.
public Iterator<E>
engineGetCertPathEncodings()

Overrides java.security.cert.CertificateFactorySpi.engineGetCertPathEncodings.

Returns an iteration of the CertPath encodings supported by this certificate factory, with the default encoding first.
private Certificate
private Certificate
private CRL
private CRL
private Certificate
private CRL
private Certificate
readPEMCertificate(InputStream in, boolean isFirst)

private CRL
readPEMCRL(InputStream in, boolean isFirst)

Field Detail

bcHelperback to summary
private final JcaJceHelper bcHelper
currentCrlStreamback to summary
private InputStream currentCrlStream
currentStreamback to summary
private InputStream currentStream
PEM_CERT_PARSERback to summary
private static final PEMUtil PEM_CERT_PARSER
PEM_CRL_PARSERback to summary
private static final PEMUtil PEM_CRL_PARSER
PEM_PKCS7_PARSERback to summary
private static final PEMUtil PEM_PKCS7_PARSER
sCrlDataback to summary
private ASN1Set sCrlData
sCrlDataObjectCountback to summary
private int sCrlDataObjectCount
sDataback to summary
private ASN1Set sData
sDataObjectCountback to summary
private int sDataObjectCount

Constructor Detail

CertificateFactoryback to summary
public CertificateFactory()

Method Detail

createCRLback to summary
protected CRL createCRL(CertificateList c) throws CRLException
doGenerateCertificateback to summary
private Certificate doGenerateCertificate(InputStream in, boolean isFirst) throws CertificateException
doGenerateCRLback to summary
private CRL doGenerateCRL(InputStream in, boolean isFirst) throws CRLException

Generates a certificate revocation list (CRL) object and initializes it with the data read from the input stream inStream.

engineGenerateCertificateback to summary
public Certificate engineGenerateCertificate(InputStream in) throws CertificateException

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCertificate.

Generates a certificate object and initializes it with the data read from the input stream inStream.

Parameters
in:InputStream

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertificate.

an input stream with the certificate data.

Returns:Certificate

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertificate.

a certificate object initialized with the data from the input stream.

Exceptions
CertificateException:

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertificate.

on parsing errors.

engineGenerateCertificatesback to summary
public Collection<E> engineGenerateCertificates(InputStream inStream) throws CertificateException

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCertificates.

Returns a (possibly empty) collection view of the certificates read from the given input stream inStream.

Parameters
inStream:InputStream

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertificates.

the input stream with the certificates.

Returns:Collection<E>

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertificates.

a (possibly empty) collection view of java.security.cert.Certificate objects initialized with the data from the input stream.

Exceptions
CertificateException:

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertificates.

on parsing errors.

engineGenerateCertPathback to summary
public CertPath engineGenerateCertPath(InputStream inStream) throws CertificateException

Overrides java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Generates a CertPath object and initializes it with the data read from the InputStream inStream. The data is assumed to be in the default encoding.

This method was added to version 1.4 of the Java 2 Platform Standard Edition. In order to maintain backwards compatibility with existing service providers, this method cannot be abstract and by default throws an UnsupportedOperationException.

Parameters
inStream:InputStream

an InputStream containing the data

Returns:CertPath

a CertPath initialized with the data from the InputStream

Exceptions
CertificateException:
if an exception occurs while decoding
engineGenerateCertPathback to summary
public CertPath engineGenerateCertPath(InputStream inStream, String encoding) throws CertificateException

Overrides java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Generates a CertPath object and initializes it with the data read from the InputStream inStream. The data is assumed to be in the specified encoding.

This method was added to version 1.4 of the Java 2 Platform Standard Edition. In order to maintain backwards compatibility with existing service providers, this method cannot be abstract and by default throws an UnsupportedOperationException.

Parameters
inStream:InputStream

an InputStream containing the data

encoding:String

the encoding used for the data

Returns:CertPath

a CertPath initialized with the data from the InputStream

Exceptions
CertificateException:
if an exception occurs while decoding or the encoding requested is not supported
engineGenerateCertPathback to summary
public CertPath engineGenerateCertPath(List<E> certificates) throws CertificateException

Overrides java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCertPath.

Generates a CertPath object and initializes it with a List of Certificates.

The certificates supplied must be of a type supported by the CertificateFactory. They will be copied out of the supplied List object.

This method was added to version 1.4 of the Java 2 Platform Standard Edition. In order to maintain backwards compatibility with existing service providers, this method cannot be abstract and by default throws an UnsupportedOperationException.

Parameters
certificates:List<E>

a List of Certificates

Returns:CertPath

a CertPath initialized with the supplied list of certificates

Exceptions
CertificateException:
if an exception occurs
engineGenerateCRLback to summary
public CRL engineGenerateCRL(InputStream in) throws CRLException

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCRL.

Generates a certificate revocation list (CRL) object and initializes it with the data read from the input stream inStream.

Parameters
in:InputStream

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCRL.

an input stream with the CRL data.

Returns:CRL

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCRL.

a CRL object initialized with the data from the input stream.

Exceptions
CRLException:

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCRL.

on parsing errors.

engineGenerateCRLsback to summary
public Collection<E> engineGenerateCRLs(InputStream inStream) throws CRLException

Implements abstract java.security.cert.CertificateFactorySpi.engineGenerateCRLs.

Returns a (possibly empty) collection view of the CRLs read from the given input stream inStream. The inStream may contain a sequence of DER-encoded CRLs, or a PKCS#7 CRL set. This is a PKCS#7 SignedData object, with the only signficant field being crls. In particular the signature and the contents are ignored.

Parameters
inStream:InputStream

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCRLs.

the input stream with the CRLs.

Returns:Collection<E>

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCRLs.

a (possibly empty) collection view of java.security.cert.CRL objects initialized with the data from the input stream.

Exceptions
CRLException:

Doc from java.security.cert.CertificateFactorySpi.engineGenerateCRLs.

on parsing errors.

engineGetCertPathEncodingsback to summary
public Iterator<E> engineGetCertPathEncodings()

Overrides java.security.cert.CertificateFactorySpi.engineGetCertPathEncodings.

Doc from java.security.cert.CertificateFactorySpi.engineGetCertPathEncodings.

Returns an iteration of the CertPath encodings supported by this certificate factory, with the default encoding first. See the CertPath Encodings section in the Java Security Standard Algorithm Names Specification for information about standard encoding names.

Attempts to modify the returned Iterator via its remove method result in an UnsupportedOperationException.

This method was added to version 1.4 of the Java 2 Platform Standard Edition. In order to maintain backwards compatibility with existing service providers, this method cannot be abstract and by default throws an UnsupportedOperationException.

Returns:Iterator<E>

an Iterator over the names of the supported CertPath encodings (as Strings)

getCertificateback to summary
private Certificate getCertificate(ASN1Sequence seq) throws CertificateParsingException
getCertificateback to summary
private Certificate getCertificate() throws CertificateParsingException
getCRLback to summary
private CRL getCRL(ASN1Sequence seq) throws CRLException
getCRLback to summary
private CRL getCRL() throws CRLException
readDERCertificateback to summary
private Certificate readDERCertificate(ASN1InputStream dIn) throws IOException, CertificateParsingException
readDERCRLback to summary
private CRL readDERCRL(ASN1InputStream aIn) throws IOException, CRLException
readPEMCertificateback to summary
private Certificate readPEMCertificate(InputStream in, boolean isFirst) throws IOException, CertificateParsingException
readPEMCRLback to summary
private CRL readPEMCRL(InputStream in, boolean isFirst) throws IOException, CRLException
org.bouncycastle.jcajce.provider.asymmetric.x509 back to summary

private Class CertificateFactory.ExCertificateException

extends CertificateException
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Throwable

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Throwable
getCause()

Overrides java.lang.Throwable.getCause.

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Field Detail

causeback to summary
private Throwable cause

Hides java.lang.Throwable.cause.

Constructor Detail

ExCertificateExceptionback to summary
public ExCertificateException(Throwable cause)
ExCertificateExceptionback to summary
public ExCertificateException(String msg, Throwable cause)

Method Detail

getCauseback to summary
public Throwable getCause()

Overrides java.lang.Throwable.getCause.

Doc from java.lang.Throwable.getCause.

Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.)

This implementation returns the cause that was supplied via one of the constructors requiring a Throwable, or that was set after creation with the initCause(Throwable) method. While it is typically unnecessary to override this method, a subclass can override it to return a cause set by some other means. This is appropriate for a "legacy chained throwable" that predates the addition of chained exceptions to Throwable. Note that it is not necessary to override any of the PrintStackTrace methods, all of which invoke the getCause method to determine the cause of a throwable.

Returns:Throwable

the cause of this throwable or null if the cause is nonexistent or unknown.