iaik.smime.attributes
Class SMIMEEncryptionKeyPreference

java.lang.Object
  extended by iaik.asn1.structures.AttributeValue
      extended by iaik.smime.attributes.SMIMEEncryptionKeyPreference
All Implemented Interfaces:
ASN1Type

public class SMIMEEncryptionKeyPreference
extends AttributeValue

The S/MIMEv3 SMIMEEncryptionKeyPreference attribute.

S/MIMEv3 (RFC 5751) specifies the SMIMEEncryptionKeyPreference attribute to may be included as signed attribute in a SignerInfo to identify encryption certificate of the sender by by IssuerAndSerialNumber, or SubjectKeyIdentifier, or RecipientKeyIdentifier

 SMIMEEncryptionKeyPreference ::= CHOICE {
   issuerAndSerialNumber   [0] IssuerAndSerialNumber,
   receipentKeyId          [1] RecipientKeyIdentifier,
   subjectAltKeyIdentifier [2] SubjectKeyIdentifier
 }
 
 id-aa OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840)
    rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) attributes(2)}

 id-aa-encrypKeyPref OBJECT IDENTIFIER ::= {id-aa 11}
 

When creating a SMIMEEncryptionKeyPreference object specify the identifier for the encryption certificate of the sender, e.g.:

 X509Certificate encyrptionCert = ...;
 IssuerAndSerialNumber ias = new IssuerAndSerialNumber(encryptionCert);
 SMIMEEncryptionKeyPreference sMIMEEncryptionKeyPreference = 
   new SMIMEEncryptionKeyPreference(ias);
 

See Also:
IssuerAndSerialNumber, SubjectKeyID, RecipientKeyIdentifier, CertificateIdentifier

Field Summary
static ObjectID oid
          The attributeType object identifier of this SMIMEEncryptionKeyPreference attribute.
 
Constructor Summary
SMIMEEncryptionKeyPreference()
          Empty default constructor.
SMIMEEncryptionKeyPreference(ASN1Object obj)
          Creates an SMIMEEncryptionKeyPreference from its ASN.1 representation.
SMIMEEncryptionKeyPreference(CertificateIdentifier encryptionCertID)
          Creates an SMIMEEncryptionKeyPreference for the given encryption cert identifier.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 SMIMEEncryptionKeyPreference object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this SMIMEEncryptionKeyPreference to the specified object.
 ObjectID getAttributeType()
          Returns the OID identifying the SMIMEEncryptionKeyPreference attribute type.
 CertificateIdentifier getEncryptionCertID()
          Returns the the encryption cert id.
 int hashCode()
          Returns a hashcode for this MSOEEncryptionKeyPreference.
 ASN1Object toASN1Object()
          Returns this SMIMEEncryptionKeyPreference as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this SMIMEEncryptionKeyPreference.
 
Methods inherited from class iaik.asn1.structures.AttributeValue
getName, multipleAllowed
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

oid

public static final ObjectID oid
The attributeType object identifier of this SMIMEEncryptionKeyPreference attribute. The corresponding OID string is "1.2.840.113549.1.9.16.2.11".

Constructor Detail

SMIMEEncryptionKeyPreference

public SMIMEEncryptionKeyPreference()
Empty default constructor. Required for dynamic object creation. Shall NOT be used by an application.


SMIMEEncryptionKeyPreference

public SMIMEEncryptionKeyPreference(CertificateIdentifier encryptionCertID)
Creates an SMIMEEncryptionKeyPreference for the given encryption cert identifier.

Parameters:
encryptionCertID - the certificate identifier identifying the encryption cert of the sender, either by IssuerAndSerialNumber, SubjectKeyIdentifier, or RecipientKeyIdentifier

SMIMEEncryptionKeyPreference

public SMIMEEncryptionKeyPreference(ASN1Object obj)
                             throws CodingException
Creates an SMIMEEncryptionKeyPreference from its ASN.1 representation.

Parameters:
obj - the SMIMEEncryptionKeyPreference as ASN1Object
Throws:
CodingException - if the encoding is invalid
Method Detail

getEncryptionCertID

public CertificateIdentifier getEncryptionCertID()
Returns the the encryption cert id.

Returns:
the certificate identifier identifying the encryption cert of the sender, either by IssuerAndSerialNumber, SubjectKeyIdentifier, or RecipientKeyIdentifier

decode

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

Parameters:
obj - the SMIMEEncryptionKeyPreference as ASN1Object
Throws:
CodingException - if the encoding is invalid

equals

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

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

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this MSOEEncryptionKeyPreference

toASN1Object

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

Returns:
this SMIMEEncryptionKeyPreference as ASN1Object
Throws:
CodingException - if the ASN.1 object cannot be built

getAttributeType

public ObjectID getAttributeType()
Returns the OID identifying the SMIMEEncryptionKeyPreference attribute type.

Specified by:
getAttributeType in class AttributeValue
Returns:
the OID identifying the SMIMEEncryptionKeyPreference attribute type.

toString

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

Specified by:
toString in class AttributeValue
Returns:
this SMIMEEncryptionKeyPreference as string

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