IAIK PKCS#11 Wrapper
version 1.5

iaik.pkcs.pkcs11.objects
Class HardwareFeature

java.lang.Object
  |
  +--iaik.pkcs.pkcs11.objects.Object
        |
        +--iaik.pkcs.pkcs11.objects.HardwareFeature
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Clock, MonotonicCounter, UserInterface

public class HardwareFeature
extends Object

This is the base class for hardware feature classes. Objects of this class represent hardware features as specified by PKCS#11 v2.20. A hardware feature is of a specific type: MONOTONIC_COUNTER, CLOCK, CKH_USER_INTERFAC or VENDOR_DEFINED. If an application needs to use vendor-defined hardware features, it must set a VendorDefinedHardwareFeatureBuilder using the setVendorDefinedHardwareFeatureBuilder method.

Version:
1.0
Author:
Karl Scheibelhofer

Inner Class Summary
static interface HardwareFeature.FeatureType
          This interface defines the available hardware feature types as defined by PKCS#11 2.20: MONOTONIC_COUNTER, CLOCK, CKH_USER_INTERFAC or VENDOR_DEFINED.
static interface HardwareFeature.VendorDefinedHardwareFeatureBuilder
          If an application uses vendor defined hardware features, it must implement this interface and install such an object handler using setVendorDefinedHardwareFeatureBuilder.
 
Inner classes inherited from class iaik.pkcs.pkcs11.objects.Object
Object.ObjectClass, Object.VendorDefinedObjectBuilder
 
Field Summary
protected  HardwareFeatureTypeAttribute hardwareFeatureType_
          The type of this hardware feature.
protected static HardwareFeature.VendorDefinedHardwareFeatureBuilder vendorHardwareFeatureBuilder_
          The currently set vendor defined hardware feature builder, or null.
 
Fields inherited from class iaik.pkcs.pkcs11.objects.Object
attributeTable_, objectClass_, objectClassNames_, objectHandle_, vendorObjectBuilder_
 
Constructor Summary
  HardwareFeature()
          The default constructor.
protected HardwareFeature(Session session, long objectHandle)
          Called by getInstance to create an instance of a PKCS#11 hardware feature.
 
Method Summary
protected  void allocateAttributes()
          Allocates the attribute objects for this class and adds them to the attribute table.
 java.lang.Object clone()
          Create a (deep) clone of this object.
 boolean equals(java.lang.Object otherObject)
          Compares all member variables of this object with the other object.
 LongAttribute getHardwareFeatureType()
          Gets the hardware feature type attribute of the PKCS#11 key.
static java.lang.String getHardwareFeatureTypeName(java.lang.Long hardwareFeatureType)
          Get the given hardware feature type as string.
static Object getInstance(Session session, long objectHandle)
          Called by sub-classes to create an instance of a PKCS#11 hardware feature.
protected static Object getUnknownHardwareFeature(Session session, long objectHandle)
          Try to create a hardware feature which has no or an unkown harware feature type attribute.
static HardwareFeature.VendorDefinedHardwareFeatureBuilder getVendorDefinedHardwareFeatureBuilder()
          Get the currently set vendor-defined hardware feature builder.
 int hashCode()
          The overriding of this method should ensure that the objects of this class work correctly in a hashtable.
protected static void putAttributesInTable(HardwareFeature object)
          Put all attributes of the given object into the attributes table of this object.
static void setVendorDefinedHardwareFeatureBuilder(HardwareFeature.VendorDefinedHardwareFeatureBuilder builder)
          Set a vendor-defined hardware feature builder that should be called to create an* instance of an vendor-defined PKCS#11 hardware feature; i.e.
 java.lang.String toString()
          This method returns a string representation of the current object.
 
Methods inherited from class iaik.pkcs.pkcs11.objects.Object
checkAttributesState, checkAttributeState, getAttribute, getAttributeTable, getAttributeValue, getAttributeValues, getObjectClass, getObjectClassName, getObjectHandle, getSetAttributes, getSetAttributes, getUnknownObject, getVendorDefinedObjectBuilder, putAttribute, putAttributesInTable, readAttributes, removeAttribute, setObjectHandle, setVendorDefinedObjectBuilder, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

vendorHardwareFeatureBuilder_

protected static HardwareFeature.VendorDefinedHardwareFeatureBuilder vendorHardwareFeatureBuilder_
The currently set vendor defined hardware feature builder, or null.

hardwareFeatureType_

