Methods Summary |
---|
public java.util.List | getCertificates()Returns the list of certificates in this certification
path. The List returned must be immutable and thread-safe.
TODO: return immutable List
return new ArrayList( certificates );
|
public byte[] | getEncoded()Returns the encoded form of this certification path, using
the default encoding.
Iterator iter = getEncodings();
if ( iter.hasNext() )
{
Object enc = iter.next();
if ( enc instanceof String )
{
return getEncoded((String)enc);
}
}
return null;
|
public byte[] | getEncoded(java.lang.String encoding)Returns the encoded form of this certification path, using
the specified encoding.
TODO: implement PKCS7 decoding
DERObject encoded = null;
if ( encoding.equals("PkiPath") )
{
ASN1EncodableVector v = new ASN1EncodableVector();
// TODO check ListIterator implementation for JDK 1.1
ListIterator iter = certificates.listIterator(certificates.size());
while ( iter.hasPrevious() )
{
v.add(getEncodedX509Certificate((X509Certificate)iter.previous()));
}
encoded = new DERSequence(v);
}
else
throw new CertificateEncodingException( "unsupported encoding" );
if ( encoded == null )
return null;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DEROutputStream derOutStream = new DEROutputStream(outStream);
try {
derOutStream.writeObject( encoded );
derOutStream.close();
} catch ( IOException ex ) {
throw new CertificateEncodingException( "IOExeption thrown: " + ex.toString() );
}
return outStream.toByteArray();
|
private org.bouncycastle.asn1.DERObject | getEncodedX509Certificate(java.security.cert.X509Certificate cert)Return a DERObject containing the encoded certificate.
try {
ByteArrayInputStream inStream = new ByteArrayInputStream( cert.getEncoded() );
DERInputStream derInStream = new DERInputStream( inStream );
return derInStream.readObject();
} catch ( IOException ex ) {
throw new CertificateEncodingException( "IOException caught while encoding certificate\n" + ex.toString() );
}
|
public java.util.Iterator | getEncodings()Returns an iteration of the encodings supported by this
certification path, with the default encoding
first. Attempts to modify the returned Iterator via its
remove method result in an UnsupportedOperationException.
return certPathEncodings.iterator();
|