iaik.pkcs
Class NetscapeCertList

java.lang.Object
  |
  +--iaik.pkcs.NetscapeCertList

public class NetscapeCertList
extends Object

This class implements the Netscape Certificate Sequence format.

Netscape uses its own format for disseminating certificate lists, based on a PKCS#7 ContentInfo. The contentType object identifer is netscape-cert-sequence (2.16.840.1.113730.2.5) and the content simply is a sequence of certificates:

 CertificateSequence ::= SEQUENCE OF Certificate
 
For 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);
  

or:

NetscapeCertList pkcs7 = new NetscapeCertList(new FileInputStream("certs.p7c")); X509Certificate[] certs = pkcs7.getCertificateList();

For parsing a DER encoded Netscape Cert List use the NetscapeCertList(InputStream) constructor:
 // the DER encoded Netscape cert list supplied from a stream:
 InputStream is = ...;
 NetscapeCertList netscapeCertList = new NetscapeCertList(is);
 X509Certificate[] certs = netscapeCertList.getCertificateList();
 

Version:
File Revision 10
See Also:
X509Certificate

Constructor Summary
NetscapeCertList()
          Default constructor.
NetscapeCertList(InputStream is)
          Creates a NetscapeCertList from an input stream.
 
Method Summary
 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.
 String toString()
          Returns a string giving some information about the contents of this NetscapeCertList object.
 void writeTo(OutputStream os)
          Writes this Netscape certificate chain DER encoded to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetscapeCertList

public NetscapeCertList()
Default constructor. Creates an empty NetscapeCertList object.

Use setCertificateList for supplying a list of X509Certificates, e.g.:

 NetscapeCertList netscapeCertList = new NetscapeCertList();
 netscapeCertList.setCertificateList(certs);
 


NetscapeCertList

public NetscapeCertList(InputStream is)
                 throws IOException,
                        PKCSParsingException
Creates a 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();
 

Parameters:
is - the input stream from where the object shall be read
Throws:
IOException - if the object could not be read
PKCSParsingException - if the object could not be parsed
Method Detail

getCertificateList

public X509Certificate[] getCertificateList()
Returns the certificates included in this NetscapeCertList object.
Returns:
the certificates included in this NetscapeCertList object, as array of X509Certificates

setCertificateList

public void setCertificateList(X509Certificate[] certificateList)
Set the certificates for this NetscapeCertList object.
Parameters:
certificateList - the chain of certificates as array

writeTo

public void writeTo(OutputStream os)
             throws IOException
Writes this Netscape certificate chain DER encoded to the given output stream.
Parameters:
os - the output stream to which the certificate chain shall be written
Throws:
IOException - if an error occurs during writing out the stream

toByteArray

public byte[] toByteArray()
                   throws PKCSException
Returns this NetscapeCertList object as DER encoded byte array.

Returns:
this NetscapeCertList object as DER encoded byte array
Throws:
PKCSException - if an encoding error occurs

toString

public String toString()
Returns a string giving some information about the contents of this NetscapeCertList object.
Overrides:
toString in class Object
Returns:
the string representation

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK