public class Key extends Storage
| Modifier and Type | Class and Description |
|---|---|
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.
|
Object.ObjectClass, Object.VendorDefinedObjectBuilder| Modifier and Type | Field and Description |
|---|---|
protected MechanismArrayAttribute |
allowedMechanisms_
The list of mechanism that can be used with this key.
|
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 java.util.Hashtable |
keyTypeNames_
A table holding string representations for all known key types.
|
protected BooleanAttribute |
local_
True, if this key was created (generated or copied from 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.
|
label_, modifiable_, private_, token_attributeTable_, objectClass_, objectClassNames_, objectHandle_, vendorObjectBuilder_| Modifier | Constructor and Description |
|---|---|
|
Key()
The default constructor.
|
protected |
Key(Session session,
long objectHandle)
Called by sub-classes to create an instance of a PKCS#11 key.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
MechanismArrayAttribute |
getAllowedMechanisms()
Get the list of mechanisms that are allowed to use with this key.
|
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 java.lang.String |
getKeyTypeName(java.lang.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.
|
boolean |
isDerivable()
Check whether this key's derive attribute is set to true.
|
boolean |
isDerive()
Check whether this key's derive attribute is set to true.
|
boolean |
isLocal()
Check whether this key's local attribute is set to true.
|
protected static void |
putAttributesInTable(Key object)
Put all attributes of the given object into the attributes table of this object.
|
Mechanism[] |
readAllowedMechanisms()
Read the value of the allowed mechanisms attribute.
|
boolean |
readDerive()
Read the value of the derive attribute.
|
java.util.Date |
readEndDate()
Read the value of the end date attribute.
|
byte[] |
readId()
Read the value of the ID attribute.
|
java.lang.Long |
readKeyGenMechanism()
Read the value of the key generation mechanism attribute.
|
java.lang.Long |
readKeyType()
Read the value of the key type attribute.
|
boolean |
readLocal()
Read the value of the local attribute.
|
java.util.Date |
readStartDate()
Read the value of the start date attribute.
|
Key |
setAllowedMechanisms(Mechanism[] allowedMechanisms)
Set the value of the allowed mechanisms attribute.
|
Key |
setDerive(boolean derive)
Set the value of the derive attribute.
|
Key |
setEndDate(java.util.Date endDate)
Set the value of the end date attribute.
|
Key |
setId(byte[] id)
Set the value of the ID attribute.
|
Key |
setKeyGenMechanism(java.lang.Long keyGenMechanism)
Set the value of the key generation mechanism attribute.
|
Key |
setKeyType(java.lang.Long keyType)
Set the value of the key type attribute.
|
Key |
setLocal(boolean local)
Set the value of the local attribute.
|
Key |
setStartDate(java.util.Date startDate)
Set the value of the start date attribute.
|
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.
|
java.lang.String |
toString()
This method returns a string representation of the current object.
|
getLabel, getModifiable, getPrivate, getToken, isModifiable, isPrivate, isToken, putAttributesInTable, readLabel, readModifiable, readPrivate, readToken, setLabel, setModifiable, setPrivate, setTokencheckAttributesState, checkAttributeState, filterExcludedAttributes, filterExcludedAttributes, getAttribute, getAttributeTable, getAttributeValue, getAttributeValues, getExcludedAttributes, getInstance, getObjectClass, getObjectClassName, getObjectHandle, getSetAttributes, getSetAttributes, getUnknownObject, getVendorDefinedObjectBuilder, hasExcluded, putAttribute, putAttributesInTable, readAttributes, removeAttribute, setObjectHandle, setVendorDefinedObjectBuilder, toStringprotected static Key.VendorDefinedKeyBuilder vendorKeyBuilder_
protected static java.util.Hashtable keyTypeNames_
protected KeyTypeAttribute keyType_
protected ByteArrayAttribute id_
protected DateAttribute startDate_
protected DateAttribute endDate_
protected BooleanAttribute derive_
protected BooleanAttribute local_
protected MechanismAttribute keyGenMechanism_
protected MechanismArrayAttribute allowedMechanisms_
public Key()
protected Key(Session session, long objectHandle) throws TokenException
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.TokenException - If getting the attributes failed.public static void setVendorDefinedKeyBuilder(Key.VendorDefinedKeyBuilder builder)
builder - The vendor-defined key builder. Null to clear any previously installed vendor-defined
builder.public static Key.VendorDefinedKeyBuilder getVendorDefinedKeyBuilder()
public static java.lang.String getKeyTypeName(java.lang.Long keyType)
keyType - The key type to get as string.protected static void putAttributesInTable(Key object)
object - The object to handle.protected void allocateAttributes()
allocateAttributes in class Storagepublic java.lang.Object clone()
public boolean equals(java.lang.Object otherObject)
public Key setKeyType(java.lang.Long keyType)
keyType - the key type attrubute valuepublic LongAttribute getKeyType()
public java.lang.Long readKeyType()
public Key setId(byte[] id)
id - the ID attribute valuepublic ByteArrayAttribute getId()
public byte[] readId()
public Key setStartDate(java.util.Date startDate)
startDate - the start date attribute valuepublic DateAttribute getStartDate()
public java.util.Date readStartDate()
public Key setEndDate(java.util.Date endDate)
endDate - the end date attribute valuepublic DateAttribute getEndDate()
public java.util.Date readEndDate()
public Key setDerive(boolean derive)
derive - the derive attribute valuepublic BooleanAttribute getDerive()
public boolean readDerive()
public boolean isDerive()
public boolean isDerivable()
public Key setLocal(boolean local)
local - the local attribute valuepublic BooleanAttribute getLocal()
public boolean readLocal()
public boolean isLocal()
public Key setKeyGenMechanism(java.lang.Long keyGenMechanism)
keyGenMechanism - the key generation mechanism attribute valuepublic MechanismAttribute getKeyGenMechanism()
public java.lang.Long readKeyGenMechanism()
public Key setAllowedMechanisms(Mechanism[] allowedMechanisms)
allowedMechanisms - the allowed mechanisms attribute valuepublic MechanismArrayAttribute getAllowedMechanisms()
public Mechanism[] readAllowedMechanisms()
public int hashCode()
public java.lang.String toString()