iaik.cms
Class IssuerAndSerialNumber

java.lang.Object
  extended by iaik.cms.IssuerAndSerialNumber
All Implemented Interfaces:
ASN1Type, CertificateIdentifier, KeyIdentifier

public class IssuerAndSerialNumber
extends java.lang.Object
implements CertificateIdentifier

This class implements the CMS IssuerAndSerialNumber type.

The Cryptographic Message Syntax (CMS) ( RFC 5652) specifies the IssuerAndSerialNumber type for identifying a certificate (and thereby an entity and a public key) by the distinguished name of the certificate issuer and an issuer-specific certificate serial number:

 IssuerAndSerialNumber ::= SEQUENCE {
   issuer Name,
   serialNumber CertificateSerialNumber }
 

The IssuerAndSerialNumber type maybe used for specifying the signer certificate in the CMS SignerInfo structure, the recipient's certificate in the CMS RecipientInfo structure, or the originator in the CMS KeyAgreeRecipientInfo structure.

See Also:
SignerInfo, RecipientInfo

Field Summary
 
Fields inherited from interface iaik.cms.KeyIdentifier
ISSUER_AND_SERIALNUMBER, KEK_IDENTIFIER, ORIGINATOR_PUBLIC_KEY, RECIPIENT_KEY_IDENTIFIER, SUBJECT_KEY_IDENTIFIER
 
Constructor Summary
IssuerAndSerialNumber()
          Default Constructor.
IssuerAndSerialNumber(ASN1Object obj)
          Creates a new IssuerAndSerialNumber from an ASN1Object.
IssuerAndSerialNumber(Name issuer, java.math.BigInteger serialNumber)
          Creates a new IssuerAndSerialNumber from an issuer distinguished name and an issuer-specific serial number.
IssuerAndSerialNumber(X509Certificate cert)
          Creates a new IssuerAndSerialNumber from a certificate.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 IssuerAndSerialNumber object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this IssuerAndSerialNumber to the specified object.
 Name getIssuer()
          Returns the issuer distinguished name.
 int getKeyIdType()
          Returns the key (certificate) identifier type this class represents.
 java.lang.String getKeyIdTypeName()
          Returns the key (certificate) identifier type this class represents as string.
 java.math.BigInteger getSerialNumber()
          Returns the issuer-specific serial number.
 int hashCode()
          Returns a hashcode for this IssuerAndSerialNumber.
 boolean identifiesCert(X509Certificate certificate)
          Checks if the given certificate is identified by this IssuerAndSerialNumber.
 boolean isIssuerOf(X509Certificate certificate)
          Checks if the issuer of this IssuerAndSerialNumber has issued the given certificate.
 ASN1Object toASN1Object()
          Returns this IssuerAndSerialNumber as ASN1Object.
 java.lang.String toString()
          Returns a string giving some information about this IssuerAndSerialNumber object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IssuerAndSerialNumber

public IssuerAndSerialNumber()
Default Constructor. Only used for dynamic object creation. Shall not be called by an application.


IssuerAndSerialNumber

public IssuerAndSerialNumber(Name issuer,
                             java.math.BigInteger serialNumber)
Creates a new IssuerAndSerialNumber from an issuer distinguished name and an issuer-specific serial number.

Issuer distinguished name and issuer-specific serial number may be obtained from a certificate, or may be supplied immediatly, e.g.:

 Name issuerDN = new Name();
 issuerDN.addRDN(ObjectID.country, "AT");
 issuerDN.addRDN(ObjectID.organization ,"TU Graz");
 issuerDN.addRDN(ObjectID.organizationalUnit ,"IAIK");
 issuerDN.addRDN(ObjectID.commonName ,"IAIK Test CA");
 IssuerAndSerialNumber issuer_and_serialNr = 
        new IssuerAndSerialNumber(issuerDN, BigInteger.valueOf(0x12345)); 
 

Parameters:
issuer - the issuer distinguished name
serialNumber - the issuer-specific serial number

IssuerAndSerialNumber

public IssuerAndSerialNumber(X509Certificate cert)
Creates a new IssuerAndSerialNumber from a certificate.

Issuer distinguished name and issuer-specific serial number are derived from the given certificate.

Parameters:
cert - the X509Certificate

IssuerAndSerialNumber

public IssuerAndSerialNumber(ASN1Object obj)
                      throws CodingException
Creates a new IssuerAndSerialNumber from an ASN1Object.

The ASN1Object supplied to this constructor represents an already exisiting IssuerAndSerialNumber object that may have been created by calling toASN1Object.

Parameters:
obj - the IssuerAndSerialNumber as ASN1Object
Throws:
CodingException - if the ASN1Object could not be parsed
Method Detail

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes the given ASN.1 IssuerAndSerialNumber object for parsing the internal structure.

This method internally is called when creating a IssuerAndSerialNumber object from an already existing IssuerAndSerialNumber object, supplied as ASN1Object.

Specified by:
decode in interface ASN1Type
Parameters:
obj - the CMS IssuerAndSerialNumber as ASN1Object
Throws:
CodingException - if the object can not be parsed

toASN1Object

public ASN1Object toASN1Object()
Returns this IssuerAndSerialNumber as ASN1Object.

The ASN1Object returned by this method may be used as parameter value when creating an IssuerAndSerialNumber object using the IssuerAndSerialNumber(ASN1Object obj) constructor.

Specified by:
toASN1Object in interface ASN1Type
Returns:
this IssuerAndSerialNumber as ASN1Object

getKeyIdType

public int getKeyIdType()
Returns the key (certificate) identifier type this class represents.

Specified by:
getKeyIdType in interface KeyIdentifier
Returns:
the cert id type ISSUER_AND_SERIALNUMBER (0)

getKeyIdTypeName

public java.lang.String getKeyIdTypeName()
Returns the key (certificate) identifier type this class represents as string.

Specified by:
getKeyIdTypeName in interface KeyIdentifier
Returns:
"IssuerAndSerialNumber"

getIssuer

public Name getIssuer()
Returns the issuer distinguished name.

Returns:
the issuer distinguished name

getSerialNumber

public java.math.BigInteger getSerialNumber()
Returns the issuer-specific serial number.

Returns:
the issuer-specific serial number, as BigInteger

equals

public boolean equals(java.lang.Object obj)
Compares this IssuerAndSerialNumber to the specified object.

Specified by:
equals in interface KeyIdentifier
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare this IssuerAndSerialNumber against.
Returns:
true, if the given object is equal to this IssuerAndSerialNumber, false otherwise

hashCode

public int hashCode()
Returns a hashcode for this IssuerAndSerialNumber.

Specified by:
hashCode in interface KeyIdentifier
Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this IssuerAndSerialNumber

isIssuerOf

public boolean isIssuerOf(X509Certificate certificate)
Checks if the issuer of this IssuerAndSerialNumber has issued the given certificate.

Parameters:
certificate - the certificate to be checked of being issued by the issuer of this IssuerAndSerialNumber
Returns:
true if the issuer of this IssuerAndSerialNumber has issued the given certificate, false otherwise

identifiesCert

public boolean identifiesCert(X509Certificate certificate)
Checks if the given certificate is identified by this IssuerAndSerialNumber. As method isIssuerOf this method checks if the issuer of this IssuerAndSerialNumber has issued the given certificate.

Specified by:
identifiesCert in interface CertificateIdentifier
Parameters:
certificate - the certificate to be checked of being issued by the issuer of this IssuerAndSerialNumber
Returns:
true if the issuer of this IssuerAndSerialNumber has issued the given certificate, false otherwise

toString

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

Specified by:
toString in interface KeyIdentifier
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 5.1, (c) 2002 IAIK, (c) 2003 - 2010 SIC