iaik.cms
Class RevocationInfoChoices

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

public class RevocationInfoChoices
extends java.lang.Object

This class implements the CMS type RevocationInfoChoices. The Cryptographic Message Syntax (CMS) (RFC 5652) specifies the RevocationInfoChoices 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 }
 
For creating an empty RevocationInfoChoices use the default constructor and subsequently supply RevocationInfos by calling method setRevocationInfos or a addRevocationInfo method.

Attention! Only X.509 certificate revocation lists (instances of iaik.x509.X509CRL) or other RevocationInfos (instances of iaik.cms.OtherRevocationInfo) can be added to a RevocationInfoChoices, e.g.:

 RevocationInfoChoices revocationInfoChoices = new RevocationInfoChoices();
 X509CRL x509Crl = ...;
 revocationInfoChoices.addRevocationInfo(x509Crl);
 OtherRevocationInfo otherRevInfo = ...;
 revocationInfoChoices.addRevocationInfo(otherRevInfo);
 
RevocationInfoChoices maybe used to provide/get revocation status information for the certificates included in a CMS SignedData or CMS OriginatorInfo object; the latter providing certificate/revocation status information of the originator of a CMS EnvelopedData or AuthenticatedData message, e.g.:
 SignedData signedData = ...;
 signedData.setRevocationInfoChoices(revocationInfoChoices);
 
 EnvelopedData envelopedData = ...;
 OriginatorInfo originatorInfo = new OriginatorInfo();
 ...
 originatorInfo.setRevocationInfoChoices(revocationInfoChoices);
 ...
 envelopedData.setOriginatorInfo(originatorInfo);
 
For parsing use the equivalent getRevocationInfoChoices() methods, e.g.:
 RevocationInfoChoices revocationInfoChoices = signedData.getRevocationInfoChoices();
 

See Also:
AuthenticatedDataStream, AuthenticatedData, EnvelopedDataStream, EnvelopedData, OriginatorInfo, SignedDataStream, SignedData

Constructor Summary
RevocationInfoChoices()
          Default constructor.
RevocationInfoChoices(java.io.InputStream is)
          Creates a RevocationInfoChoices from an input stream that supplies a DER encoded RevocationInfoChoices.
 
Method Summary
 void addRevocationInfo(java.security.cert.CRL crl)
          Adds the given RevocationInfo to this RevocationInfoChoices.
 void addRevocationInfoChoice(RevocationInfoChoice ric)
          Adds the given RevocationInfoChoice to this RevocationInfoChoices.
 void addRevocationInfoChoices(RevocationInfoChoice[] rics)
          Adds the given RevocationInfoChoice elements to this RevocationInfoChoices.
 void addRevocationInfos(java.security.cert.CRL[] crls)
          Adds the given RevocationInfos to this RevocationInfoChoices.
 boolean containsOCSPRevocationInfos()
          Asks whether RFC 5652 OtherRevocationInfos of type id-ri-ocsp-response (1.3.6.1.5.5.7.16.2, RFC 5940) are included.
 boolean containsOtherRevocationInfos()
          Asks whether RFC 5652 OtherRevocationInfos are included.
 boolean containsX509CRLs()
          Asks whether X.509 CRLs are included.
 void decode(java.io.InputStream is)
          Decodes a RevocationInfoChoices from the given InputStream.
 OCSPRevocationInfo[] getOCSPRevocationInfos()
          Gets all included RFC 5652 OtherRevocationInfos of type id-ri-ocsp-response (1.3.6.1.5.5.7.16.2, RFC 5940) from this RevocationInfoChoices.
 OtherRevocationInfo[] getOtherRevocationInfos()
          Gets all included RFC 5652 other RevocationInfos from this RevocationInfoChoices.
 RevocationInfoChoice[] getRevocationInfoChoices()
          Gets all included RevocationInfoChoice elements.
 java.security.cert.CRL[] getRevocationInfos()
          Gets the RevocationInfos included in this RevocationInfoChoices.
 X509CRL getX509CRL(Name issuer)
          Gets the X.509 CRL issued by the given issuer.
 X509CRL[] getX509CRLs()
          Gets all included X.509 CRLs from this RevocationInfoChoices.
 boolean isEmpty()
          Asks if this RevocationInfoChoices is empty.
 void removeAllRevocationInfos()
          Removes all RevocationInfos from this RevocationInfoChoices.
 void setRevocationInfoChoices(RevocationInfoChoice[] rics)
          Sets the given RevocationInfoChoice elements for this RevocationInfoChoices.
 void setRevocationInfos(java.security.cert.CRL[] crls)
          Sets the RevocationInfos of this RevocationInfoChoices.
 int size()
          Counts the number of RevocationInfo elements included in this RevocationInfoChoices.
 ASN1Object toASN1Object()
          Returns this RevocationInfoChoices as ASN1Object.
 java.lang.String toString()
          Returns a string giving some information about this RevocationInfoChoices object.
 void writeTo(java.io.OutputStream os)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RevocationInfoChoices

public RevocationInfoChoices()
Default constructor.

Creates an empty RevocationInfoChoices. Supply revocation status information to be included by calling method setRevocationInfos or use a proper addRevocationInfo method.


RevocationInfoChoices

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

Parameters:
is - the InputStream from which to read the DER encoded RevocationInfoChoices
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 any of the included RevocationInfos is not supported
Method Detail

setRevocationInfos

public void setRevocationInfos(java.security.cert.CRL[] crls)
Sets the RevocationInfos of this RevocationInfoChoices.

Only X.509 certificate revocation lists (instances of iaik.x509.X509CRL) or other RevocationInfos (instances of iaik.cms.OtherRevocationInfo) are allowed.

Parameters:
crls - the RevocationInfos to be set
Throws:
java.lang.IllegalArgumentException - if any of the supplied RevocationInfos is not a iaik.x509.X509CRL or iaik.cms.OtherRevocationInfo, iaik.cms.OCSPRevocationInfo object

addRevocationInfos

public void addRevocationInfos(java.security.cert.CRL[] crls)
Adds the given RevocationInfos to this RevocationInfoChoices.

Only X.509 certificate revocation lists (instances of iaik.x509.X509CRL) or other RevocationInfos (instances of iaik.cms.OtherRevocationInfo) can be added to this RevocationInfoChoices.

Parameters:
crls - the RevocationInfos to add
Throws:
java.lang.IllegalArgumentException - if any of the supplied RevocationInfos is not a iaik.x509.X509CRL or iaik.cms.OtherRevocationInfo object

addRevocationInfo

public void addRevocationInfo(java.security.cert.CRL crl)
Adds the given RevocationInfo to this RevocationInfoChoices.

Only X.509 certificate revocation lists (instances of iaik.x509.X509CRL) or other RevocationInfos (instances of iaik.cms.OtherRevocationInfo) can be added to this RevocationInfoChoices.

Parameters:
crl - the RevocationInfo to be added
Throws:
java.lang.IllegalArgumentException - if the supplied RevocationInfo is not a iaik.x509.X509CRL or iaik.cms.OtherRevocationInfo object

getRevocationInfos

public java.security.cert.CRL[] getRevocationInfos()
Gets the RevocationInfos included in this RevocationInfoChoices.

