Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| IAIK PKCS#11 Wrapper version 1.2.16
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## iaik.pkcs.pkcs11.objects
Class Key

    java.lang.Object
      iaik.pkcs.pkcs11.objects.Object
          iaik.pkcs.pkcs11.objects.Storage
              iaik.pkcs.pkcs11.objects.Key

All Implemented Interfaces:
  Cloneable

Direct Known Subclasses:
  PrivateKey, PublicKey, SecretKey

public class Key
extends Storage

An object of this class represents a key as defined by PKCS#11 2.11. A key is of a specific type: RSA, DSA, DH, ECDSA, EC, X9_42_DH, KEA, GENERIC_SECRET, RC2, RC4, DES, DES2, DES3, CAST, CAST3, CAST5, CAST128, RC5, IDEA, SKIPJACK, BATON, JUNIPER, CDMF, AES or VENDOR_DEFINED. If an application needs to use vendor-defined keys, it must set a VendorDefinedKeyeBuilder using the setVendorDefinedKeyBuilder method.

Invariants
  (keyType_ <> null) and (id_ <> null) and (startDate_ <> null) and (endDate_ <> null) and (derive_ <> null) and (local_ <> null) and (keyGenMechanism_ <> null)

Nested Class Summary
`static interface` | `Key.KeyType` This interface defines the available key types as defined by PKCS#11 2.11: RSA, DSA, DH, ECDSA, KEA, GENERIC_SECRET, RC2, RC4, DES, DES2, DES3, CAST, CAST3, CAST5, CAST128, RC5, IDEA, SKIPJACK, BATON, JUNIPER, CDMF, AES, EC, X9_42_DH or VENDOR_DEFINED.
`static interface` | `Key.VendorDefinedKeyBuilder` If an application uses vendor defined keys, it must implement this interface and install such an object handler using setVendorDefinedKeyBuilder.

Nested classes inherited from class iaik.pkcs.pkcs11.objects.Object
`Object.ObjectClass, Object.VendorDefinedObjectBuilder`

Field Summary
`protected BooleanAttribute` | `derive_` True, if other keys can be derived from this key.
`protected DateAttribute` | `endDate_` The end date of this key's validity.
`protected ByteArrayAttribute` | `id_` The identifier (ID) of this key.
`protected MechanismAttribute` | `keyGenMechanism_` The mechanism used to generate the key material.
`protected KeyTypeAttribute` | `keyType_` The type of this key.
`protected static Hashtable` | `keyTypeNames_` A table holding string representations for all known key types.
`protected BooleanAttribute` | `local_` True, if this key was created (generated or copiedfrom a different key) on the token.
`protected DateAttribute` | `startDate_` The start date of this key's validity.
`protected static Key.VendorDefinedKeyBuilder` | `vendorKeyBuilder_` The currently set vendor defined key builder, or null.

Fields inherited from class iaik.pkcs.pkcs11.objects.Storage
`label_, modifiable_, private_, token_`

Fields inherited from class iaik.pkcs.pkcs11.objects.Object
`attributeTable_, objectClass_, objectClassNames_, objectHandle_, vendorObjectBuilder_`

Constructor Summary
`` | `Key()` The default constructor.
`protected` | `Key(Session session, long objectHandle)` Called by sub-classes to create an instance of a PKCS#11 key.

