iaik.cms
Class SubjectKeyID

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

public class SubjectKeyID
extends java.lang.Object
implements CertificateIdentifier

This class implements the SubjectKeyIdentifier type.

The Cryptographic Message Syntax (CMS) (RFC 5652) uses the X.509 certificate SubjectKeyIdentifier extension for identifying a certificate (and thereby an entity and a public key):

 SubjectKeyIdentifier ::= OCTET STRING
 

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

See Also:
SignerInfo, RecipientInfo, KeyAgreeRecipientInfo

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
SubjectKeyID()
          Default Constructor.
SubjectKeyID(ASN1Object obj)
          Creates a new SubjectKeyID from an ASN1Object.
SubjectKeyID(byte[] keyIdentifier)
          Creates a new SubjectKeyID the given identifier value.
SubjectKeyID(X509Certificate cert)
          Creates a new SubjectKeyID from a certificate.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 SubjectKeyIdentifier object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this SubjectKeyID to the specified object.
 byte[] getKeyIdentifier()
          Returns the keyIdentifier value of this SubjectKeyID.
 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.
 int hashCode()
          Returns a hashcode for this SubjectKeyIdentifier.
 boolean identifiesCert(X509Certificate certificate)
          Checks if the given certificate is identified by this SubjectKeyID.
 ASN1Object toASN1Object()
          Returns this SubjectKeyIdentifier as ASN1Object.
 java.lang.String toString()
          Returns a string giving some information about this SubjectKeyIdentifier object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubjectKeyID

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


SubjectKeyID

public SubjectKeyID(byte[] keyIdentifier)
Creates a new SubjectKeyID the given identifier value.

Parameters:
keyIdentifier - the SubjectKeyIdentifier value

SubjectKeyID

public SubjectKeyID(X509Certificate cert)
             throws X509ExtensionException
Creates a new SubjectKeyID from a certificate.

The KeyIdentifier value is read from the SubjectKeyIdentifier extension of the supplied certificate. If the certificate does not contain the SubjectKeyIdentifier extension an IllegalArgumetException is thrown indicating that a SubjectKeyIdentifier cannot be used for identfying the certificate within a CMS transaction.

Parameters:
cert - the certificate this SubjectKeyID object shall be initialized from
Throws:
X509ExtensionException - if the given cert does not contain the SubjectKeyIdentifier extension, or if the SubjectKeyIdentifier extension cannot be parsed

SubjectKeyID

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

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

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

getKeyIdentifier

public byte[] getKeyIdentifier()
Returns the keyIdentifier value of this SubjectKeyID.

Returns:
the keyIdentifier value

decode

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

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

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

toASN1Object

public ASN1Object toASN1Object()
Returns this SubjectKeyIdentifier as ASN1Object.

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

Specified by:
toASN1Object in interface ASN1Type
Returns:
this SubjectKeyIdentifier 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 SUBJECT_KEY_IDENTIFIER (1)

getKeyIdTypeName

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

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

identifiesCert

public boolean identifiesCert(X509Certificate certificate)
Checks if the given certificate is identified by this SubjectKeyID. This method returns true if the given cert contains a SubjectKeyIdentifier extension with the same value as represented by this SubjectKeyIdentifier object.

Specified by:
identifiesCert in interface CertificateIdentifier
Parameters:
certificate - the certificate to be checked of being identified by this SubjectKeyIdentifier
Returns:
true if the given cert contains a SubjectKeyIdentifier extension with the same value as represented by this SubjectKeyIdentifier object, false otherwise

equals

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

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

hashCode

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

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

toString

public java.lang.String toString()
Returns a string giving some information about this SubjectKeyIdentifier 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 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC