/**
 *  Constructor for the certificate object
 */
int createCertificateObject(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, struct p11Object_t *object)
{
	unsigned int i;
	int index, rc;

	rc = createStorageObject(pTemplate, ulCount, object);

	if (rc) {
		return rc;
	}

	for (i = 0; i < NEEDED_ATTRIBUTES_CERTIFICATEOBJECT; i++) {
		index = findAttributeInTemplate(attributesCertificateObject[i].attribute.type, pTemplate, ulCount);

		if (index == -1) { /* The attribute is not present - is it optional? */
			if (attributesCertificateObject[i].optional) {
				addAttribute(object, &attributesCertificateObject[i].attribute);
			} else { /* the attribute is not optional */
				removeAllAttributes(object);
				memset(object, 0x00, sizeof(*object));
				return CKR_TEMPLATE_INCOMPLETE;
			}
		} else {
			addAttribute(object, &pTemplate[index]);
		}
	}

#ifdef DEBUG
	dumpAttributeList(object);
#endif

	return 0;
}
// MANIPULATORS
DefaultAttributeContainer&
DefaultAttributeContainer::operator=(
    const DefaultAttributeContainer& rhs)
{
    if (this != &rhs) {
        removeAllAttributes();

        for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) {
            addAttribute(*iter);
        }
    }

    return *this;
}
예제 #3
0
int createStorageObject(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, struct p11Object_t *pObject)
{
	int index;
	unsigned int i, rc;

	rc = createObject(pTemplate, ulCount, pObject);

	if (rc) {
		return rc;
	}

	for (i = 0; attributesStorageObject[i].attribute.type; i++) {
		index = findAttributeInTemplate(attributesStorageObject[i].attribute.type, pTemplate, ulCount);

		if (index == -1) { /* The attribute is not present - is it optional? */
			if (attributesStorageObject[i].condition == AC_DEFAULT) {
				addAttribute(pObject, &attributesStorageObject[i].attribute);
			} else if (attributesStorageObject[i].condition != AC_OPTIONAL) { /* the attribute is not optional */
#ifdef DEBUG
				debug("[createStorageObject] Error creating storage object - the following attribute is not present!");
				dumpAttribute(&(attributesStorageObject[i].attribute));
#endif
				removeAllAttributes(pObject);
				return CKR_TEMPLATE_INCOMPLETE;
			}
		} else {
			addAttribute(pObject, &pTemplate[index]);

			/* The object is public */
			if ((pTemplate[index].type == CKA_PRIVATE ) &&
					(*(CK_BBOOL *)pTemplate[index].pValue == CK_FALSE)) {
				pObject->publicObj = TRUE;
			}

			/* The object is a token object */
			if ((pTemplate[index].type == CKA_TOKEN ) &&
					(*(CK_BBOOL *)pTemplate[index].pValue == CK_TRUE)) {
				pObject->tokenObj = TRUE;
			}
		}
	}

	return 0;
}
예제 #4
0
/**
 * Free unlinked PKCS11 object
 *
 * @param list address of the pointer to the first entry in the list
 * @param handle the handle of the object to be removed
 * @return CKR_OK or CKR_OBJECT_HANDLE_INVALID
 */
void freeObject(struct p11Object_t *object)
{
	removeAllAttributes(object);
	free(object);
}
AttributeManager::~AttributeManager()
{ 
    removeAllAttributes(); 
}
예제 #6
0
AbstractWidgetForm::~AbstractWidgetForm() {
    removeAllAttributes();
//    delete _label;
//    delete _help;
}