IAIK PKCS#11 Wrapper
version 1.5

iaik.pkcs.pkcs11.objects
Class Attribute

java.lang.Object
  |
  +--iaik.pkcs.pkcs11.objects.Attribute
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AttributeArray, BooleanAttribute, ByteArrayAttribute, CharArrayAttribute, DateAttribute, LongAttribute, MechanismArrayAttribute, OtherAttribute

public abstract class Attribute
extends java.lang.Object
implements java.lang.Cloneable

This is the base-class for all types of attributes. In general, all PKCS#11 objects are just a collection of attributes. PKCS#11 specifies which attributes each type of objects must have. In some cases, attributes are optional (e.g. in RSAPrivateKey). In such a case, this attribute will return false when the application calls isPresent() on this attribute. This means, that the object does not possess this attribute (maybe even though it should, but not all drivers seem to implement the standard correctly). Handling attributes in this fashion ensures that this library can work also with drivers that are not fully compliant. Moreover, certain attributes can be sensitive; i.e. their values cannot be read, e.g. the private exponent of a RSA private key.

Version:
1.0
Author:
Karl Scheibelhofer

Field Summary
static java.lang.Long AC_ISSUER
           
static java.lang.Long ALLOWED_MECHANISMS
           
static java.lang.Long ALWAYS_AUTHENTICATE
           
static java.lang.Long ALWAYS_SENSITIVE
           
static java.lang.Long APPLICATION
           
static java.lang.Long ATTR_TYPES
           
protected static java.util.Hashtable attributeClasses_
           
protected static java.util.Hashtable attributeNames_
           
static java.lang.Long AUTH_PIN_FLAGS
           
static java.lang.Long BASE
           
static java.lang.Long BITS_PER_PIXEL
           
static java.lang.Long CERTIFICATE_CATEGORY
           
static java.lang.Long CERTIFICATE_TYPE
           
static java.lang.Long CHAR_COLUMNS
           
static java.lang.Long CHAR_ROWS
           
static java.lang.Long CHAR_SETS
           
static java.lang.Long CHECK_VALUE
           
protected  CK_ATTRIBUTE ckAttribute_
          The CK_ATTRIBUTE that is used to hold the PKCS#11 type of this attribute and the value.
static java.lang.Long CLASS
           
static java.lang.Long COEFFICIENT
           
static java.lang.Long COLOR
           
static java.lang.Long DECRYPT
           
static java.lang.Long DERIVE
           
static java.lang.Long EC_PARAMS
           
static java.lang.Long EC_POINT
           
static java.lang.Long ECDSA_PARAMS
           
static java.lang.Long ENCODING_METHODS
           
static java.lang.Long ENCRYPT
           
static java.lang.Long END_DATE
           
static java.lang.Long EXPONENT_1
           
static java.lang.Long EXPONENT_2
           
static java.lang.Long EXTRACTABLE
           
static java.lang.Long HAS_RESET
           
static java.lang.Long HASH_OF_ISSUER_PUBLIC_KEY
           
static java.lang.Long HASH_OF_SUBJECT_PUBLIC_KEY
           
static java.lang.Long HW_FEATURE_TYPE
           
static java.lang.Long ID
           
static java.lang.Long ISSUER
           
static java.lang.Long JAVA_MIDP_SECURITY_DOMAIN
           
static java.lang.Long KEY_GEN_MECHANISM
           
static java.lang.Long KEY_TYPE
           
static java.lang.Long LABEL
           
static java.lang.Long LOCAL
           
static java.lang.Long MECHANISM_TYPE
           
static java.lang.Long MIME_TYPES
           
static java.lang.Long MODIFIABLE
           
static java.lang.Long MODULUS
           
static java.lang.Long MODULUS_BITS
           
static java.lang.Long NEVER_EXTRACTABLE
           
static java.lang.Long OBJECT_ID
           
static java.lang.Long OWNER
           
static java.lang.Long PIXEL_X
           
