Migrated x509_ac to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-09-28 20:43:07 +02:00
parent 5976e149eb
commit 6f07a5b46f
+62 -106
View File
@@ -616,7 +616,6 @@ static chunk_t build_attr_cert_info(private_x509_ac_t *this)
build_extensions(this)); build_extensions(this));
} }
/** /**
* build an X.509 attribute certificate * build an X.509 attribute certificate
*/ */
@@ -636,82 +635,62 @@ static chunk_t build_ac(private_x509_ac_t *this)
asn1_bitstring("m", signatureValue)); asn1_bitstring("m", signatureValue));
} }
/** METHOD(ac_t, get_serial, chunk_t,
* Implementation of ac_t.get_serial. private_x509_ac_t *this)
*/
static chunk_t get_serial(private_x509_ac_t *this)
{ {
return this->serialNumber; return this->serialNumber;
} }
/** METHOD(ac_t, get_holderSerial, chunk_t,
* Implementation of ac_t.get_holderSerial. private_x509_ac_t *this)
*/
static chunk_t get_holderSerial(private_x509_ac_t *this)
{ {
return this->holderSerial; return this->holderSerial;
} }
/** METHOD(ac_t, get_holderIssuer, identification_t*,
* Implementation of ac_t.get_holderIssuer. private_x509_ac_t *this)
*/
static identification_t* get_holderIssuer(private_x509_ac_t *this)
{ {
return this->holderIssuer; return this->holderIssuer;
} }
/** METHOD(ac_t, get_authKeyIdentifier, chunk_t,
* Implementation of ac_t.get_authKeyIdentifier. private_x509_ac_t *this)
*/
static chunk_t get_authKeyIdentifier(private_x509_ac_t *this)
{ {
return this->authKeyIdentifier; return this->authKeyIdentifier;
} }
/** METHOD(ac_t, get_groups, ietf_attributes_t*,
* Implementation of certificate_t.get_groups. private_x509_ac_t *this)
*/
static ietf_attributes_t* get_groups(private_x509_ac_t *this)
{ {
return this->groups ? this->groups->get_ref(this->groups) : NULL; return this->groups ? this->groups->get_ref(this->groups) : NULL;
} }
/** METHOD(certificate_t, get_type, certificate_type_t,
* Implementation of certificate_t.get_type private_x509_ac_t *this)
*/
static certificate_type_t get_type(private_x509_ac_t *this)
{ {
return CERT_X509_AC; return CERT_X509_AC;
} }
/** METHOD(certificate_t, get_subject, identification_t*,
* Implementation of certificate_t.get_subject private_x509_ac_t *this)
*/
static identification_t* get_subject(private_x509_ac_t *this)
{ {
return this->entityName; return this->entityName;
} }
/** METHOD(certificate_t, get_issuer, identification_t*,
* Implementation of certificate_t.get_issuer private_x509_ac_t *this)
*/
static identification_t* get_issuer(private_x509_ac_t *this)
{ {
return this->issuerName; return this->issuerName;
} }
/** METHOD(certificate_t, has_subject, id_match_t,
* Implementation of certificate_t.has_subject. private_x509_ac_t *this, identification_t *subject)
*/
static id_match_t has_subject(private_x509_ac_t *this, identification_t *subject)
{ {
return ID_MATCH_NONE; return ID_MATCH_NONE;
} }
/** METHOD(certificate_t, has_issuer, id_match_t,
* Implementation of certificate_t.has_issuer. private_x509_ac_t *this, identification_t *issuer)
*/
static id_match_t has_issuer(private_x509_ac_t *this, identification_t *issuer)
{ {
if (issuer->get_type(issuer) == ID_KEY_ID && this->authKeyIdentifier.ptr && if (issuer->get_type(issuer) == ID_KEY_ID && this->authKeyIdentifier.ptr &&
chunk_equals(this->authKeyIdentifier, issuer->get_encoding(issuer))) chunk_equals(this->authKeyIdentifier, issuer->get_encoding(issuer)))
@@ -721,10 +700,8 @@ static id_match_t has_issuer(private_x509_ac_t *this, identification_t *issuer)
return this->issuerName->matches(this->issuerName, issuer); return this->issuerName->matches(this->issuerName, issuer);
} }
/** METHOD(certificate_t, issued_by, bool,
* Implementation of certificate_t.issued_by private_x509_ac_t *this, certificate_t *issuer)
*/
static bool issued_by(private_x509_ac_t *this, certificate_t *issuer)
{ {
public_key_t *key; public_key_t *key;
signature_scheme_t scheme; signature_scheme_t scheme;
@@ -776,28 +753,21 @@ static bool issued_by(private_x509_ac_t *this, certificate_t *issuer)
return valid; return valid;
} }
/** METHOD(certificate_t, get_public_key, public_key_t*,
* Implementation of certificate_t.get_public_key. private_x509_ac_t *this)
*/
static public_key_t* get_public_key(private_x509_ac_t *this)
{ {
return NULL; return NULL;
} }
/** METHOD(certificate_t, get_ref, certificate_t*,
* Implementation of certificate_t.get_ref. private_x509_ac_t *this)
*/
static private_x509_ac_t* get_ref(private_x509_ac_t *this)
{ {
ref_get(&this->ref); ref_get(&this->ref);
return this; return &this->public.interface.certificate;
} }
/** METHOD(certificate_t, get_validity, bool,
* Implementation of certificate_t.get_validity. private_x509_ac_t *this, time_t *when, time_t *not_before, time_t *not_after)
*/
static bool get_validity(private_x509_ac_t *this, time_t *when,
time_t *not_before, time_t *not_after)
{ {
time_t t = when ? *when : time(NULL); time_t t = when ? *when : time(NULL);
@@ -812,11 +782,8 @@ static bool get_validity(private_x509_ac_t *this, time_t *when,
return (t >= this->notBefore && t <= this->notAfter); return (t >= this->notBefore && t <= this->notAfter);
} }
/** METHOD(certificate_t, get_encoding, bool,
* Implementation of certificate_t.get_encoding. private_x509_ac_t *this, cred_encoding_type_t type, chunk_t *encoding)
*/
static bool get_encoding(private_x509_ac_t *this, cred_encoding_type_t type,
chunk_t *encoding)
{ {
if (type == CERT_ASN1_DER) if (type == CERT_ASN1_DER)
{ {
@@ -827,10 +794,8 @@ static bool get_encoding(private_x509_ac_t *this, cred_encoding_type_t type,
CRED_PART_X509_AC_ASN1_DER, this->encoding, CRED_PART_END); CRED_PART_X509_AC_ASN1_DER, this->encoding, CRED_PART_END);
} }
/** METHOD(certificate_t, equals, bool,
* Implementation of certificate_t.equals. private_x509_ac_t *this, certificate_t *other)
*/
static bool equals(private_x509_ac_t *this, certificate_t *other)
{ {
chunk_t encoding; chunk_t encoding;
bool equal; bool equal;
@@ -852,10 +817,8 @@ static bool equals(private_x509_ac_t *this, certificate_t *other)
return equal; return equal;
} }
/** METHOD(certificate_t, destroy, void,
* Implementation of x509_ac_t.destroy private_x509_ac_t *this)
*/
static void destroy(private_x509_ac_t *this)
{ {
if (ref_put(&this->ref)) if (ref_put(&this->ref))
{ {
@@ -879,41 +842,34 @@ static void destroy(private_x509_ac_t *this)
*/ */
static private_x509_ac_t *create_empty(void) static private_x509_ac_t *create_empty(void)
{ {
private_x509_ac_t *this = malloc_thing(private_x509_ac_t); private_x509_ac_t *this;
/* public functions */ INIT(this,
this->public.interface.get_serial = (chunk_t (*)(ac_t*))get_serial; .public = {
this->public.interface.get_holderSerial = (chunk_t (*)(ac_t*))get_holderSerial; .interface = {
this->public.interface.get_holderIssuer = (identification_t* (*)(ac_t*))get_holderIssuer; .certificate = {
this->public.interface.get_authKeyIdentifier = (chunk_t (*)(ac_t*))get_authKeyIdentifier; .get_type = _get_type,
this->public.interface.get_groups = (ietf_attributes_t* (*)(ac_t*))get_groups; .get_subject = _get_subject,
this->public.interface.certificate.get_type = (certificate_type_t (*)(certificate_t *this))get_type; .get_issuer = _get_issuer,
this->public.interface.certificate.get_subject = (identification_t* (*)(certificate_t *this))get_subject; .has_subject = _has_subject,
this->public.interface.certificate.get_issuer = (identification_t* (*)(certificate_t *this))get_issuer; .has_issuer = _has_issuer,
this->public.interface.certificate.has_subject = (id_match_t(*)(certificate_t*, identification_t *subject))has_subject; .issued_by = _issued_by,
this->public.interface.certificate.has_issuer = (id_match_t(*)(certificate_t*, identification_t *issuer))has_issuer; .get_public_key = _get_public_key,
this->public.interface.certificate.issued_by = (bool (*)(certificate_t *this, certificate_t *issuer))issued_by; .get_validity = _get_validity,
this->public.interface.certificate.get_public_key = (public_key_t* (*)(certificate_t *this))get_public_key; .get_encoding = _get_encoding,
this->public.interface.certificate.get_validity = (bool(*)(certificate_t*, time_t *when, time_t *, time_t*))get_validity; .equals = _equals,
this->public.interface.certificate.get_encoding = (bool(*)(certificate_t*,cred_encoding_type_t,chunk_t*))get_encoding; .get_ref = _get_ref,
this->public.interface.certificate.equals = (bool(*)(certificate_t*, certificate_t *other))equals; .destroy = _destroy,
this->public.interface.certificate.get_ref = (certificate_t* (*)(certificate_t *this))get_ref; },
this->public.interface.certificate.destroy = (void (*)(certificate_t *this))destroy; .get_serial = _get_serial,
.get_holderSerial = _get_holderSerial,
/* initialize */ .get_holderIssuer = _get_holderIssuer,
this->encoding = chunk_empty; .get_authKeyIdentifier = _get_authKeyIdentifier,
this->serialNumber = chunk_empty; .get_groups = _get_groups,
this->holderSerial = chunk_empty; },
this->authKeyIdentifier = chunk_empty; },
this->holderIssuer = NULL; .ref = 1,
this->entityName = NULL; );
this->issuerName = NULL;
this->holderCert = NULL;
this->signerCert = NULL;
this->signerKey = NULL;
this->charging = NULL;
this->groups = NULL;
this->ref = 1;
return this; return this;
} }