The array returned may contain X.509 CRLs (instances of iaik.x509.X509CRL and/or other RevocationInfos (instances of iaik.cms.OtherRevocationInfo).

Returns:
an array containing all RevocationInfos included in this RevocationInfoChoices; the array may be empty if no RevocationInfos are included
Throws:
CMSRuntimeException - may be thrown if any of the included RevocationInfos has not been parsed so far and has an invalid ASN.1 structure

getX509CRL

public X509CRL getX509CRL(Name issuer)
Gets the X.509 CRL issued by the given issuer.

If no CRL in this RevocationInfoChoices has been issued by the given issuer null is returned.

Parameters:
issuer - the CRL issuer to be searched for an issued CRL
Returns:
the X.509 CRL issued by the given issuer or null if none of the included CRLs has been issued by this issuer
Throws:
CMSRuntimeException - may be thrown if any of the included RevocationInfos has not been parsed so far and has an invalid ASN.1 structure

getX509CRLs

public X509CRL[] getX509CRLs()
Gets all included X.509 CRLs from this RevocationInfoChoices.

Returns:
an array containing all X.509 CRLs included in this RevocationInfoChoices; the array may be empty if no X.509 CRLS are included
Throws:
CMSRuntimeException - may be thrown if any of the included RevocationInfos has not been parsed so far and has an invalid ASN.1 structure

getOtherRevocationInfos

public OtherRevocationInfo[] getOtherRevocationInfos()
Gets all included RFC 5652 other RevocationInfos from this RevocationInfoChoices.

Returns:
an array containing all other RevocationInfos included in this RevocationInfoChoices; the array may be empty if no other RevocationInfos are included
Throws:
CMSRuntimeException - may be thrown if any of the included RevocationInfos has not been parsed so far and has an invalid ASN.1 structure

getOCSPRevocationInfos

public OCSPRevocationInfo[] getOCSPRevocationInfos()
                                            throws CMSParsingException
Gets all included RFC 5652 OtherRevocationInfos of type id-ri-ocsp-response (1.3.6.1.5.5.7.16.2, RFC 5940) from this RevocationInfoChoices.

Returns:
an array containing all OtherRevocationInfos of type id-ri-ocsp-response included in this RevocationInfoChoices; the array may be empty if no other RevocationInfos are included
Throws:
CMSParsingException - if any of the included RevocationInfos cannot be parsed

size

public int size()
Counts the number of RevocationInfo elements included in this RevocationInfoChoices.

Returns:
the number of RevocationInfo elements

isEmpty

public boolean isEmpty()
Asks if this RevocationInfoChoices is empty.

Returns:
true if there are no RevocationInfos in this RevocationInfoChoices, false otherwise

containsX509CRLs

public boolean containsX509CRLs()
Asks whether X.509 CRLs are included.

Returns:
true if there are X.509 CRLs in this RevocationInfoChoices, false otherwise

containsOtherRevocationInfos

public boolean containsOtherRevocationInfos()
Asks whether RFC 5652 OtherRevocationInfos are included.

Returns:
true if there are other RevocationInfos in this RevocationInfoChoices, false otherwise

containsOCSPRevocationInfos

public boolean containsOCSPRevocationInfos()
                                    throws CMSParsingException
Asks whether RFC 5652 OtherRevocationInfos of type id-ri-ocsp-response (1.3.6.1.5.5.7.16.2, RFC 5940) are included.

Returns:
true if there are OCSP RevocationInfos in this RevocationInfoChoices, false otherwise
Throws:
CMSParsingException - if any of the included RevocationInfos cannot be parsed

removeAllRevocationInfos

public void removeAllRevocationInfos()
Removes all RevocationInfos from this RevocationInfoChoices.


addRevocationInfoChoice

public void addRevocationInfoChoice(RevocationInfoChoice ric)
Adds the given RevocationInfoChoice to this RevocationInfoChoices.

Parameters:
ric - the RevocationInfoChoice to be added

addRevocationInfoChoices

public void addRevocationInfoChoices(RevocationInfoChoice[] rics)
Adds the given RevocationInfoChoice elements to this RevocationInfoChoices.

Parameters:
rics - the RevocationInfoChoice elements to be added

setRevocationInfoChoices

public void setRevocationInfoChoices(RevocationInfoChoice[] rics)
Sets the given RevocationInfoChoice elements for this RevocationInfoChoices.

Parameters:
rics - the RevocationInfoChoice elements to be set

getRevocationInfoChoices

public RevocationInfoChoice[] getRevocationInfoChoices()
Gets all included RevocationInfoChoice elements.

Note that this method returns an array of RevocationInfoChoice objects, whereas method getRevocationInfos returns the RevocationInfo (CRL) elements included in the RevocationInfoChoice objects. Calling getRevocationInfoChoices may be preferred to get the encoding of each RevocationInfoChoice object if required:

 RevocationInfoChoices revocationInfoChoices = ...;
 RevocationInfoChoice[] rics = revocationInfoChoices.getRevocationInfoChoices();
 for (int i = 0; i < rics.length; i++) {
   byte[] encodedRic = rics[i].getEncoded();
 }
 

Returns:
all included RevocationInfoChoice elements

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException,
                   CMSParsingException
Decodes a RevocationInfoChoices from the given InputStream.

Parameters:
is - the input stream supplying the encoded RevocationInfoChoices
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 any of the included RevocationInfos is not supported

toASN1Object

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

CMS (RFC 5652) specifies the RevocationInfoChoices type as SET OF RevocationInfoChoice objects:

 RevocationInfoChoices ::= SET OF RevocationInfoChoice

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

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

Returns:
this RevocationInfoChoices as ASN1Object of type SET
Throws:
CodingException - if an error occurs while building the ASN.1 structure

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString()
Returns a string giving some information about this RevocationInfoChoices 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