iaik.cms
Class RevocationInfoChoice

java.lang.Object
  extended by iaik.cms.RevocationInfoChoice

public class RevocationInfoChoice
extends java.lang.Object

This class implements the CMS type RevocationInfoChoice. The Cryptographic Message Syntax (CMS) (RFC 5652) specifies the RevocationInfoChoice type for modeling certificate revocation status information:

 RevocationInfoChoices ::= SET OF RevocationInfoChoice
 
 RevocationInfoChoice ::= CHOICE {
   crl CertificateList,
   other [1] IMPLICIT OtherRevocationInfoFormat }

 OtherRevocationInfoFormat ::= SEQUENCE {
   otherRevInfoFormat OBJECT IDENTIFIER,
   otherRevInfo ANY DEFINED BY otherRevInfoFormat }
 
When creating a RevocationInfoChoice object the revocation info has to be given as X.509 CRL (instance of iaik.x509.X509CRL) or other revocation info (instance of iaik.cms.OtherRevocationInfo or iaik.cms.OCSPRevocationInfo), e.g.:
 RevocationInfoChoices revocationInfoChoices = new RevocationInfoChoices(); 
 X509CRL crl = ...;
 revocationInfoChoices.addRevocationInfoChoice(new RevocationInfoChoice(crl));
 OtherRevocationInfo otherRevInfo = ...;
 revocationInfoChoices.addRevocationInfoChoice(new RevocationInfoChoice(otherRevInfo));
 OCSPRevocationInfo ocspRevInfo = ...;
 revocationInfoChoices.addRevocationInfoChoice(new RevocationInfoChoice(ocspRevInfo));
 
Note that it might be more convenient to add the revocation info immediately to the RevocationInfoChoices without prior wrapping it into a RevocationInfoChoice object:
 RevocationInfoChoices revocationInfoChoices = new RevocationInfoChoices();
 X509CRL crl = ...;
 revocationInfoChoices.addRevocationInfo(crl);
 OtherRevocationInfo otherRevInfo = ...;
 revocationInfoChoices.addRevocationInfo(otherRevInfo);
 OCSPRevocationInfo ocspRevInfo = ...;
 revocationInfoChoices.addRevocationInfo(ocspRevInfo);
 
Using RevocationInfoChoice maybe of more interest on the parsing side when getting the RevocationInfoChoice elements from a RevocationInfoChoices object to obtain their (original, parsed) encoding:
 RevocationInfoChoices revocationInfoChoices = ...;
 RevocationInfoChoice[] rics = revocationInfoChoices.getRevocationInfoChoices();
 for (int i = 0; i < rics.length; i++) {
   byte[] encodedRic = rics[i].getEncoded();
 }
 

See Also:
RevocationInfoChoices, OtherRevocationInfo, OCSPRevocationInfo

Field Summary
static int TYPE_CERTIFICATE_LIST
          RevocationInfoChoice type CertificateList (crl).
static int TYPE_OTHER_REVOCATION_INFO_FORMAT
          RevocationInfoChoice type OtherRevocationInfoFormat.
 
Constructor Summary
RevocationInfoChoice(byte[] array)
          Creates a RevocationInfoChoice from a DER encoded RevocationInfoChoice.
RevocationInfoChoice(java.security.cert.CRL revocationInfo)
          Creates a RevocationInfoChoice for the given RevocationInfo.
RevocationInfoChoice(java.io.InputStream is)
          Creates a RevocationInfoChoice from an input stream that supplies a DER encoded RevocationInfoChoice.
RevocationInfoChoice(java.io.InputStream is, boolean keepEncoding)
          Creates a RevocationInfoChoice from an input stream that supplies a DER encoded RevocationInfoChoice.
 
Method Summary
 void clearEncoded()
          Clears the RevocationInfoChoice encoding.
 java.security.cert.CRL getCRL()
          Gets the included RevocationInfo.
 byte[] getEncoded()
          Gets the encoding of this RevocationInfoChoice.
 int getType()
          Gets the type of the RevocationInfoChoice.
 ASN1Object toASN1Object()
          Returns this RevocationInfoChoice as ASN1Object.
 java.lang.String toString()
          Returns a string giving some information about this RevocationInfoChoice object.
 void writeTo(java.io.OutputStream os)
          Writes this RevocationInfoChoice 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

TYPE_CERTIFICATE_LIST

public static final int TYPE_CERTIFICATE_LIST
RevocationInfoChoice type CertificateList (crl).

See Also:
Constant Field Values

TYPE_OTHER_REVOCATION_INFO_FORMAT

public static final int TYPE_OTHER_REVOCATION_INFO_FORMAT
RevocationInfoChoice type OtherRevocationInfoFormat.

See Also:
Constant Field Values
Constructor Detail

RevocationInfoChoice

public RevocationInfoChoice(java.security.cert.CRL revocationInfo)
Creates a RevocationInfoChoice for the given RevocationInfo.

Parameters:
revocationInfo - the RevocationInfo as CRL object

RevocationInfoChoice

public RevocationInfoChoice(byte[] array)
                     throws CMSParsingException
Creates a RevocationInfoChoice from a DER encoded RevocationInfoChoice.

