public class Object
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static interface |
Object.ObjectClass
This interface defines the available object classes as defined by PKCS#11: DATA, CERTIFICATE,
PUBLIC_KEY, PRIVATE_KEY, SECRET_KEY, HW_FEATURE, DOMAIN_PARAMETERS or VENDOR_DEFINED.
|
static interface |
Object.VendorDefinedObjectBuilder
If an application uses vendor defined objects, it must implement this interface and install
such an object handler using setVendorDefinedObjectBuilder.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable |
attributeTable_
Contains all attribute objects an object possesses.
|
protected ObjectClassAttribute |
objectClass_
The class type of this object.
|
protected static java.util.Hashtable |
objectClassNames_
A table holding string representations for all known key types.
|
protected long |
objectHandle_
The object handle as given from the PKCS#11 driver.
|
protected static Object.VendorDefinedObjectBuilder |
vendorObjectBuilder_
The currently set vendor defined object builder, or null.
|
Modifier | Constructor and Description |
---|---|
|
Object()
The default constructor.
|
protected |
Object(Session session,
long objectHandle)
The subclasses that are used to create objects by reading the attributes from the token should
call this super-constructor first.
|
Modifier and Type | Method and Description |
---|---|
protected void |
allocateAttributes()
Allocates the attribute objects for this class and adds them to the attribute table.
|
void |
checkAttributesState(Session session)
Checks for all of this object's attributes whether their state is known (see
#isStateKnown() ). |
void |
checkAttributeState(Session session,
java.lang.Long type)
Checks for the given attribute type, if it's an attribute of this object and whether its state
is known (see
#isStateKnown() ). |
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.
|
Attribute |
getAttribute(long attribute)
Gets the attribute.
|
java.util.Hashtable |
getAttributeTable()
Return the table that contains all attributes of this object.
|
protected static void |
getAttributeValue(Session session,
long objectHandle,
Attribute attribute)
This method reads the attribute specified by
attribute from the token using the
given session . |
protected static void |
getAttributeValues(Session session,
long objectHandle,
Attribute[] attributes)
This method reads the attributes in a similar way as
getAttributeValue(iaik.pkcs.pkcs11.Session, long, iaik.pkcs.pkcs11.objects.Attribute) , but a complete
array at once. |
static Object |
getInstance(Session session,
long objectHandle)
The object creation mechanism of ObjectAccess uses this method to create an instance of an
PKCS#11 object.
|
LongAttribute |
getObjectClass()
Gets the object class attribute of the PKCS#11 object.
|
static java.lang.String |
getObjectClassName(java.lang.Long objectClass)
Get the given object class as string.
|
long |
getObjectHandle()
Gets the object handle of the underlying PKCS#11 object on the token.
|
java.util.Vector |
getSetAttributes()
This method returns the PKCS#11 attributes of this object.
|
static CK_ATTRIBUTE[] |
getSetAttributes(Object object)
This method returns the PKCS#11 attributes of an object.
|
protected static Object |
getUnknownObject(Session session,
long objectHandle)
Try to create an object which has no or an unknown object class attribute.
|
static Object.VendorDefinedObjectBuilder |
getVendorDefinedObjectBuilder()
Get the currently set vendor-defined object builder.
|
int |
hashCode()
The overriding of this method should ensure that the objects of this class work correctly in a
hashtable.
|
void |
putAttribute(long attribute,
java.lang.Object value)
Allows for putting attributes into the table without knowing the
Attribute at
compile-time. |
protected static void |
putAttributesInTable(Object 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.
|
void |
removeAttribute(long attribute)
Removes the attribute.
|
void |
setObjectHandle(long objectHandle)
Sets the object handle of the underlying PKCS#11 object on the token.
|
static void |
setVendorDefinedObjectBuilder(Object.VendorDefinedObjectBuilder builder)
Set a vendor-defined object builder that should be called to create an instance of an
vendor-defined PKCS#11 object; i.e.
|
java.lang.String |
toString()
This method returns a string representation of the current object.
|
java.lang.String |
toString(boolean newline,
boolean withName,
java.lang.String indent)
This method returns a string representation of the current object.
|
protected static Object.VendorDefinedObjectBuilder vendorObjectBuilder_
protected static java.util.Hashtable objectClassNames_
protected java.util.Hashtable attributeTable_
protected ObjectClassAttribute objectClass_
protected long objectHandle_
public Object()
protected Object(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 Object getInstance(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.protected static Object getUnknownObject(Session session, long objectHandle) throws TokenException
Object
.session
- The session to use.objectHandle
- The handle of the objectTokenException
- If no object could be created.public static void setVendorDefinedObjectBuilder(Object.VendorDefinedObjectBuilder builder)
builder
- The vendor-defined object builder. Null to clear any previously installed
vendor-defined builder.public static java.lang.String getObjectClassName(java.lang.Long objectClass)
objectClass
- The object class to get as string.public static Object.VendorDefinedObjectBuilder getVendorDefinedObjectBuilder()
protected static void putAttributesInTable(Object object)
object
- The object to handle.protected void allocateAttributes()
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object otherObject)
equals
in class java.lang.Object
otherObject
- The other object to compare to.public java.util.Hashtable getAttributeTable()
public void putAttribute(long attribute, java.lang.Object value) throws UnsupportedAttributeException
Attribute
at
compile-time.attribute
- the attribute identifier as a long
valuevalue
- the valueUnsupportedAttributeException
- the specified attribute identifier is not available for this Object
instance.java.lang.ClassCastException
- the given value type is not valid for this Attribute
instance.public Attribute getAttribute(long attribute)
attribute
- the attribute identifier as a long
valuepublic void removeAttribute(long attribute)
attribute
- the attribute identifier as a long
valuepublic long getObjectHandle()
public void setObjectHandle(long objectHandle)
objectHandle
- The object handle of the corresponding PKCS#11 object.public LongAttribute getObjectClass()
public java.util.Vector getSetAttributes()
public int hashCode()
hashCode
in class java.lang.Object
public void readAttributes(Session session) throws TokenException
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.TokenException
- If getting the attributes failed.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean newline, boolean withName, java.lang.String indent)
newline
- true if the output should start in a new linewithName
- true if the type of the attribute should be returned tooindent
- the indent to be usedpublic void checkAttributesState(Session session) throws TokenException
#isStateKnown()
). If state is not known, this method determines if this attribute is
present and sensitive.session
- the session to use for checking this object's attributesTokenException
- If checking the attribute failedpublic void checkAttributeState(Session session, java.lang.Long type) throws TokenException, UnsupportedAttributeException
#isStateKnown()
). If state is not known, this method determines if this
attribute is present and sensitive.session
- the session to use for checking this object's attributetype
- the type of the attribute, that shall be checkedTokenException
- If checking the attribute failed or this object has no such attributeUnsupportedAttributeException
- in case the attribute is not supportedpublic static CK_ATTRIBUTE[] getSetAttributes(Object object) throws PKCS11Exception
object
- The iaik.pkcs.pkcs11.object.Object object to get the attributes from.PKCS11Exception
- If setting the attribute values.protected static void getAttributeValue(Session session, long objectHandle, Attribute attribute) throws PKCS11Exception
attribute
from the token using the
given session
. The object from which to read the attribute is specified using the
objectHandle
. The attribute
will contain the results. If the attempt
to read the attribute returns CKR_ATTRIBUTE_TYPE_INVALID
, this will be indicated
by setting Attribute.setPresent(boolean)
to false
. If
CKR_ATTRIBUTE_SENSITIVE is returned, the attribute object is marked as present (by calling
Attribute.setPresent(boolean)
with true
), and in addition as sensitive by
calling Attribute.setSensitive(boolean)
with true
.session
- The session to use for reading the attribute.objectHandle
- The handle of the object which contains the attribute.attribute
- The object specifying the attribute type (see Attribute.getType()
) and
receiving the attribute value (see Attribute.setCkAttribute(CK_ATTRIBUTE)
).PKCS11Exception
- If getting the attribute failed.protected static void getAttributeValues(Session session, long objectHandle, Attribute[] attributes) throws PKCS11Exception
getAttributeValue(iaik.pkcs.pkcs11.Session, long, iaik.pkcs.pkcs11.objects.Attribute)
, but a complete
array at once. This can lead to performance improvements. If reading all attributes at once
fails, it tries to read each attributes individually.session
- The session to use for reading the attributes.objectHandle
- The handle of the object which contains the attributes.attributes
- The objects specifying the attribute types (see Attribute.getType()
) and
receiving the attribute values (see Attribute.setCkAttribute(CK_ATTRIBUTE)
).PKCS11Exception
- If getting the attributes failed.IAIK JavaSecurity Website http://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. version 1.6.9