public class NetscapeCertList
extends java.lang.Object
Netscape uses its own format for disseminating certificate lists, based on a PKCS#7 ContentInfo. The contentType object identifier is netscape-cert-sequence (2.16.840.1.113730.2.5) and the content simply is a sequence of certificates:
CertificateSequence ::= SEQUENCE OF CertificateFor creating a certificate list to be sent just use the empty default constructor and subsequently supply the certificates as array of
X509Certificate
instances. Finally write
the Netscape certificate list DER encoded to a stream, call method
writeTo
, e.g.:
X509Certificate[] certs = ...; NetscapeCertList netscapeCertList = new NetscapeCertList(); netscapeCertList.setCertificateList(certs); OutputStream os = ...; netscapeCertList.writeTo(os);For parsing a DER encoded Netscape Cert List use theor:
NetscapeCertList pkcs7 = new NetscapeCertList(new FileInputStream("certs.p7c")); X509Certificate[] certs = pkcs7.getCertificateList();
NetscapeCertList(InputStream)
constructor:
// the DER encoded Netscape cert list supplied from a stream: InputStream is = ...; NetscapeCertList netscapeCertList = new NetscapeCertList(is); X509Certificate[] certs = netscapeCertList.getCertificateList();
X509Certificate
Constructor and Description |
---|
NetscapeCertList()
Default constructor.
|
NetscapeCertList(java.io.InputStream is)
Creates a
NetscapeCertList from an input stream. |
Modifier and Type | Method and Description |
---|---|
X509Certificate[] |
getCertificateList()
Returns the certificates included in this NetscapeCertList object.
|
void |
setCertificateList(X509Certificate[] certificateList)
Set the certificates for this NetscapeCertList object.
|
byte[] |
toByteArray()
Returns this
NetscapeCertList object as DER encoded byte
array. |
java.lang.String |
toString()
Returns a string giving some information about the contents of this
NetscapeCertList object. |
void |
writeTo(java.io.OutputStream os)
Writes this Netscape certificate chain DER encoded to the given output
stream.
|
public NetscapeCertList()
NetscapeCertList
object.
Use setCertificateList
for
supplying a list of X509Certificates, e.g.:
NetscapeCertList netscapeCertList = new NetscapeCertList(); netscapeCertList.setCertificateList(certs);
public NetscapeCertList(java.io.InputStream is) throws java.io.IOException, PKCSParsingException
NetscapeCertList
from an input stream.
You may use this constructor for "reading in" a certificate list that has
been written to a stream using the writeTo
method, e.g.:
NetscapeCertList netscapeCertList = new NetscapeCertList(...); X509Certificate[] certs = netscapeCertList.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()
NetscapeCertList
object, as array of X509Certificatespublic void setCertificateList(X509Certificate[] certificateList)
certificateList
- the chain of certificates as arraypublic void writeTo(java.io.OutputStream os) throws java.io.IOException
os
- the output stream to which the certificate chain shall be writtenjava.io.IOException
- if an error occurs during writing out the streampublic byte[] toByteArray() throws PKCSException
NetscapeCertList
object as DER encoded byte
array.
NetscapeCertList
object as DER encoded byte arrayPKCSException
- if an encoding error occurspublic java.lang.String toString()
NetscapeCertList
object.toString
in class java.lang.Object