public class PKCS7CertList
extends java.lang.Object
implements java.io.Serializable
The PKCS#7 SignedData
content type provides a degenerate case
where there are no signers on the content. It is an intended application of
this degenerate case to be used for disseminating certificates and
certificate-revocation lists.
This class provides several constructors and methods for creating a
SignedData
object only containing a list of X509v3
certificates, writing the list to a file (with extension .p7c
),
and reading it back from the file.
Usage:
X509Certificate[] certs = ...; PKCS7CertList pkcs7 = new PKCS7CertList(); pkcs7.setCertificateList(certs); pkcs7.writeTo(new FileOutputStream(pkcs7File));or:
PKCS7CertList pkcs7 = new PKCS7CertList(new FileInputStream("certs.p7c")); X509Certificate[] certs = pkcs7.getCertificateList();
ContentInfo
,
SignedData
,
X509Certificate
,
Serialized FormConstructor and Description |
---|
PKCS7CertList()
Default constructor.
|
PKCS7CertList(java.io.InputStream is)
Creates a
PKCS7CertList from an input stream. |
Modifier and Type | Method and Description |
---|---|
X509Certificate[] |
getCertificateList()
Returns the certificates included in this PKCS7CertList object.
|
X509CRL[] |
getCRLList()
Returns the CRLs included in this PKCS7CertList object.
|
void |
setCertificateList(X509Certificate[] certificateList)
Set the certificates for this PKCS#7 SignedData object.
|
void |
setCRLList(X509CRL[] crlList)
Set the CRLs for this PKCS#7 SignedData object.
|
byte[] |
toByteArray()
Returns this
PKCS7CertList object as DER encoded byte array. |
java.lang.String |
toString()
Returns a string giving some information about the contents of this
PKCS7CertList object. |
void |
writeTo(java.io.OutputStream os)
Writes the certificate chain to the given output stream.
|
public PKCS7CertList()
PKCS7CertList
object.
Use setCertificateList
for supplying a list of X509Certificates, e.g.:
PKCS7CertList pkcs7 = new PKCS7CertList(); pkcs7.setCertificateList(certs);
public PKCS7CertList(java.io.InputStream is) throws java.io.IOException, PKCSParsingException
PKCS7CertList
from an input stream.
You may use this constructor for "reading in" a certificate list that
has been written to a .p7c file by using the
writeTo
method, e.g.:
PKCS7CertList pkcs7 = new PKCS7CertList(new FileInputStream("certs.p7c")); X509Certificate[] certs = pkcs7.getCertificateList();
is
- the input stream from where the object shall be readjava.io.IOException
- if the object could not be readPKCSParsingException
- if the object could not be parsedpublic X509Certificate[] getCertificateList()
PKCS7CertList
object, as array of X509Certificatespublic X509CRL[] getCRLList()
PKCS7CertList
object, as array of X509CRLspublic void setCertificateList(X509Certificate[] certificateList)
certificateList
- the chain of certificates as arraypublic void setCRLList(X509CRL[] crlList)
crlList
- the list of certificates as arraypublic void writeTo(java.io.OutputStream os) throws java.io.IOException
This method can be used to write the certificate list to a .p7c file, e.g.:
X509Certificate[] certs = ...; PKCS7CertList pkcs7 = new PKCS7CertList(); pkcs7.createCertificateList(certs); pkcs7.writeTo(new FileOutputStream("certs.p7c"));
Use the PKCS7CertList(InputStream is)
for "reading back" the certificate chain from the file.
os
- the output stream to which the certificate chain shall
be writtenjava.io.IOException
- if an error occurs during writing out the filepublic byte[] toByteArray() throws PKCSException
PKCS7CertList
object as DER encoded byte array.
This method DER encodes the ASN.1 representation of this PKCS#7 cert list an writes it to a byte array.
PKCS7CertList
object as DER encoded byte arrayPKCSException
- if an encoding error occurspublic java.lang.String toString()
PKCS7CertList
object.toString
in class java.lang.Object