static java.lang.Long PIXEL_Y
           
protected  boolean present_
          True, if the object really possesses this attribute.
static java.lang.Long PRIME
           
static java.lang.Long PRIME_1
           
static java.lang.Long PRIME_2
           
static java.lang.Long PRIME_BITS
           
static java.lang.Long PRIVATE
           
static java.lang.Long PRIVATE_EXPONENT
           
static java.lang.Long PUBLIC_EXPONENT
           
static java.lang.Long RESET_ON_INIT
           
static java.lang.Long RESOLUTION
           
static java.lang.Long SECONDARY_AUTH
           
static java.lang.Long SENSITIVE
           
protected  boolean sensitive_
          True, if this attribute is sensitive.
static java.lang.Long SERIAL_NUMBER
           
static java.lang.Long SIGN
           
static java.lang.Long SIGN_RECOVER
           
static java.lang.Long START_DATE
           
protected  boolean stateKnown_
          True, if this attribute's status (i.e.
static java.lang.Long SUB_PRIME_BITS
           
static java.lang.Long SUBJECT
           
static java.lang.Long SUBPRIME
           
static java.lang.Long TOKEN
           
static java.lang.Long TRUSTED
           
static java.lang.Long UNWRAP
           
static java.lang.Long UNWRAP_TEMPLATE
           
static java.lang.Long URL
           
static java.lang.Long VALUE
           
static java.lang.Long VALUE_BITS
           
static java.lang.Long VALUE_LEN
           
static java.lang.Long VENDOR_DEFINED
           
static java.lang.Long VERIFY
           
static java.lang.Long VERIFY_RECOVER
           
static java.lang.Long WRAP
           
static java.lang.Long WRAP_TEMPLATE
           
static java.lang.Long WRAP_WITH_TRUSTED
           
 
Constructor Summary
protected Attribute()
          Empty constructor.
protected Attribute(java.lang.Long type)
          Constructor taking the PKCS#11 type of the attribute.
 
Method Summary
 java.lang.Object clone()
          Create a (deep) clone of this object.
 boolean equals(java.lang.Object otherObject)
          True, if both attributes are not present or if both attributes are present and all other member variables are equal.
protected  boolean equalsValue(java.lang.Object otherObject)
          True, if both attribute values are null or if both attribute values are equal.
protected static java.lang.Class getAttributeClass(java.lang.Long type)
          Get the class of the given attribute type.
protected static java.lang.String getAttributeName(java.lang.Long type)
          Get the name of the given attribute type.
protected  CK_ATTRIBUTE getCkAttribute()
          Get the CK_ATTRIBUTE object of this Attribute that contains the attribute type and value .
 java.lang.Long getType()
          Get the PKCS#11 type of this attribute.
protected  java.lang.String getValueString()
          Get a string representation of the value of this attribute.
 int hashCode()
          The overriding of this method should ensure that the objects of this class work correctly in a hashtable.
 boolean isPresent()
          Check, if this attribute is really present in the associated object.
 boolean isSensitive()
          Check, if this attribute is sensitive in the associated object.
 boolean isStateKnown()
          Check, if this attribute's status is known.
protected  void setCkAttribute(CK_ATTRIBUTE ckAttribute)
          Set the CK_ATTRIBUTE of this Attribute.
 void setPresent(boolean present)
          Set, if this attribute is really present in the associated object.
 void setSensitive(boolean sensitive)
          Set, if this attribute is sensitive in the associated object.
protected  void setType(java.lang.Long type)
          Set the PKCS#11 type of this attribute.
abstract  void setValue(java.lang.Object value)
          Redirects the request for setting the attribute value to the implementing attribute class.
 java.lang.String toString()
          Get a string representation of this attribute.
 java.lang.String toString(boolean withName)
          Get a string representation of this attribute.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS

public static final java.lang.Long CLASS

TOKEN

public static final java.lang.Long TOKEN

PRIVATE

public static final java.lang.Long PRIVATE

LABEL

public static final java.lang.Long LABEL

APPLICATION

public static final java.lang.Long APPLICATION

VALUE

public static final java.lang.Long VALUE

OBJECT_ID

public static final java.lang.Long OBJECT_ID

CERTIFICATE_TYPE

public static final java.lang.Long CERTIFICATE_TYPE

ISSUER

public static final java.lang.Long ISSUER

SERIAL_NUMBER

public static final java.lang.Long SERIAL_NUMBER

URL

public static final java.lang.Long URL

HASH_OF_SUBJECT_PUBLIC_KEY

public static final java.lang.Long HASH_OF_SUBJECT_PUBLIC_KEY

HASH_OF_ISSUER_PUBLIC_KEY

public static final java.lang.Long HASH_OF_ISSUER_PUBLIC_KEY

JAVA_MIDP_SECURITY_DOMAIN

public static final java.lang.Long JAVA_MIDP_SECURITY_DOMAIN

AC_ISSUER

public static final java.lang.Long AC_ISSUER

OWNER

public static final java.lang.Long OWNER

ATTR_TYPES

public static final java.lang.Long ATTR_TYPES

TRUSTED

public static final java.lang.Long TRUSTED

KEY_TYPE

public static final java.lang.Long KEY_TYPE

SUBJECT

public static final java.lang.Long SUBJECT

ID

public static final java.lang.Long ID

CHECK_VALUE

public static final java.lang.Long CHECK_VALUE

CERTIFICATE_CATEGORY

public static final java.lang.Long CERTIFICATE_CATEGORY

SENSITIVE

public static final java.lang.Long SENSITIVE

ENCRYPT

public static final java.lang.Long ENCRYPT

DECRYPT

public static final java.lang.Long DECRYPT

WRAP

public static final java.lang.Long WRAP

WRAP_TEMPLATE

public static final java.lang.Long WRAP_TEMPLATE

UNWRAP

public static final java.lang.Long UNWRAP

UNWRAP_TEMPLATE

public static final java.lang.Long UNWRAP_TEMPLATE

SIGN

public static final java.lang.Long SIGN

SIGN_RECOVER

public static final java.lang.Long SIGN_RECOVER

VERIFY

public static final java.lang.Long VERIFY

VERIFY_RECOVER

public static final java.lang.Long VERIFY_RECOVER

DERIVE

public static final java.lang.Long DERIVE

START_DATE

public static final java.lang.Long START_DATE

END_DATE

public static final java.lang.Long END_DATE

MECHANISM_TYPE

public static final java.lang.Long MECHANISM_TYPE

MODULUS

public static final java.lang.Long MODULUS

MODULUS_BITS

public static final java.lang.Long MODULUS_BITS

PUBLIC_EXPONENT

public static final java.lang.Long PUBLIC_EXPONENT

PRIVATE_EXPONENT

public static final java.lang.Long PRIVATE_EXPONENT

PRIME_1

public static final java.lang.Long PRIME_1

PRIME_2

public static final java.lang.Long PRIME_2

EXPONENT_1

public static final java.lang.Long EXPONENT_1

EXPONENT_2

public static final java.lang.Long EXPONENT_2

COEFFICIENT

public static final java.lang.Long COEFFICIENT

PRIME

public static final java.lang.Long PRIME

SUBPRIME

public static final java.lang.Long SUBPRIME

BASE

public static final java.lang.Long BASE

PRIME_BITS

public static final java.lang.Long PRIME_BITS

SUB_PRIME_BITS

public static final java.lang.Long SUB_PRIME_BITS

VALUE_BITS

public static final java.lang.Long VALUE_BITS

VALUE_LEN

public static final java.lang.Long VALUE_LEN

EXTRACTABLE

public static final java.lang.Long EXTRACTABLE

LOCAL

public static final java.lang.Long LOCAL

NEVER_EXTRACTABLE

public static final java.lang.Long NEVER_EXTRACTABLE

WRAP_WITH_TRUSTED

