iaik.cms
Class SignerIdentifier

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

public class SignerIdentifier
extends java.lang.Object

The CMS type SignerIdentifier.

A SignerIdentifier is used for identifying the signer certificate of a CMS SignerInfo. It is defined as ASN.1 CHOICE of IssuerAndSerialNumber or SubjectKeyIdentifier (see RFC 5652):

 
 SignerIdentifier ::= CHOICE {
   issuerAndSerialNumber IssuerAndSerialNumber,
   subjectKeyIdentifier [0] SubjectKeyIdentifier }
 


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
SignerIdentifier(ASN1Object obj)
          Creates a SignerIdentifier from an ASN1Object.
SignerIdentifier(CertificateIdentifier certificateIdentifier)
          Creates a SignerIdentifier from the given IssuerAndSerialNumber or SubjectKeyID.
SignerIdentifier(java.io.InputStream is)
          Creates a SignerIdentifier and parses a DER encoded SignerIdentifier from the given input stream.
 
Method Summary
 void clearEncoded()
          Clears the encoded SignerIdentifier.
 void decode(ASN1Object obj)
          Decodes the SignerRecipientIdentifier from the given ASN1Object.
 void decode(java.io.InputStream is)
          Decodes the SignerIdentifier from the given input stream.
 void decode(java.io.InputStream is, boolean keepEncoding)
          Decodes the SignerIdentifier from the given input stream.
 boolean equals(java.lang.Object obj)
          Compares this SignerRecipientIdentifier to the specified object.
 CertificateIdentifier getCertificateIdentifier()
          Gets the CertificateIdentifier this SignerIdentifier represents.
 byte[] getEncoded()
          Returns the DER encoded SignerIdentifier.
 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.
 int hashCode()
          Returns a hashcode for this SignerRecipientIdentifier.
 boolean identifiesCert(X509Certificate cert)
          Checks if the given certificate is identified by this CertificateIdentifier.
 ASN1Object toASN1Object()
          Returns this SignerIdentifier as ASN1Object.
 java.lang.String toString()
          Returns a String representation of this SignerRecipientKeyIdentifier.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SignerIdentifier

public SignerIdentifier(CertificateIdentifier certificateIdentifier)
Creates a SignerIdentifier from the given IssuerAndSerialNumber or SubjectKeyID.

Parameters:
certificateIdentifier - the IssuerAndSerialNumber or SubjectKeyID to be used for identifying the certificate
Throws:
if - the supplied certificateIdentifier is not an IssuerAndSerialNumber or SubjecKeyIdentifier

SignerIdentifier

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

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

SignerIdentifier

public SignerIdentifier(java.io.InputStream is)
                 throws java.io.IOException,
                        CodingException
Creates a SignerIdentifier and parses a DER encoded SignerIdentifier from the given input stream.

Parameters:
is - the input stream from which to parse the encoded SignerIdentifier
Throws:
CodingException - if the SignerIdentifier cannot be parsed
java.io.IOException - if an error occurs when reading from the stream
Method Detail

getCertificateIdentifier

public CertificateIdentifier getCertificateIdentifier()
Gets the CertificateIdentifier this SignerIdentifier represents.

Returns:
an IssuerAndSerialNumber or SubjectKeyIdentifier object, depending on the certificate identifier type this SignerIdentifier represents

decode

public void decode(java.io.InputStream is)
            throws CodingException,
                   java.io.IOException
Decodes the SignerIdentifier from the given input stream.

Parameters:
is - the input stream from which to parse the encoded SignerIdentifier
Throws:
CodingException - if the SignerIdentifier cannot be parsed
java.io.IOException - if an error occurs when reading from the stream

decode

public void decode(java.io.InputStream is,
                   boolean keepEncoding)
            throws CodingException,
                   java.io.IOException
Decodes the SignerIdentifier from the given input stream.

Parameters:
is - the input stream from which to parse the encoded SignerIdentifier
keepEncoding - whether to keep the encoding
Throws:
CodingException - if the SignerIdentifier cannot be parsed
java.io.IOException - if an error occurs when reading from the stream

toASN1Object

public ASN1Object toASN1Object()
Returns this SignerIdentifier as ASN1Object.

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

getEncoded

public byte[] getEncoded()
Returns the DER encoded SignerIdentifier.

Returns:
the DER encoded SignerIdentifier

clearEncoded

public void clearEncoded()
Clears the encoded SignerIdentifier.
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.


identifiesCert

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

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

decode

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

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

equals

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

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

hashCode

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

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

getKeyIdType

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

Specified by:
getKeyIdType in interface KeyIdentifier
Returns:
ISSUER_AND_SERIALNUMBER (0) or 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:
"IssuerAndSerialNumber" or "SubjectKeyIdentifier"

toString

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

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

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