|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.CertificateChoices
public class CertificateChoices
This class implements the CMS type CertificateChoices. The Cryptographic
Message Syntax (CMS) (RFC 5652) specifies the CertificateChoices type for
modeling several certificate types to maybe included into a
CertificateSet
:
CertificateSet ::= SET OF CertificateChoicesWhen
CertificateChoices ::= CHOICE { certificate Certificate, -- see X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete; see PKCS#6 v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete; see X.509-1997 v2AttrCert [2] IMPLICIT AttributeCertificateV2, -- see X509-2000 other [3] IMPLICIT OtherCertificateFormat } OtherCertificateFormat ::= SEQUENCE { otherCertFormat OBJECT IDENTIFIER, otherCert ANY DEFINED BY otherCertFormat } CertificateSet ::= SET OF CertificateChoices
creating
a CertificateChoices
object the certificate has to be given as X.509 public key certificate
(instance of iaik.x509.X509Certificate
), X.509 attribute
certificate (instance of iaik.x509.attr.AttributeCertificate
) or
other certificate (instance of iaik.cms.OtherCertificate
);
PKCS#6 extended certificates are obsolete and therefore not supported, e.g.:
CertificateSet certSet = new CertificateSet(); X509Certificate x509Cert = ...; certSet.addCertificateChoices(new CertificateChoices(x509Cert)); AttributeCertificate attCert = ...; certSet.addCertificateChoices(new CertificateChoices(attCert)); OtherCertificate otherCert = ...; certSet.addCertificateChoices(new CertificateChoices(otherCert));Note that it might be more convenient to
add
the certificate
immediately to the CertificateSet without prior wrapping it into a
CertificateChoices object:
CertificateSet certSet = new CertificateSet(); X509Certificate x509Cert = ...; certSet.addCertificate(x509Cert); AttributeCertificate attCert = ...; certSet.addCertificate(attCert); OtherCertificate otherCert = ...; certSet.addCertificate(otherCert);Using CertificateChoices maybe of more interest on the parsing side when getting the CertificateChoices from a CertificateSet to obtain their (original, parsed) encoding:
CertificateSet certSet = ...; CertificateChoices[] certificateChoices = certSet.getCertificateChoices(); for (int i = 0; i < certificateChoices.length; i++) { byte[] encodedCertificateChoices = certificateChoices[i].getEncoded(); }
CertificateSet
Field Summary | |
---|---|
static int |
TYPE_ATTRIBUTE_CERTIFICATE_V1
CertificateChoices type AttributeCertificateV1 (obsolete). |
static int |
TYPE_ATTRIBUTE_CERTIFICATE_V2
CertificateChoices type AttributeCertificateV2 . |
static int |
TYPE_CERTIFICATE
CertificateChoices type Certificate . |
static int |
TYPE_EXTENDED_CERTIFICATE
CertificateChoices type ExtendedCertificate (obsolete; not
supported). |
static int |
TYPE_OTHER_CERTIFICATE
CertificateChoices type OtherCertificate . |
Constructor Summary | |
---|---|
CertificateChoices(byte[] array)
Creates n CertificateChoices from an DER encoded CertificateChoices. |
|
CertificateChoices(java.security.cert.Certificate certificate)
Creates a CertificateChoices for the given certificate. |
|
CertificateChoices(java.io.InputStream is)
Creates a CertificateChoices from an input stream that supplies a DER encoded CertificateChoices. |
Method Summary | |
---|---|
void |
clearEncoded()
Clears the CertificateChoices encoding. |
java.security.cert.Certificate |
getCertificate()
Gets the included certificate. |
byte[] |
getEncoded()
Gets the encoding of this CertificateChoices. |
int |
getType()
Gets the type of the CertificateChoices. |
ASN1Object |
toASN1Object()
Returns this CertificateChoices as ASN1Object. |
java.lang.String |
toString()
Returns a string giving some information about this CertificateChoices object. |
void |
writeTo(java.io.OutputStream os)
Writes this CertificateChoices DER encoded to the given output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_CERTIFICATE
Certificate
.
public static final int TYPE_EXTENDED_CERTIFICATE
ExtendedCertificate
(obsolete; not
supported).
public static final int TYPE_ATTRIBUTE_CERTIFICATE_V1
AttributeCertificateV1
(obsolete).
public static final int TYPE_ATTRIBUTE_CERTIFICATE_V2
AttributeCertificateV2
.
public static final int TYPE_OTHER_CERTIFICATE
OtherCertificate
.
Constructor Detail |
---|
public CertificateChoices(java.security.cert.Certificate certificate)
certificate
- the certificate
java.lang.IllegalArgumentException
- if the supplied certificate is not a
iaik.x509.X509Certificate
or
iaik.x509.attr.AttributeCertificate
or
iaik.cms.OtherCertificate
objectpublic CertificateChoices(byte[] array) throws CMSParsingException
The DER encoded byte array either represents the DER encoded X.509 Certificate or an implicitly tagged AttributeCertificate or OtherCertificateFormat:
CertificateChoices ::= CHOICE { certificate Certificate, -- see X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete; see PKCS#6 v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete; see X.509-1997 v2AttrCert [2] IMPLICIT AttributeCertificateV2, -- see X509-2000 other [3] IMPLICIT OtherCertificateFormat } OtherCertificateFormat ::= SEQUENCE { otherCertFormat OBJECT IDENTIFIER, otherCert ANY DEFINED BY otherCertFormat }
array
- the DER encoded CertificateChoices as byte array
CMSParsingException
- if an parsing error occurs
CMSParsingException
- if the CertificateChoices cannot be parsedpublic CertificateChoices(java.io.InputStream is) throws CMSParsingException, java.io.IOException
The DER encoding read from the stream either represents the DER encoded X.509 Certificate or an implicitly tagged AttributeCertificate or OtherCertificateFormat:
CertificateChoices ::= CHOICE { certificate Certificate, -- see X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete; see PKCS#6 v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete; see X.509-1997 v2AttrCert [2] IMPLICIT AttributeCertificateV2, -- see X509-2000 other [3] IMPLICIT OtherCertificateFormat } OtherCertificateFormat ::= SEQUENCE { otherCertFormat OBJECT IDENTIFIER, otherCert ANY DEFINED BY otherCertFormat }
is
- the InputStream from which to read the DER encoded
CertificateChoices
java.io.IOException
- if an I/O error occurs during reading from the InputStream
CMSParsingException
- if an error occurs during the parsing procedure; e.g. the
encoding is invalid, or any of the included RevocationInfos is
not supportedMethod Detail |
---|
public java.security.cert.Certificate getCertificate()
public int getType()
TYPE_CERTIFICATE
,
TYPE_EXTENDED_CERTIFICATE
,
TYPE_ATTRIBUTE_CERTIFICATE_V1
,
TYPE_ATTRIBUTE_CERTIFICATE_V2
, or TYPE_OTHER_CERTIFICATE
public ASN1Object toASN1Object() throws CodingException
CMS ( RFC 5652) defines the CertificateChoices object as choice of certificate, extended certificate, attribute certificate v1 or v2, or other certificate. The ASN1Object returned by this method either represents the ASN.1 X.509 Certificate or an implicitly tagged AttributeCertificate or OtherCertificateFormat:
CertificateChoices ::= CHOICE { certificate Certificate, -- see X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete; see PKCS#6 v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete; see X.509-1997 v2AttrCert [2] IMPLICIT AttributeCertificateV2, -- see X509-2000 other [3] IMPLICIT OtherCertificateFormat } OtherCertificateFormat ::= SEQUENCE { otherCertFormat OBJECT IDENTIFIER, otherCert ANY DEFINED BY otherCertFormat }
CodingException
- if an error occurs while building the ASN.1 structurepublic byte[] getEncoded() throws CodingException
java.lang.Exception
- if an error occurs during encoding the CertificateChoices
CodingException
public void clearEncoded()
toASN1Object()
or getEncoded()
will build the internal ASN.1 structure anew. If this method
is called but the internal ASN.1 structure has not been built so far, the
ASN.1 parsing is done before clearing the encoding. For that reason this
method may throw a CMSParsingException.
public void writeTo(java.io.OutputStream os) throws java.io.IOException
os
- the output stream to which this CertificateChoices shall be
encoded
java.io.IOException
- if an error occurs when writing to the streampublic java.lang.String toString()
CertificateChoices
object.
toString
in class java.lang.Object
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |