iaik.cms
Class RecipientKeyIdentifier

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

public class RecipientKeyIdentifier
extends java.lang.Object
implements CertificateIdentifier

The CMS type RecipientKeyIdentifier.

The RecipientKeyIdentifier type may be used in a KeyAgreeRecipientInfo for identifying the public key agreement certificate of the recipient by SubjectKeyIdentifier and optional date (for identifiying which of the previously distributed UKMs was used by the sender) and optional other key attribute (see RFC 5652):

 RecipientKeyIdentifier ::= SEQUENCE {   
   subjectKeyIdentifier SubjectKEyIdentifier,
   date GeneralizedTime OPTIONAL,
   other OtherKeyAttribute OPTIONAL }

 SubjectKeyIdentifier ::= OCTET_STRING
 
For interoperability reasons it is recommended NOT to use OtherKeyAttribute.


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
RecipientKeyIdentifier()
          Default Constructor.
RecipientKeyIdentifier(ASN1Object obj)
          Creates a RecipientKeyIdentifier from an ASN1Object.
RecipientKeyIdentifier(SubjectKeyID subjectKeyIdentifier)
          Creates a RecipientKeyIdentifier from the given SubjectkeyIdentifier.
RecipientKeyIdentifier(X509Certificate recipientCertificate)
          Creates a RecipientKeyIdentifier from the given recipient certificate.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the RecipientKeyIdentifier from the given ASN1Object.
 boolean equals(java.lang.Object obj)
          Compares this RecipientKeyIdentifier to the specified object.
 java.util.Date getDate()
          Gets the optional Date value.
 int getKeyIdType()
          Returns the key identifier type this class represents.
 java.lang.String getKeyIdTypeName()
          Returns the key (certificate) identifier type this class represents as string.
 OtherKeyAttribute getOtherKeyAttribute()
          Gets the optional OtherKeyAttribute component value.
 SubjectKeyID getSubjectKeyIdentifier()
          Gets the SubjectKeyIdentifier.
 boolean hasDate(java.util.Date date)
          Checks if this RecipientKeyIdentifier holds the given Date.
 int hashCode()
          Returns a hashcode for this RecipientKeyIdentifier.
 boolean hasOtherKeyAttribute(OtherKeyAttribute otherKeyAttribute)
          Checks if this RecipientKeyIdentifier holds the given OtherKeyAttribute.
 boolean hasSubjectKeyIdentifier(SubjectKeyID subjectKeyIdentifier)
          Checks if this RecipientKeyIdentifier holds the given SubjectKeyIdentifier.
 boolean identifiesCert(X509Certificate cert)
          Checks if the given certificate is identified by this RecipientKeyIdentifier.
 void setDate(java.util.Date date)
          Sets the optional Date component.
 void setOtherKeyAttribute(OtherKeyAttribute other)
          Sets the optional OtherKeyAttribute component.
 ASN1Object toASN1Object()
          Returns this RecipientKeyIdentifier as ASN1Object.
 java.lang.String toString()
          Returns a String representation of this RecipientKeyIdentifier.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecipientKeyIdentifier

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


RecipientKeyIdentifier

public RecipientKeyIdentifier(X509Certificate recipientCertificate)
                       throws X509ExtensionException
Creates a RecipientKeyIdentifier from the given recipient certificate.

Parameters:
recipientCertificate - the recipient certificate from which to get the SubjectKeyIdentifier
Throws:
X509ExtensionException - if the given cert does not contain the SubjectKeyIdentifier extension, or if the SubjectKeyIdentifier extension cannot be parsed

RecipientKeyIdentifier

public RecipientKeyIdentifier(SubjectKeyID subjectKeyIdentifier)
Creates a RecipientKeyIdentifier from the given SubjectkeyIdentifier.

Parameters:
subjectKeyIdentifier - the SubjectKeyIdentifier

RecipientKeyIdentifier

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

Parameters:
obj - the RecipientKeyIdentifier as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be decoded or is invalid structured
Method Detail

setDate

public void setDate(java.util.Date date)
Sets the optional Date component.

Parameters:
date - the Date optionally identifying which of the previously distributed UKMs was used by the sender

setOtherKeyAttribute

public void setOtherKeyAttribute(OtherKeyAttribute other)
Sets the optional OtherKeyAttribute component.

Parameters:
other - additional information for identifying the key

getDate

public java.util.Date getDate()
Gets the optional Date value.

Returns:
the Date optionally identifying which of the previously distributed UKMs was used by the sender

getOtherKeyAttribute

public OtherKeyAttribute getOtherKeyAttribute()
Gets the optional OtherKeyAttribute component value.

Returns:
other additional information for identifying the keying material

getSubjectKeyIdentifier

public SubjectKeyID getSubjectKeyIdentifier()
Gets the SubjectKeyIdentifier.

Returns:
the SubjectKeyIdentifier

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes the RecipientKeyIdentifier from the given ASN1Object.

Specified by:
decode in interface ASN1Type
Parameters:
obj - the RecipientKeyIdentifier as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be decoded or is invalid structured

toASN1Object

public ASN1Object toASN1Object()
Returns this RecipientKeyIdentifier as ASN1Object.

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

hasSubjectKeyIdentifier

public boolean hasSubjectKeyIdentifier(SubjectKeyID subjectKeyIdentifier)
Checks if this RecipientKeyIdentifier holds the given SubjectKeyIdentifier.

Parameters:
subjectKeyIdentifier - the value of the SubjectKeyIdentifier to compare to
Returns:
true if the SubjectKeyIdentifier value of this RecipientKeyIdentifier is equal to the supplied SubjectKeyIdentifer value, false otherwise

hasDate

public boolean hasDate(java.util.Date date)
Checks if this RecipientKeyIdentifier holds the given Date.

Returns:
true if the Date component of this RecipientKeyIdentifier is equal to the supplied Date, false otherwise

hasOtherKeyAttribute

public boolean hasOtherKeyAttribute(OtherKeyAttribute otherKeyAttribute)
Checks if this RecipientKeyIdentifier holds the given OtherKeyAttribute.

Returns:
true if the OtherKeyAttribute component of this RecipientKeyIdentifier is equal to the supplied OtherKeyAttribute, false otherwise

equals

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

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

hashCode

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

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

identifiesCert

public boolean identifiesCert(X509Certificate cert)
Checks if the given certificate is identified by this RecipientKeyIdentifier.

This method implements the CertificateIdentifier interface.
Attention! This method only can check the subjectKeyIdentifier component of being equal to the SubjectKeyIdentifier of the given certificate. If you want to check date and otherKeyAttribute you may use method equals for comparing this RecipientIdentifier against some other RecipientIdentifier.

Specified by:
identifiesCert in interface CertificateIdentifier
Parameters:
cert - the certificate to be checked of being identified by this CertificateIdentifier
Returns:
true if the given certificate is identified by this CertificateIdentifier, false otherwise

getKeyIdType

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

Specified by:
getKeyIdType in interface KeyIdentifier
Returns:
the key id type RECIPIENT_KEY_IDENTIFIER (2)

getKeyIdTypeName

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

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

toString

public java.lang.String toString()
Returns a String representation of this RecipientKeyIdentifier.

Specified by:
toString in interface KeyIdentifier
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this RecipientKeyIdentifier

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