Package org.xipki.pkcs11.wrapper.attrs
Class Attribute
- java.lang.Object
-
- org.xipki.pkcs11.wrapper.attrs.Attribute
-
- Direct Known Subclasses:
AttributeArrayAttribute,BooleanAttribute,ByteArrayAttribute,CharArrayAttribute,DateAttribute,LongAttribute,MechanismArrayAttribute
public abstract class Attribute extends Object
This is the base-class for all types of attributes. In general, all PKCS#11 objects are just a collection of attributes. PKCS#11 specifies which attributes each type of objects must have.In some cases, attributes are optional. In such a case, this attribute will return false when the application calls present() on this attribute. This means, that the object does not possess this attribute (maybe even though it should, but not all drivers seem to implement the standard correctly). Handling attributes in this fashion ensures that this library can work also with drivers that are not fully standard-compliant.
Moreover, certain attributes can be sensitive; i.e. their values cannot be read, e.g. the private exponent of an RSA private key.
- Author:
- Karl Scheibelhofer (SIC), Lijun Liao (xipki)
-
-
Field Summary
Fields Modifier and Type Field Description protected CK_ATTRIBUTEckAttributeThe CK_ATTRIBUTE that is used to hold the PKCS#11 type of this attribute and the value.protected booleanpresentTrue, if the object really possesses this attribute.protected booleansensitiveTrue, if this attribute is sensitive.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAttribute(long type)Constructor taking the PKCS#11 type of the attribute.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AttributeckAttribute(CK_ATTRIBUTE ckAttribute)Set the CK_ATTRIBUTE of this Attribute.CK_ATTRIBUTEgetCkAttribute()Get the CK_ATTRIBUTE object of this Attribute that contains the attribute type and value .static AttributegetInstance(long type)static AttributegetInstance(long type, Object value)longgetType()Get the PKCS#11 type of this attribute.abstract ObjectgetValue()protected StringgetValueString()Get a string representation of the value of this attribute.booleanisNullValue()booleanisPresent()Check, if this attribute is really present in the associated object.booleanisSensitive()Check, if this attribute is sensitive in the associated object.Attributepresent(boolean present)Set, if this attribute is really present in the associated object.Attributesensitive(boolean sensitive)Set, if this attribute is sensitive in the associated object.StringtoString()Get a string representation of this attribute.StringtoString(boolean withName, int minNameLen, String indent)Get a string representation of this attribute.longtype()
-
-
-
Field Detail
-
present
protected boolean present
True, if the object really possesses this attribute.
-
sensitive
protected boolean sensitive
True, if this attribute is sensitive.
-
ckAttribute
protected CK_ATTRIBUTE ckAttribute
The CK_ATTRIBUTE that is used to hold the PKCS#11 type of this attribute and the value.
-
-
Method Detail
-
getValue
public abstract Object getValue()
-
getInstance
public static Attribute getInstance(long type)
-
present
public Attribute present(boolean present)
Set, if this attribute is really present in the associated object. Does only make sense if used in combination with template objects.- Parameters:
present- True, if attribute is present.- Returns:
- a reference to this object.
-
sensitive
public Attribute sensitive(boolean sensitive)
Set, if this attribute is sensitive in the associated object. Does only make sense if used in combination with template objects.- Parameters:
sensitive- True, if attribute is sensitive.- Returns:
- a reference to this object.
-
ckAttribute
public Attribute ckAttribute(CK_ATTRIBUTE ckAttribute)
Set the CK_ATTRIBUTE of this Attribute. Only for internal use.- Parameters:
ckAttribute- The new CK_ATTRIBUTE of this Attribute.- Returns:
- a reference to this object.
-
isPresent
public boolean isPresent()
Check, if this attribute is really present in the associated object.- Returns:
- True, if this attribute is really present in the associated object.
-
isSensitive
public boolean isSensitive()
Check, if this attribute is sensitive in the associated object.- Returns:
- True, if this attribute is sensitive in the associated object.
-
getCkAttribute
public CK_ATTRIBUTE getCkAttribute()
Get the CK_ATTRIBUTE object of this Attribute that contains the attribute type and value .- Returns:
- The CK_ATTRIBUTE of this Attribute.
-
type
public long type()
-
getValueString
protected String getValueString()
Get a string representation of the value of this attribute.- Returns:
- A string representation of the value of this attribute.
-
toString
public String toString()
Get a string representation of this attribute. If the attribute is not present or if it is sensitive, the output of this method shows just a message telling this. This string does not contain the attribute's type name.
-
toString
public String toString(boolean withName, int minNameLen, String indent)
Get a string representation of this attribute. If the attribute is not present or if it is sensitive, the output of this method shows just a message telling this.- Parameters:
withName- If true, the string contains the attribute type name and the value. If false, it just contains the value.minNameLen- Minimal length of the name.indent- The indent.- Returns:
- A string representation of this attribute.
-
getType
public long getType()
Get the PKCS#11 type of this attribute.- Returns:
- The PKCS#11 type of this attribute.
-
isNullValue
public boolean isNullValue()
-
-