Method Summary
`protected void` | `allocateAttributes()` Allocates the attribute objects for this class and adds them to the attribute table.
`Object` | `clone()` Create a (deep) clone of this object.
`boolean` | `equals(Object otherObject)` Compares all member variables of this object with the other object.
`BooleanAttribute` | `getDerive()` Check, if other keys can be derived from this key.
`DateAttribute` | `getEndDate()` Gets the end date attribute of the validity of this key.
`ByteArrayAttribute` | `getId()` Gets the ID attribute of this key.
`MechanismAttribute` | `getKeyGenMechanism()` Get the mechanism used to generate the key material for this key.
`LongAttribute` | `getKeyType()` Gets the key type attribute of the PKCS#11 key.
`static String` | `getKeyTypeName(Long keyType)` Get the given key type as string.
`BooleanAttribute` | `getLocal()` Check, if this key is a local key; i.e. was generated on the token or created via copy from a different key on the token.
`DateAttribute` | `getStartDate()` Gets the start date attribute of the validity of this key.
`static Key.VendorDefinedKeyBuilder` | `getVendorDefinedKeyBuilder()` Get the currently set vendor-defined key 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(Key object)` Put all attributes of the given object into the attributes table of this object.
`void` | `readAttributes(Session session)` Read the values of the attributes of this object from the token.
`static void` | `setVendorDefinedKeyBuilder(Key.VendorDefinedKeyBuilder builder)` Set a vendor-defined key builder that should be called to create an instance of an vendor-defined PKCS#11 key; i.e. an instance of a vendor defined sub-class of this class.
`String` | `toString()` This method returns a string representation of the current object.

Methods inherited from class iaik.pkcs.pkcs11.objects.Storage
`getLabel, getModifiable, getPrivate, getToken, putAttributesInTable`

Methods inherited from class iaik.pkcs.pkcs11.objects.Object
`getAttributeTable, getAttributeValue, getInstance, getObjectClass, getObjectClassName, getObjectHandle, getSetAttributes, getSetAttributes, getUnknownObject, getVendorDefinedObjectBuilder, putAttributesInTable, setObjectHandle, setVendorDefinedObjectBuilder`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### vendorKeyBuilder_

    protected static Key.VendorDefinedKeyBuilder vendorKeyBuilder_

  The currently set vendor defined key builder, or null.

### keyTypeNames_

    protected static Hashtable keyTypeNames_

  A table holding string representations for all known key types. Table key is the key type as Long object.

### keyType_

    protected KeyTypeAttribute keyType_

  The type of this key. Its value is one of KeyType, or one that has a bigger value than VENDOR_DEFINED.

### id_

    protected ByteArrayAttribute id_

  The identifier (ID) of this key.

### startDate_

    protected DateAttribute startDate_

  The start date of this key's validity.

### endDate_

    protected DateAttribute endDate_

  The end date of this key's validity.

### derive_

    protected BooleanAttribute derive_

  True, if other keys can be derived from this key.

### local_

    protected BooleanAttribute local_

  True, if this key was created (generated or copiedfrom a different key) on the token.

### keyGenMechanism_

    protected MechanismAttribute keyGenMechanism_

  The mechanism used to generate the key material.

Constructor Detail

### Key

    public Key()

  The default constructor. An application use this constructor to instanciate a key that serves as a template. It may also be useful for working with vendor-defined keys.

Preconditions
Postconditions

### Key

    protected Key(Session session,
                  long objectHandle)
           throws TokenException

  Called by sub-classes to create an instance of a PKCS#11 key.

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.
Preconditions
  (session <> null)
Postconditions

Method Detail

### setVendorDefinedKeyBuilder

    public static void setVendorDefinedKeyBuilder(Key.VendorDefinedKeyBuilder builder)

  Set a vendor-defined key builder that should be called to create an instance of an vendor-defined PKCS#11 key; i.e. an instance of a vendor defined sub-class of this class.

  Parameters:
    `builder` - The vendor-defined key builder. Null to clear any previously installed vendor-defined builder.
  Preconditions
  Postconditions

### getVendorDefinedKeyBuilder

    public static Key.VendorDefinedKeyBuilder getVendorDefinedKeyBuilder()

  Get the currently set vendor-defined key builder.

  Returns:
    The currently set vendor-defined key builder or null if none is set.
  Preconditions
  Postconditions

### getKeyTypeName

    public static String getKeyTypeName(Long keyType)

  Get the given key type as string.

  Parameters:
    `keyType` - The key type to get as string.
  Returns:
    A string denoting the key type; e.g. "RSA".
  Preconditions
    (keyType <> null)
  Postconditions
    (result <> null)

### putAttributesInTable

    protected static void putAttributesInTable(Key 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.
  Preconditions
    (object <> null)
  Postconditions

### allocateAttributes

    protected void allocateAttributes()

  Allocates the attribute objects for this class and adds them to the attribute table.

  Overrides:
    `allocateAttributes` in class `Storage`
  Preconditions
  Postconditions

### clone

    public Object clone()

  Create a (deep) clone of this object.

  Overrides:
    `clone` in class `Storage`
  Returns:
    A clone of this object.
  Preconditions
  Postconditions
    (result <> null) and (result instanceof Key) and (result.equals(this))

### equals

    public boolean equals(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 `Storage`
  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.
  Preconditions
  Postconditions

### getKeyType

    public LongAttribute getKeyType()

  Gets the key type attribute of the PKCS#11 key. Its value must be one of those defined in the KeyType interface or one with an value bigger than KeyType.VENDOR_DEFINED.

  Returns:
    The key type identifier.
  Preconditions
  Postconditions
    (result <> null)

### getId

    public ByteArrayAttribute getId()

  Gets the ID attribute of this key.

  Returns:
    The key identifier attribute.
  Preconditions
  Postconditions
    (result <> null)

### getStartDate

    public DateAttribute getStartDate()

  Gets the start date attribute of the validity of this key.

  Returns:
    The start date of validity.
  Preconditions
  Postconditions
    (result <> null)

### getEndDate

    public DateAttribute getEndDate()

  Gets the end date attribute of the validity of this key.

  Returns:
    The end date of validity.
  Preconditions
  Postconditions
    (result <> null)

### getDerive

    public BooleanAttribute getDerive()

  Check, if other keys can be derived from this key.

  Returns:
    Its value is true, if other keys can be derived from this key.
  Preconditions
  Postconditions
    (result <> null)

### getLocal

    public BooleanAttribute getLocal()

  Check, if this key is a local key; i.e. was generated on the token or created via copy from a different key on the token.

  Returns:
    Its value is true, if the key was created on the token.
  Preconditions
  Postconditions
    (result <> null)

### getKeyGenMechanism

    public MechanismAttribute getKeyGenMechanism()

  Get the mechanism used to generate the key material for this key.

  Returns:
    The mechanism attribute used to generate the key material for this key.
  Preconditions
  Postconditions
    (result <> null)

### 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 `Storage`
  Returns:
    The hash code of this object.
  Preconditions
  Postconditions

### readAttributes

    public void readAttributes(Session session)
                        throws TokenException

  Read the values of the attributes of this object from the token.

  Overrides:
    `readAttributes` in class `Storage`
  Parameters:
    `session` - The session handle 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.
  Throws:
    `TokenException` - If getting the attributes failed.
  Preconditions
    (session <> null)
  Postconditions

### toString

    public 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 `Storage`
  Returns:
    A string presentation of this object for debugging output.
  Preconditions
  Postconditions
    (result <> null)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| IAIK PKCS#11 Wrapper version 1.2.16
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

IAIK JavaSecurity Website http://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2002, IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved.