Top Description Inners Fields Constructors Methods
org.conscrypt

public Class OpenSSLX509CertificateFactory

extends CertificateFactorySpi
Class Inheritance
Annotations
@Internal
Imports
java.io.IOException, .InputStream, .PushbackInputStream, java.security.cert.CRL, .CRLException, .CertPath, .Certificate, .CertificateException, .CertificateFactorySpi, .X509Certificate, java.util.ArrayList, .Arrays, .Collection, .Collections, .Iterator, .List

An implementation of java.security.cert.CertificateFactory based on BoringSSL.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
OpenSSLX509CertificateFactory.Parser<T>

The code for X509 Certificates and CRL is pretty much the same.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private OpenSSLX509CertificateFactory.Parser<OpenSSLX509Certificate>
private OpenSSLX509CertificateFactory.Parser<OpenSSLX509CRL>
private static final byte[]
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Certificate
engineGenerateCertificate(InputStream
an input stream with the certificate data.
inStream
)

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<? extends Certificate>
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<? extends Certificate>
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.
inStream
)

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<? extends CRL>
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<String>
engineGetCertPathEncodings()

Overrides java.security.cert.CertificateFactorySpi.engineGetCertPathEncodings.

Returns an iteration of the CertPath encodings supported by this certificate factory, with the default encoding first.

Field Detail

certificateParserback to summary
private OpenSSLX509CertificateFactory.Parser<OpenSSLX509Certificate> certificateParser
crlParserback to summary
private OpenSSLX509CertificateFactory.Parser<OpenSSLX509CRL> crlParser
PKCS7_MARKERback to summary
private static final byte[] PKCS7_MARKER
PUSHBACK_SIZEback to summary
private static final int PUSHBACK_SIZE

Constructor Detail

OpenSSLX509CertificateFactoryback to summary
public OpenSSLX509CertificateFactory()

Method Detail

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

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

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

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

In order to take advantage of the specialized certificate format supported by this certificate factory, the returned certificate object can be typecast to the corresponding certificate class. For example, if this certificate factory implements X.509 certificates, the returned certificate object can be typecast to the X509Certificate class.

In the case of a certificate factory for X.509 certificates, the certificate provided in inStream must be DER-encoded and may be supplied in binary or printable (Base64) encoding. If the certificate is provided in Base64 encoding, it must be bounded at the beginning by -----BEGIN CERTIFICATE-----, and must be bounded at the end by -----END CERTIFICATE-----.

Note that if the given input stream does not support mark and reset, this method will consume the entire input stream. Otherwise, each call to this method consumes one certificate and the read position of the input stream is positioned to the next available byte after the inherent end-of-certificate marker. If the data in the input stream does not contain an inherent end-of-certificate marker (other than EOF) and there is trailing data after the certificate is parsed, a CertificateException is thrown.

Parameters
inStream:InputStream

an input stream with the certificate data.

Returns:Certificate

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

Annotations
@Override
Exceptions
CertificateException:
on parsing errors.
engineGenerateCertificatesback to summary
public Collection<? extends Certificate> engineGenerateCertificates(InputStream inStream) throws CertificateException

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

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

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

In order to take advantage of the specialized certificate format supported by this certificate factory, each element in the returned collection view can be typecast to the corresponding certificate class. For example, if this certificate factory implements X.509 certificates, the elements in the returned collection can be typecast to the X509Certificate class.

In the case of a certificate factory for X.509 certificates, inStream may contain a single DER-encoded certificate in the formats described for generateCertificate. In addition, inStream may contain a PKCS#7 certificate chain. This is a PKCS#7 SignedData object, with the only significant field being certificates. In particular, the signature and the contents are ignored. This format allows multiple certificates to be downloaded at once. If no certificates are present, an empty collection is returned.

Note that if the given input stream does not support mark and reset, this method will consume the entire input stream.

Parameters
inStream:InputStream

the input stream with the certificates.

Returns:Collection<? extends Certificate>

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

Annotations
@Override
Exceptions
CertificateException:
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

Annotations
@Override
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