protected HardwareFeatureTypeAttribute hardwareFeatureType_
The type of this hardware feature. Its value is one of FeatureType, or one that has a bigger value than VENDOR_DEFINED.
Constructor Detail

HardwareFeature

public HardwareFeature()
The default constructor. An application use this constructor to instanciate a hardware feature that serves as a template. It may also be useful for working with vendor-defined hardware features.

HardwareFeature

protected HardwareFeature(Session session,
                          long objectHandle)
                   throws TokenException
Called by getInstance to create an instance of a PKCS#11 hardware feature.
Parameters:
session - The session to use for reading attributes. This session must have the appropriate rights; i.e. it must be a user-session, if it is a private object.
objectHandle - The object handle as given from the PKCS#111 module.
Throws:
TokenException - If getting the attributes failed.
Method Detail

getHardwareFeatureTypeName

public static java.lang.String getHardwareFeatureTypeName(java.lang.Long hardwareFeatureType)
Get the given hardware feature type as string.
Parameters:
hardwareFeatureType - The hardware feature type to get as string.
Returns:
A string denoting the object hardware feature type; e.g. "Clock".

getInstance

public static Object getInstance(Session session,
                                 long objectHandle)
                          throws TokenException
Called by sub-classes to create an instance of a PKCS#11 hardware feature. This method reads the hardware feature type attribute and calls the getInstance method of the according sub-class. If the hardware feature type is a vendor defined it uses the VendorDefinedHardwareFeatureBuilder set by the application. If no hardware feature could be constructed, this method returns null.
Parameters:
session - The session to use for reading attributes. This session must have the appropriate rights; i.e. it must be a user-session, if it is a private object.
objectHandle - The object handle as given from the PKCS#111 module.
Returns:
The object representing the PKCS#11 object. The returned object can be casted to the according sub-class.
Throws:
TokenException - If getting the attributes failed.

getUnknownHardwareFeature

protected static Object getUnknownHardwareFeature(Session session,
                                                  long objectHandle)
                                           throws TokenException
Try to create a hardware feature which has no or an unkown harware feature type attribute. This implementation will try to use a vendor defined hardware feature builder, if such has been set. If this is impossible or fails, it will create just a simple HardwareFeature.
Parameters:
session - The session to use.
objectHandle - The handle of the object
Returns:
A new Object.
Throws:
TokenException - If no object could be created.

setVendorDefinedHardwareFeatureBuilder

public static void setVendorDefinedHardwareFeatureBuilder(HardwareFeature.VendorDefinedHardwareFeatureBuilder builder)
Set a vendor-defined hardware feature builder that should be called to create an* instance of an vendor-defined PKCS#11 hardware feature; i.e. an instance of a vendor defined sub-class of this class.
Parameters:
builder - The vendor-defined hardware feature builder. Null to clear any previously installed vendor-defined builder.

getVendorDefinedHardwareFeatureBuilder

public static HardwareFeature.VendorDefinedHardwareFeatureBuilder getVendorDefinedHardwareFeatureBuilder()
Get the currently set vendor-defined hardware feature builder.
Returns:
The currently set vendor-defined hardware feature builder or null if none is set.

putAttributesInTable

protected static void putAttributesInTable(HardwareFeature object)
Put all attributes of the given object into the attributes table of this object. This method is only static to be able to access invoke the implementation of this method for each class separately (see use in clone()).
Parameters:
object - The object to handle.

allocateAttributes

protected void allocateAttributes()
Allocates the attribute objects for this class and adds them to the attribute table.
Overrides:
allocateAttributes in class Object

clone

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

equals

public boolean equals(java.lang.Object otherObject)
Compares all member variables of this object with the other object. Returns only true, if all are equal in both objects.
Overrides:
equals in class Object
Parameters:
otherObject - The other object to compare to.
Returns:
True, if other is an instance of this class and all member variables of both objects are equal. False, otherwise.

getHardwareFeatureType

public LongAttribute getHardwareFeatureType()
Gets the hardware feature type attribute of the PKCS#11 key. Its value must be one of those defined in the FeatureType interface or one with an value bigger than FeatureType.VENDOR_DEFINED.
Returns:
The hardware feature type identifier.

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 Object
Returns:
The hash code of this object.

toString

public java.lang.String toString()
This method returns a string representation of the current object. The output is only for debugging purposes and should not be used for other purposes.
Overrides:
toString in class Object
Returns:
A string presentation of this object for debugging output.

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