public static final java.lang.Long WRAP_WITH_TRUSTED

ALWAYS_SENSITIVE

public static final java.lang.Long ALWAYS_SENSITIVE

ALWAYS_AUTHENTICATE

public static final java.lang.Long ALWAYS_AUTHENTICATE

KEY_GEN_MECHANISM

public static final java.lang.Long KEY_GEN_MECHANISM

ALLOWED_MECHANISMS

public static final java.lang.Long ALLOWED_MECHANISMS

MODIFIABLE

public static final java.lang.Long MODIFIABLE

ECDSA_PARAMS

public static final java.lang.Long ECDSA_PARAMS

EC_PARAMS

public static final java.lang.Long EC_PARAMS

EC_POINT

public static final java.lang.Long EC_POINT

SECONDARY_AUTH

public static final java.lang.Long SECONDARY_AUTH

AUTH_PIN_FLAGS

public static final java.lang.Long AUTH_PIN_FLAGS

HW_FEATURE_TYPE

public static final java.lang.Long HW_FEATURE_TYPE

RESET_ON_INIT

public static final java.lang.Long RESET_ON_INIT

HAS_RESET

public static final java.lang.Long HAS_RESET

VENDOR_DEFINED

public static final java.lang.Long VENDOR_DEFINED

PIXEL_X

public static final java.lang.Long PIXEL_X

PIXEL_Y

public static final java.lang.Long PIXEL_Y

RESOLUTION

public static final java.lang.Long RESOLUTION

CHAR_ROWS

public static final java.lang.Long CHAR_ROWS

CHAR_COLUMNS

public static final java.lang.Long CHAR_COLUMNS

COLOR

public static final java.lang.Long COLOR

BITS_PER_PIXEL

public static final java.lang.Long BITS_PER_PIXEL

CHAR_SETS

public static final java.lang.Long CHAR_SETS

ENCODING_METHODS

public static final java.lang.Long ENCODING_METHODS

MIME_TYPES

public static final java.lang.Long MIME_TYPES

attributeNames_

protected static java.util.Hashtable attributeNames_

attributeClasses_

protected static java.util.Hashtable attributeClasses_

present_

protected boolean present_
True, if the object really possesses this attribute.

sensitive_

protected boolean sensitive_
True, if this attribute is sensitive.

stateKnown_

protected boolean stateKnown_
True, if this attribute's status (i.e. if it is present and sensitive) is known.

ckAttribute_

protected CK_ATTRIBUTE ckAttribute_
The CK_ATTRIBUTE that is used to hold the PKCS#11 type of this attribute and the value.
Constructor Detail

Attribute

protected Attribute()
Empty constructor. Attention! If you use this constructor, you must set ckAttribute_ to ensure that the class invariant is not violated.

Attribute

protected Attribute(java.lang.Long type)
Constructor taking the PKCS#11 type of the attribute.
Parameters:
type - The PKCS'11 type of this attribute; e.g. PKCS11Constants.CKA_PRIVATE.
Method Detail

getAttributeName

protected static java.lang.String getAttributeName(java.lang.Long type)
Get the name of the given attribute type.
Parameters:
type - The attribute type.
Returns:
The name of the attribute type, or null if there is no such type.

getAttributeClass

protected static java.lang.Class getAttributeClass(java.lang.Long type)
Get the class of the given attribute type. Current existing Attribute classes are: AttributeArray BooleanAttribute ByteArrayAttribute CertificateTypeAttribute CharArrayAttribute DateAttribute HardwareFeatureTypeAttribute KeyTypeAttribute LongAttribute MechanismAttribute MechanismArrayAttribute ObjectClassAttribute
Parameters:
type - The attribute type.
Returns:
The class of the attribute type, or null if there is no such type.

clone

public java.lang.Object clone()
Create a (deep) clone of this object.
Overrides:
clone in class java.lang.Object
Returns:
A clone of this object.

setPresent

