iaik.smime.attributes
Class SMIMECapabilities

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

public class SMIMECapabilities
extends AttributeValue

The S/MIMEv3 SMIMECapabilities attribute.

S/MIMEv3 (RFC 5751) specifies the SMIMECapabilities attribute to may be included as signed attribute in a SignerInfo for announcing the algorithms an S/MIME client is capable to to handle. Any algorithm a client is able to handle is announced by an SMIMECapability object identifying the algorithm by its OID and optionally additionally including parameters for providing information that may be required to differentiate between two instances of the same algorithm (for instance key length for RC2). Any SMimeCapability a client want to announce is collected and included into a SMIMECapabilities attribute in preference order.

 SMIMECapability ::= SEQUENCE {
   capabilityID OBJECT IDENTIFIER,
   parameters ANY DEFINED BY capabilityID OPTIONAL } 
 
 SMIMECapabilities ::= SEQUENCE OF SMIMECapability
 
When creating an SMIMECapabilities object the list of capabilities has to be supplied. The following example shows how to create an SMIMECapabilities attribute containing capabilities announcing that the client is able to handle the RC2 algorithm for key lengths of 128, 64 and 40 bits, in this preference order:
 // RC2 128
 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_128Capability.setParameters(new INTEGER(128));
 // RC2 64
 SMIMECapability rc2_64Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_64Capability.setParameters(new INTEGER(64));
 // RC2 40
 SMIMECapability rc2_40Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_40Capability.setParameters(new INTEGER(40));
 // any further capabilities
 ...
 // add the capabilities in preference order to an SMIMECapabilities attribute:
 SMIMECapability[] capabilities = { ..., rc2_128Capability, rc2_64Capability, rc2_40Capability, ...};
 SMIMECapabilities smimeCapabilities = new SMIMECapabilities(capabilities);
 

See Also:
SMIMECapability

Field Summary
static ObjectID oid
          The attributeType object identifier of this SMIMECapabilities attribute.
 
Constructor Summary
SMIMECapabilities()
          Empty default constructor.
SMIMECapabilities(ASN1Object obj)
          Creates an SMIMECapabilities object from its ASN.1 representation.
SMIMECapabilities(SMIMECapability[] capabilities)
          Creates an SMIMECapabilities attribute for the supplied list of algorithm capabilities to be announced.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 SMIMECapabilities object for parsing the internal structure.
 boolean equals(java.lang.Object obj)
          Compares this SMIMECapabilities to the specified object.
 ObjectID getAttributeType()
          Returns the OID identifying the SMIMECapabilities attribute type.
 SMIMECapability[] getCapabilities()
          Returns the capabilites included.
 SMIMECapability[] getCapabilities(ObjectID capabilityID)
          Returns all capabilities with the same capability ID.
 int hashCode()
          Returns a hashcode for this SMIMECapabilities.
 boolean multipleAllowed()
          Returns false since only one AttributeValue is allowed in the SET OF AttributeValue of an SMIMECapabilities attribute.
 ASN1Object toASN1Object()
          Returns this SMIMECapabilities as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this SMIMECapabilities.
 java.lang.String toString(boolean detailed)
          Returns a string representation of this SMIMECapabilities.
 
Methods inherited from class iaik.asn1.structures.AttributeValue
getName
 
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 SMIMECapabilities attribute. The corresponding OID string is "1.2.840.113549.1.9.16.0.1".

Constructor Detail

SMIMECapabilities

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


SMIMECapabilities

public SMIMECapabilities(SMIMECapability[] capabilities)
Creates an SMIMECapabilities attribute for the supplied list of algorithm capabilities to be announced.

Parameters:
capabilities - the algorithm capabilities to be announced

SMIMECapabilities

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

Parameters:
obj - the SMIMECapabilities as ASN1Object
Throws:
CodingException - if an error occurs while parsing the ASN.1 object
Method Detail

getCapabilities

public SMIMECapability[] getCapabilities()
Returns the capabilites included.

Returns:
all capabilities included in this SMIMECapabilities attribute or null if no capabilities are included

getCapabilities

public SMIMECapability[] getCapabilities(ObjectID capabilityID)
Returns all capabilities with the same capability ID.

This method may be used for getting all included SMIMECapability objects belonging to the same algorithm but possibly having different algorithm parameters.

Parameters:
capabilityID - the OID identifying the algorithm in mind
Returns:
all capabilities having the given capabilityID or null if no capabilities with the requested ID are included

decode

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

Parameters:
obj - the SMIMECapabilities as ASN1Object
Throws:
CodingException - if an error occurs while parsing the ASN.1 object

toASN1Object

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

Returns:
this SMIMECapabilities as ASN1Object
Throws:
CodingException

getAttributeType

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

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

equals

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

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

multipleAllowed

public boolean multipleAllowed()
Returns false since only one AttributeValue is allowed in the SET OF AttributeValue of an SMIMECapabilities attribute.

Overrides:
multipleAllowed in class AttributeValue
Returns:
false since only one attribute value is allowed

hashCode

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

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

toString

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

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

toString

public java.lang.String toString(boolean detailed)
Returns a string representation of this SMIMECapabilities.

Parameters:
detailed - whether to print more detailed information
Returns:
this SMIMECapabilities as string

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