/** * Set the attributes of this attribute array by specifying a * GenericTemplate. Null, is also valid. * A call to this method sets the present flag to true. * * @param value * The AttributeArray value to set. May be null. * @preconditions * @postconditions */ public void setAttributeArrayValue(PKCS11Object value) { template = value; List<CK_ATTRIBUTE> attributeList = new ArrayList<>(); Enumeration<Attribute> attributeEnumeration = template.attributeTable.elements(); while (attributeEnumeration.hasMoreElements()) { Attribute attribute = attributeEnumeration.nextElement(); if (attribute.present) { attributeList.add(attribute.getCkAttribute()); } } ckAttribute.pValue = (CK_ATTRIBUTE[]) attributeList.toArray(new CK_ATTRIBUTE[0]); present = true; }
/** * Returns the PKCS#11 attributes of this object. The collection * contains CK_ATTRIBUTE objects, one for each present attribute of this * object; e.g. for each attribute that has a set value (which might be * sensitive). * <p/> * 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. * * @return An collection of CK_ATTRIBUTE objects. * @preconditions * @postconditions (result <> null) */ public Vector<CK_ATTRIBUTE> getSetAttributes() { Vector<CK_ATTRIBUTE> attributeCollection = new Vector<>(attributeTable.size()); Enumeration<Attribute> attributeEnumeration = attributeTable.elements(); while (attributeEnumeration.hasMoreElements()) { Attribute attribute = attributeEnumeration.nextElement(); if (attribute.isPresent()) { CK_ATTRIBUTE ckAttribute = attribute.getCkAttribute(); attributeCollection.addElement(ckAttribute); } } return attributeCollection; }
for (int i = 0; i < attributes.length; i++) { CK_ATTRIBUTE attribute = new CK_ATTRIBUTE(); attribute.type = attributes[i].getCkAttribute().type; attributeTemplateList[i] = attribute;
long attributeCode = attribute.getCkAttribute().type;