Annotations
@Override
Exceptions
CertificateException:
if an exception occurs while decoding or the encoding requested is not supported
engineGenerateCertPathback to summary
public CertPath engineGenerateCertPath(List<? extends Certificate> 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<? extends Certificate>

a List of Certificates

Returns:CertPath

a CertPath initialized with the supplied list of certificates

Annotations
@Override
Exceptions
CertificateException:
if an exception occurs
engineGenerateCRLback to summary
public CRL engineGenerateCRL(InputStream inStream) throws CRLException

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

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

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

In order to take advantage of the specialized CRL format supported by this certificate factory, the returned CRL object can be typecast to the corresponding CRL class. For example, if this certificate factory implements X.509 CRLs, the returned CRL object can be typecast to the X509CRL class.

Note that if the given input stream does not support mark and reset, this method will consume the entire input stream. Otherwise, each call to this method consumes one CRL and the read position of the input stream is positioned to the next available byte after the inherent end-of-CRL marker. If the data in the input stream does not contain an inherent end-of-CRL marker (other than EOF) and there is trailing data after the CRL is parsed, a CRLException is thrown.

Parameters
inStream:InputStream

an input stream with the CRL data.

Returns:CRL

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

Annotations
@Override
Exceptions
CRLException:
on parsing errors.
engineGenerateCRLsback to summary
public Collection<? extends CRL> engineGenerateCRLs(InputStream inStream) throws CRLException

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

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

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

In order to take advantage of the specialized CRL format supported by this certificate factory, each element in the returned collection view can be typecast to the corresponding CRL class. For example, if this certificate factory implements X.509 CRLs, the elements in the returned collection can be typecast to the X509CRL class.

In the case of a certificate factory for X.509 CRLs, inStream may contain a single DER-encoded CRL. In addition, inStream may contain a PKCS#7 CRL set. This is a PKCS#7 SignedData object, with the only significant field being crls. In particular, the signature and the contents are ignored. This format allows multiple CRLs to be downloaded at once. If no CRLs are present, an empty collection is returned.

Note that if the given input stream does not support mark and reset, this method will consume the entire input stream.

Parameters
inStream:InputStream

the input stream with the CRLs.

Returns:Collection<? extends CRL>

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

Annotations
@Override
Exceptions
CRLException:
on parsing errors.
engineGetCertPathEncodingsback to summary
public Iterator<String> 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<String>

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

Annotations
@Override
org.conscrypt back to summary

private abstract Class OpenSSLX509CertificateFactory.Parser<T>

extends Object
Class Inheritance

The code for X509 Certificates and CRL is pretty much the same. We use this abstract class to share the code between them. This makes it ugly, but it's already written in this language anyway.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected abstract List<? extends T>
protected abstract List<? extends T>
protected abstract T
protected abstract T
pack-priv T
pack-priv Collection<? extends T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Parserback to summary
private Parser()

Method Detail

fromPkcs7DerInputStreamback to summary
protected abstract List<? extends T> fromPkcs7DerInputStream(InputStream is) throws ParsingException
fromPkcs7PemInputStreamback to summary
protected abstract List<? extends T> fromPkcs7PemInputStream(InputStream is) throws ParsingException
fromX509DerInputStreamback to summary
protected abstract T fromX509DerInputStream(InputStream pbis) throws ParsingException
fromX509PemInputStreamback to summary
protected abstract T fromX509PemInputStream(InputStream pbis) throws ParsingException
generateItemback to summary
pack-priv T generateItem(InputStream inStream) throws ParsingException
generateItemsback to summary
pack-priv Collection<? extends T> generateItems(InputStream inStream) throws ParsingException
org.conscrypt back to summary

pack-priv Class OpenSSLX509CertificateFactory.ParsingException

extends Exception
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
pack-priv

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

ParsingExceptionback to summary
pack-priv ParsingException(String message)
ParsingExceptionback to summary
pack-priv ParsingException(Exception cause)
ParsingExceptionback to summary
pack-priv ParsingException(String message, Exception cause)