public class PKCS11Object extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
PKCS11Object.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 |
PKCS11Object.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 Hashtable<Long,Attribute> |
attributeTable
Contains all attribute objects an object possesses.
|
protected ObjectClassAttribute |
objectClass
The class type of this object.
|
protected static Hashtable<Long,String> |
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 PKCS11Object.VendorDefinedObjectBuilder |
vendorObjectBuilder
The currently set vendor defined object builder, or null.
|
| Modifier | Constructor and Description |
|---|---|
|
PKCS11Object()
The default constructor.
|
protected |
PKCS11Object(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.
|
boolean |
equals(Object otherObject)
Compares all member variables of this object with the other object.
|
Attribute |
getAttribute(long attribute)
Gets the attribute.
|
Hashtable<Long,Attribute> |
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 PKCS11Object |
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 String |
getObjectClassName(Long objectClass)
Get the given object class as string.
|
long |
getObjectHandle()
Gets the object handle of the underlying PKCS#11 object on the token.
|
Vector<sun.security.pkcs11.wrapper.CK_ATTRIBUTE> |
getSetAttributes()
Returns the PKCS#11 attributes of this object.
|
static sun.security.pkcs11.wrapper.CK_ATTRIBUTE[] |
getSetAttributes(PKCS11Object object,
VendorCodeConverter vendorCodeConverter)
Returns the PKCS#11 attributes of an object.
|
protected static PKCS11Object |
getUnknownObject(Session session,
long objectHandle)
Try to create an object which has no or an unknown object class
attribute.
|
static PKCS11Object.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,
Object value)
Allows for putting attributes into the table without knowing the
Attribute at compile-time. |
protected static void |
putAttributesInTable(PKCS11Object 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(PKCS11Object.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.
|
String |
toString()
Returns a string representation of the current object.
|
String |
toString(boolean newline,
boolean withName,
String indent)
Returns a string representation of the current object.
|
protected static PKCS11Object.VendorDefinedObjectBuilder vendorObjectBuilder
protected static Hashtable<Long,String> objectClassNames
protected Hashtable<Long,Attribute> attributeTable
protected ObjectClassAttribute objectClass
protected long objectHandle
public PKCS11Object()
protected PKCS11Object(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 PKCS11Object 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 PKCS11Object getUnknownObject(Session session, long objectHandle) throws TokenException
PKCS11Object .session - The session to use.objectHandle - The handle of the objectTokenException - If no object could be created.public static void setVendorDefinedObjectBuilder(PKCS11Object.VendorDefinedObjectBuilder builder)
builder - The vendor-defined object builder. Null to clear any previously
installed vendor-defined builder.public static String getObjectClassName(Long objectClass)
objectClass - The object class to get as string.public static PKCS11Object.VendorDefinedObjectBuilder getVendorDefinedObjectBuilder()
protected static void putAttributesInTable(PKCS11Object object)
object - The object to handle.protected void allocateAttributes()
public boolean equals(Object otherObject)
public Hashtable<Long,Attribute> getAttributeTable()
public void putAttribute(long attribute,
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
PKCS11Object instance.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 Vector<sun.security.pkcs11.wrapper.CK_ATTRIBUTE> getSetAttributes()
The array representation of this collection can be used directly as input for the PKCS#11 wrapper. The Session class uses this method for various object operations.
public static sun.security.pkcs11.wrapper.CK_ATTRIBUTE[] getSetAttributes(PKCS11Object object, VendorCodeConverter vendorCodeConverter) throws PKCS11Exception
object - The iaik.pkcs.pkcs11.object.Object object to get the attributes
from.vendorCodeConverter - The vendor code converter.PKCS11Exception - If setting the attribute values.public int hashCode()
public void readAttributes(Session session) 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.TokenException - If getting the attributes failed.public String toString()
public String toString(boolean newline, boolean withName, 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 usedprotected 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.
It 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.Copyright © 2022. All rights reserved.