org.mozilla.jss.pkcs12

Class CertBag

Implemented Interfaces:
ASN1Value

public class CertBag
extends java.lang.Object
implements ASN1Value

A PKCS #12 cert bag.

Nested Class Summary

static class
CertBag.Template
A Template class for decoding CertBags from their BER encoding.

Field Summary

static OBJECT_IDENTIFIER
SDSI_CERT_TYPE
static OBJECT_IDENTIFIER
X509_CERT_TYPE

Constructor Summary

CertBag(OBJECT_IDENTIFIER certType, ASN1Value cert)
Creates a CertBag from a type and a cert.

Method Summary

void
encode(OutputStream ostream)
Write this value's DER encoding to an output stream using its own base tag.
void
encode(Tag implicitTag, OutputStream ostream)
Write this value's DER encoding to an output stream using an implicit tag.
ANY
getCert()
Returns the cert field of the CertBag.
OBJECT_IDENTIFIER
getCertType()
Returns the certType field of the CertBag.
ASN1Value
getInterpretedCert()
Returns the cert field of the CertBag based on its type.
Tag
getTag()
Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
static CertBag.Template
getTemplate()

Field Details

SDSI_CERT_TYPE

public static final OBJECT_IDENTIFIER SDSI_CERT_TYPE

X509_CERT_TYPE

public static final OBJECT_IDENTIFIER X509_CERT_TYPE

Constructor Details

CertBag

public CertBag(OBJECT_IDENTIFIER certType,
               ASN1Value cert)
Creates a CertBag from a type and a cert.

Method Details

encode

public void encode(OutputStream ostream)
            throws IOException
Write this value's DER encoding to an output stream using its own base tag.
Specified by:
encode in interface ASN1Value

encode

public void encode(Tag implicitTag,
                   OutputStream ostream)
            throws IOException
Write this value's DER encoding to an output stream using an implicit tag.
Specified by:
encode in interface ASN1Value

getCert

public ANY getCert()
Returns the cert field of the CertBag.

getCertType

public OBJECT_IDENTIFIER getCertType()
Returns the certType field of the CertBag. Currently defined types are:
  • X509Certificate (X509_CERT_TYPE)
  • SDSICertificate (SDSI_CERT_TYPE)

getInterpretedCert

public ASN1Value getInterpretedCert()
            throws InvalidBERException
Returns the cert field of the CertBag based on its type.
  • If the type is X509_CERT_TYPE, returns and OCTET_STRING which is the DER-encoding of an X.509 certificate.
  • If the type is SDSI_CERT_TYPE, returns an IA5String.
  • For all other types, returns an ANY.
Throws:
InvalidBERException - If the cert is not encoded correctly.

getTag

public Tag getTag()
Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
Specified by:
getTag in interface ASN1Value

getTemplate

public static CertBag.Template getTemplate()