public void setPresent(boolean present)
Set, if this attribute is really present in the associated object. Does only make sense if used in combination with template objects.
Parameters:
present - True, if attribute is present.

setSensitive

public void setSensitive(boolean sensitive)
Set, if this attribute is sensitive in the associated object. Does only make sense if used in combination with template objects.
Parameters:
sensitive - True, if attribute is sensitive.

setValue

public abstract void setValue(java.lang.Object value)
                       throws java.lang.UnsupportedOperationException
Redirects the request for setting the attribute value to the implementing attribute class.
Parameters:
value - the new value
Throws:
ClassCastException - the given value type is not valid for this very Attribute.
java.lang.UnsupportedOperationException - the OtherAttribute implementation does not support setting a value directly.

setCkAttribute

protected void setCkAttribute(CK_ATTRIBUTE ckAttribute)
Set the CK_ATTRIBUTE of this Attribute. Only for internal use.
Parameters:
ckAttribute - The new CK_ATTRIBUTE of this Attribute.

isPresent

public boolean isPresent()
Check, if this attribute is really present in the associated object.
Returns:
True, if this attribute is really present in the associated object.

isSensitive

public boolean isSensitive()
Check, if this attribute is sensitive in the associated object.
Returns:
True, if this attribute is sensitive in the associated object.

isStateKnown

public boolean isStateKnown()
Check, if this attribute's status is known. Returns true, if this attribute's value could be read from the token or the reason for an unavailable value is known (either not present or sensitive). Returns false, if the value could not be read from the token but it is not known whether the attribute is sensitive or not present at all. Some attribute values may not be available and the reason (not present or sensitive) is not checked by default for better performance. Note: If status is not known and this method returns false, this automatically means that the attribute's value is not available.
Returns:
True, if this attribute's status has already been determined.

getCkAttribute

protected CK_ATTRIBUTE getCkAttribute()
Get the CK_ATTRIBUTE object of this Attribute that contains the attribute type and value .
Returns:
The CK_ATTRIBUTE of this Attribute.

getValueString

protected java.lang.String getValueString()
Get a string representation of the value of this attribute.
Returns:
A string representation of the value of this attribute.

toString

public java.lang.String toString()
Get a string representation of this attribute. If the attribute is not present or if it is sensitive, the output of this method shows just a message telling this. This string does not contain the attribute's type name.
Overrides:
toString in class java.lang.Object
Returns:
A string representation of the value of this attribute.

toString

public java.lang.String toString(boolean withName)
Get a string representation of this attribute. If the attribute is not present or if it is sensitive, the output of this method shows just a message telling this.
Parameters:
withName - If true, the string contains the attribute type name and the value. If false, it just contains the value.
Returns:
A string representation of this attribute.

setType

protected void setType(java.lang.Long type)
Set the PKCS#11 type of this attribute.
Parameters:
type - The PKCS#11 type of this attribute.

getType

public java.lang.Long getType()
Get the PKCS#11 type of this attribute.
Returns:
The PKCS#11 type of this attribute.

equals

public boolean equals(java.lang.Object otherObject)
True, if both attributes are not present or if both attributes are present and all other member variables are equal. False, otherwise.
Overrides:
equals in class java.lang.Object
Parameters:
otherObject - The other object to compare to.
Returns:
True, if both attributes are not present or if both attributes are present and all other member variables are equal. False, otherwise.

equalsValue

protected boolean equalsValue(java.lang.Object otherObject)
True, if both attribute values are null or if both attribute values are equal. False, otherwise.
Parameters:
otherObject - The other object to compare to.
Returns:
True, if both attribute values are null or if both attribute values are equal. False, otherwise.

hashCode

public int hashCode()
The overriding of this method should ensure that the objects of this class work correctly in a hashtable.
Overrides:
hashCode in class java.lang.Object
Returns:
The hash code of this object.

IAIK PKCS#11 Wrapper
version 1.5

IAIK JavaSecurity Website http://jce.iaik.tugraz.at/

IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2004, IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved.
version 1.5