The DER encoded byte array either represents the DER encoded X.509 certificate list or the implicitly tagged OtherRevocationInfoFormat:

 RevocationInfoChoices ::= SET OF RevocationInfoChoice
 
 RevocationInfoChoice ::= CHOICE {
  crl CertificateList,
   other [1] IMPLICIT OtherRevocationInfoFormat }

 OtherRevocationInfoFormat ::= SEQUENCE {
   otherRevInfoFormat OBJECT IDENTIFIER,
   otherRevInfo ANY DEFINED BY otherRevInfoFormat }
 
When using this constructor for parsing a RevocationInfoChoice of type CertificateList the crl is not fully parsed. Rather the encoded array is kept in memory and returned unchanged when encoding it again. The parsing is done when method getCRL() is called. Please ensure that the the supplied array actually represents the encoded RevocationInfoChoice (encoded X.509 CRL when the CertificateList option is used, implicitly tagged OtherRevocationInfoFormat otherwise)! This constructor provides a memory friendly alternative for reading large CRLs (without parsing their internal structure). If getCRL is never called, the encoded CRL is never parsed and therefore never checked if actually representing a valid X.509 CRL.

Parameters:
array - the DER encoded RevocationInfoChoice as byte array (will be not cloned for a RevocationInfo of type CertificateList (crl)!)
Throws:
CMSParsingException - if a parsing error occurs

RevocationInfoChoice

public RevocationInfoChoice(java.io.InputStream is)
                     throws CMSParsingException,
                            java.io.IOException
Creates a RevocationInfoChoice from an input stream that supplies a DER encoded RevocationInfoChoice.

The DER encoding read from the stream either represents the DER encoded X.509 certificate list or the implicitly tagged OtherRevocationInfoFormat:

 RevocationInfoChoices ::= SET OF RevocationInfoChoice
 
 RevocationInfoChoice ::= CHOICE {
  crl CertificateList,
   other [1] IMPLICIT OtherRevocationInfoFormat }

 OtherRevocationInfoFormat ::= SEQUENCE {
   otherRevInfoFormat OBJECT IDENTIFIER,
   otherRevInfo ANY DEFINED BY otherRevInfoFormat }
 

Parameters:
is - the InputStream from which to read the DER encoded RevocationInfoChoice
Throws:
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 the included RevocationInfo type is not supported

RevocationInfoChoice

public RevocationInfoChoice(java.io.InputStream is,
                            boolean keepEncoding)
                     throws CMSParsingException,
                            java.io.IOException
Creates a RevocationInfoChoice from an input stream that supplies a DER encoded RevocationInfoChoice.

The DER encoding read from the stream either represents the DER encoded X.509 certificate list or the implicitly tagged OtherRevocationInfoFormat:

 RevocationInfoChoices ::= SET OF RevocationInfoChoice
 
 RevocationInfoChoice ::= CHOICE {
  crl CertificateList,
   other [1] IMPLICIT OtherRevocationInfoFormat }

 OtherRevocationInfoFormat ::= SEQUENCE {
   otherRevInfoFormat OBJECT IDENTIFIER,
   otherRevInfo ANY DEFINED BY otherRevInfoFormat }
 

Parameters:
is - the InputStream from which to read the DER encoded RevocationInfoChoice
keepEncoding - whether to keep the encoding
Throws:
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 the included RevocationInfo type is not supported
Method Detail

getCRL

public java.security.cert.CRL getCRL()
                              throws CMSParsingException
Gets the included RevocationInfo.

Returns:
the RevocationInfo as CRL object
Throws:
CMSParsingException - if an error occurs when parsing the (yet not decoded) RevocationInfo

getType

public int getType()
Gets the type of the RevocationInfoChoice.

Returns:
the type, either TYPE_CERTIFICATE_LIST or TYPE_OTHER_REVOCATION_INFO_FORMAT

toASN1Object

public ASN1Object toASN1Object()
                        throws CodingException
Returns this RevocationInfoChoice as ASN1Object.

The ASN.1 object returned by this method either represents the ASN.1 X.509 certificate list or the implicitly tagged OtherRevocationInfoFormat:

 RevocationInfoChoices ::= SET OF RevocationInfoChoice
 
 RevocationInfoChoice ::= CHOICE {
  crl CertificateList,
  other [1] IMPLICIT OtherRevocationInfoFormat }

 OtherRevocationInfoFormat ::= SEQUENCE {
   otherRevInfoFormat OBJECT IDENTIFIER,
   otherRevInfo ANY DEFINED BY otherRevInfoFormat }
 

Returns:
this RevocationInfoChoice as ASN1Object
Throws:
CodingException - if an error occurs while building the ASN.1 structure

getEncoded

public byte[] getEncoded()
                  throws CodingException
Gets the encoding of this RevocationInfoChoice.

Returns:
the encoding of this RevocationInfoChoice
Throws:
java.lang.Exception - if an error occurs during encoding the RevocationInfoChoice
CodingException

clearEncoded

public void clearEncoded()
                  throws CMSParsingException
Clears the RevocationInfoChoice encoding.
This method maybe called to clear the parsed encoding so that any following call to 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.

Throws:
CMSParsingException - if the ASN.1 structure has not been built yet and an error occurs during ASN.1 parsing

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
Writes this RevocationInfoChoice DER encoded to the given output stream.

Parameters:
os - the output stream to which this RevocationInfoChoice shall be encoded
Throws:
java.io.IOException - if an error occurs when writing to the stream

toString

public java.lang.String toString()
Returns a string giving some information about this RevocationInfoChoice object.

Overrides:
toString in class java.lang.Object
Returns:
the string representation

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK-CMS 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC