refactored credential builder

allow enumeration of matching builders
	try a second builder if the first one fails
	builder clones resources internally on demand
	caller frees added resources on failure and success
	stricter handling of non-supported build parts
This commit is contained in:
Martin Willi
2008-09-02 11:00:13 +00:00
parent 4da0116d78
commit f7c17aa15c
29 changed files with 437 additions and 376 deletions
+7 -4
View File
@@ -63,7 +63,7 @@ static bool private_enumerator_enumerate(private_enumerator_t *this,
while (this->inner->enumerate(this->inner, &chunk))
{
this->current = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
BUILD_BLOB_ASN1_DER, chunk_clone(chunk),
BUILD_BLOB_ASN1_DER, chunk,
BUILD_END);
if (this->current)
{
@@ -143,7 +143,7 @@ static bool cert_enumerator_enumerate(cert_enumerator_t *this,
while (this->inner->enumerate(this->inner, &chunk))
{
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
BUILD_BLOB_ASN1_DER, chunk_clone(chunk),
BUILD_BLOB_ASN1_DER, chunk,
BUILD_END);
if (public)
{
@@ -152,14 +152,17 @@ static bool cert_enumerator_enumerate(cert_enumerator_t *this,
this->current = lib->creds->create(lib->creds,
CRED_CERTIFICATE, CERT_TRUSTED_PUBKEY,
BUILD_PUBLIC_KEY, public, BUILD_END);
public->destroy(public);
if (this->current)
{
*cert = this->current;
return TRUE;
}
continue;
}
public->destroy(public);
else
{
public->destroy(public);
}
}
}
this->current = NULL;