iaik.cms
Class OtherKeyAttribute

java.lang.Object
  extended by iaik.cms.OtherKeyAttribute
All Implemented Interfaces:
ASN1Type

public class OtherKeyAttribute
extends java.lang.Object
implements ASN1Type

This class implements the CMS OtherKeyAttribute type.

The Cryptographic Message Syntax (CMS) (RFC 5652) specifies the OtherKeyAttribute type for supplying additional information to be used for key identification. Generally the usage of the OtherKeyAttribute type should be avoided. The ASN.1 structure consists of an object identifier and an optional key attribute identified by the object identifier (key attribute ID):

 OtherKeyAttribute ::= SEQUENCE {     
   keyAttrId OBJECT IDENTIFIER,
   keyAttr ANY DEFINED BY keyAttrId OPTIONAL }
 
This class includes a static part to be used for registering implementations for particular key attributes. A key attribute may be implemented by extending the abstract KeyAttribute class and registering it by calling the static register method, e.g.:
 public class MyKeyAttribute extends KeyAttribute {
 ...
 // the key attribute id:
   public static final ObjectID keyAttrID = ...;
 ...
 }
 ...
 // register the implementation:
 OtherKeyAttribute.register(MyKeyAttribute.keyAttrID, MyKeyAttribute.class);
 
Key Attributes for which no implementation have been registered are treated as unknown key attributes.

See Also:
KeyAttribute, UnknownKeyAttribute

Constructor Summary
OtherKeyAttribute()
          Default Constructor.
OtherKeyAttribute(ASN1Object obj)
          Creates an OtherKeyAttribute from an ASN1Object.
OtherKeyAttribute(KeyAttribute keyAttribute)
          Creates an OtherKeyAttribute from the supplied KeyAttribute.
OtherKeyAttribute(ObjectID keyAttrID)
          Creates an OtherKeyAttribute for the supplied key attribute ID.
 
Method Summary
static KeyAttribute create(ObjectID keyAttrID)
          Returns the implementation of the key attribute defined through an ASN.1 ObjectID.
 void decode(ASN1Object obj)
          Decodes an OtherKeyAttribute from its ASN.1 representation.
 boolean equals(java.lang.Object obj)
          Compares this OtherKeyAttribute to the specified object.
 KeyAttribute getKeyAttribute()
          Gets the KeyAttribute component of this OtherKeyAttribute.
 ObjectID getKeyAttributeID()
          Gets the key attribute ID of this OtherKeyAttribute.
 int hashCode()
          Returns a hashcode for this object.
static void register(ObjectID keyAttrID, java.lang.Class cl)
          Registers a new implementation for a key attribute.
 ASN1Object toASN1Object()
          Returns this OtherKeyAttribute as ASN1Object.
 java.lang.String toString()
          Returns a String representation of this OtherKeyAttribute.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OtherKeyAttribute

public OtherKeyAttribute()
Default Constructor. Creates an empty OtherKeyAttribute. This constructor only is used for dynamic object creation and shall not be used by an application.


OtherKeyAttribute

public OtherKeyAttribute(ObjectID keyAttrID)
Creates an OtherKeyAttribute for the supplied key attribute ID. This constructor may be used for creating a OtherKeyAttribute having no KeyAttribute.

Parameters:
keyAttrID - the key attribute ID of this OtherKeyAttribute

OtherKeyAttribute

public OtherKeyAttribute(KeyAttribute keyAttribute)
Creates an OtherKeyAttribute from the supplied KeyAttribute. The key attribute ID is obtained from the supplied KeyAttribute.

Parameters:
keyAttribute - the KeyAttribute component of this OtherKeyAttribute

OtherKeyAttribute

public OtherKeyAttribute(ASN1Object obj)
                  throws CodingException
Creates an OtherKeyAttribute from an ASN1Object.

Parameters:
obj - the OtherKeyAttribute as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be parsed
Method Detail

create

public static KeyAttribute create(ObjectID keyAttrID)
                           throws java.lang.InstantiationException
Returns the implementation of the key attribute defined through an ASN.1 ObjectID.

This method belongs to the static part of this class.

Parameters:
keyAttrID - the ObjectID of the key attribute.
Returns:
the implementation of the key attribute with this key attribute ID
Throws:
java.lang.InstantiationException - if the internal factory could not create an instance of requested type

register

public static void register(ObjectID keyAttrID,
                            java.lang.Class cl)
Registers a new implementation for a key attribute. This method belongs to the static part of this class.

Parameters:
keyAttrID - the key attribute ID of the key attribute to be registered
cl - the class which implements this key attribute

getKeyAttribute

public KeyAttribute getKeyAttribute()
Gets the KeyAttribute component of this OtherKeyAttribute.

Returns:
the KeyAttribute component of this OtherKeyAttribute

getKeyAttributeID

public ObjectID getKeyAttributeID()
Gets the key attribute ID of this OtherKeyAttribute.

Returns:
the key attribute ID of this OtherKeyAttribute

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes an OtherKeyAttribute from its ASN.1 representation. This method parses the key attribute id from the supplied ASN.1 representation and tries -- if a KeyAttribute is included -- to find an registered KeyAttribute implementation for the parsed key attribute ID. If no KeyAttribute implementation can be found, a UnknownKeyAttribute object is created for the unknown KeyAttribute allowing to query for information about the KeyAttribute.

Specified by:
decode in interface ASN1Type
Parameters:
obj - the OtherKeyAttribute as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be parsed

toASN1Object

public ASN1Object toASN1Object()
Returns this OtherKeyAttribute as ASN1Object.

Specified by:
toASN1Object in interface ASN1Type
Returns:
this OtherKeyAttribute as ASN1Object.

equals

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

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

hashCode

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

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

toString

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

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this OtherKeyAttribute

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