From 98729e7570442335c3825a17fb3fe4a725d255a3 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 18 Sep 2010 00:51:02 +0200 Subject: [PATCH] cleanup --- mech_eap/util_attr.cpp | 22 ++++++++++----- mech_eap/util_attr.h | 9 +++---- mech_eap/util_radius.cpp | 3 ++- mech_eap/util_radius.h | 4 +-- mech_eap/util_saml.cpp | 69 ++++++++++++++++++++++++++++-------------------- mech_eap/util_saml.h | 16 ++++------- mech_eap/util_shib.cpp | 4 +-- mech_eap/util_shib.h | 6 +++-- 8 files changed, 75 insertions(+), 58 deletions(-) diff --git a/mech_eap/util_attr.cpp b/mech_eap/util_attr.cpp index 2686f24..5228645 100644 --- a/mech_eap/util_attr.cpp +++ b/mech_eap/util_attr.cpp @@ -108,7 +108,8 @@ gss_eap_attr_ctx::gss_eap_attr_ctx(const gss_eap_attr_ctx &ctx) { for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) { if (ctx.m_providers[i] != NULL) { - m_providers[i] = (gss_eap_attr_factories[i])(&ctx, GSS_C_NO_CREDENTIAL, + m_providers[i] = (gss_eap_attr_factories[i])(&ctx, + GSS_C_NO_CREDENTIAL, GSS_C_NO_CONTEXT); } } @@ -277,8 +278,22 @@ gss_eap_attr_ctx::releaseAnyNameMapping(gss_buffer_t type_id, void gss_eap_attr_ctx::marshall(gss_buffer_t buffer) const { + /* For now, just marshall the RADIUS context. */ } +bool +gss_eap_attr_ctx::unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer) +{ + int i; + + for (i = 0; i < ATTR_TYPE_MAX; i++) { + gss_eap_attr_provider *provider = m_providers[i]; + + } +} + + /* * C wrappers */ @@ -423,11 +438,6 @@ gssEapInquireName(OM_uint32 *minor, gss_OID *MN_mech, gss_buffer_set_t *attrs) { - *minor = 0; - *name_is_MN = false; - *MN_mech = GSS_EAP_MECHANISM; - *attrs = GSS_C_NO_BUFFER_SET; - if (name->attrCtx == NULL) return GSS_S_UNAVAILABLE; diff --git a/mech_eap/util_attr.h b/mech_eap/util_attr.h index abdcb99..5407c10 100644 --- a/mech_eap/util_attr.h +++ b/mech_eap/util_attr.h @@ -83,9 +83,8 @@ public: gss_any_t input) const {} virtual void marshall(gss_buffer_t buffer) const {} - static gss_eap_attr_provider *unmarshall(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer) - { return NULL; } + virtual bool unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer) { return false; } static bool init() { return true; } static void finalize() {} @@ -138,8 +137,8 @@ public: gss_any_t input) const; void marshall(gss_buffer_t buffer) const; - gss_eap_attr_provider *unmarshall(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer); + bool unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer); static bool init(); static void finalize(); diff --git a/mech_eap/util_radius.cpp b/mech_eap/util_radius.cpp index 6cc0dd2..a2a54c7 100644 --- a/mech_eap/util_radius.cpp +++ b/mech_eap/util_radius.cpp @@ -106,10 +106,11 @@ gss_eap_radius_attr_provider::marshall(gss_buffer_t buffer) const { } -gss_eap_attr_provider * +bool gss_eap_radius_attr_provider::unmarshall(const gss_eap_attr_ctx *ctx, const gss_buffer_t buffer) { + return false; } bool diff --git a/mech_eap/util_radius.h b/mech_eap/util_radius.h index 33c6c89..7a264e3 100644 --- a/mech_eap/util_radius.h +++ b/mech_eap/util_radius.h @@ -58,8 +58,8 @@ public: gss_any_t input) const; void marshall(gss_buffer_t buffer) const; - static gss_eap_attr_provider *unmarshall(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer); + bool unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer); bool getAttribute(unsigned int attribute, int *authenticated, diff --git a/mech_eap/util_saml.cpp b/mech_eap/util_saml.cpp index b859d9b..669458b 100644 --- a/mech_eap/util_saml.cpp +++ b/mech_eap/util_saml.cpp @@ -74,33 +74,36 @@ class auto_ptr_gss_buffer { * gss_eap_saml_assertion_provider is for retrieving the underlying * assertion. */ +gss_eap_saml_assertion_provider::gss_eap_saml_assertion_provider(const gss_eap_attr_ctx * +ctx) + : gss_eap_attr_provider(ctx) +{ + /* Then we may be creating from an existing attribute context */ + gss_eap_saml_assertion_provider *saml; + + saml = dynamic_cast + (ctx->getProvider(ATTR_TYPE_SAML_ASSERTION)); + if (saml != NULL) + setAssertion(saml->getAssertion()); +} + gss_eap_saml_assertion_provider::gss_eap_saml_assertion_provider(const gss_eap_attr_ctx *ctx, gss_cred_id_t gssCred, gss_ctx_id_t gssCtx) - : gss_eap_attr_provider(ctx, gssCred, gssCtx) + : gss_eap_attr_provider(ctx) { - if (gssCtx == GSS_C_NO_CONTEXT) { - /* Then we are creating from an existing attribute context */ - gss_eap_saml_assertion_provider *saml; - - saml = dynamic_cast - (ctx->getProvider(ATTR_TYPE_SAML_ASSERTION)); - if (saml != NULL) - setAssertion(saml->getAssertion()); - } else { - gss_eap_radius_attr_provider *radius; - gss_buffer_desc value = GSS_C_EMPTY_BUFFER; - int authenticated, complete, more = -1; - OM_uint32 minor; - - radius = dynamic_cast - (ctx->getProvider(ATTR_TYPE_RADIUS)); - if (radius != NULL && - radius->getAttribute(512, &authenticated, &complete, - &value, NULL, &more)) { - m_assertion = parseAssertion(&value); - gss_release_buffer(&minor, &value); - } + gss_eap_radius_attr_provider *radius; + gss_buffer_desc value = GSS_C_EMPTY_BUFFER; + int authenticated, complete, more = -1; + OM_uint32 minor; + + radius = dynamic_cast + (ctx->getProvider(ATTR_TYPE_RADIUS)); + if (radius != NULL && + radius->getAttribute(512, &authenticated, &complete, + &value, NULL, &more)) { + m_assertion = parseAssertion(&value); + gss_release_buffer(&minor, &value); } } @@ -134,7 +137,7 @@ gss_eap_saml_assertion_provider::parseAssertion(const gss_buffer_t buffer) bool gss_eap_saml_assertion_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAttribute, void *data) const { - addAttribute(this, GSS_C_NO_BUFFER, data); + return addAttribute(this, GSS_C_NO_BUFFER, data); } void @@ -214,16 +217,21 @@ gss_eap_saml_assertion_provider::marshall(gss_buffer_t buffer) const duplicateBuffer(str, buffer); } -gss_eap_attr_provider * +bool gss_eap_saml_assertion_provider::unmarshall(const gss_eap_attr_ctx *ctx, const gss_buffer_t buffer) { - return new gss_eap_saml_assertion_provider(ctx, buffer); + assert(m_assertion == NULL); + + m_assertion = parseAssertion(buffer); + + return (m_assertion != NULL); } bool gss_eap_saml_assertion_provider::init(void) { + return true; } void @@ -395,11 +403,11 @@ gss_eap_saml_attr_provider::marshall(gss_buffer_t buffer) const { } -gss_eap_attr_provider * +bool gss_eap_saml_attr_provider::unmarshall(const gss_eap_attr_ctx *ctx, const gss_buffer_t buffer) { - return new gss_eap_saml_attr_provider(ctx); + return false; } bool @@ -418,5 +426,8 @@ gss_eap_saml_attr_provider::createAttrContext(const gss_eap_attr_ctx *ctx, gss_cred_id_t gssCred, gss_ctx_id_t gssCtx) { - return new gss_eap_saml_attr_provider(ctx, gssCred, gssCtx); + if (gssCtx != GSS_C_NO_CONTEXT) + return new gss_eap_saml_attr_provider(ctx, gssCred, gssCtx); + else + return new gss_eap_saml_attr_provider(ctx); } diff --git a/mech_eap/util_saml.h b/mech_eap/util_saml.h index 7065326..8c5a548 100644 --- a/mech_eap/util_saml.h +++ b/mech_eap/util_saml.h @@ -43,13 +43,7 @@ namespace opensaml { struct gss_eap_saml_assertion_provider : gss_eap_attr_provider { public: - gss_eap_saml_assertion_provider(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer) - : gss_eap_attr_provider(ctx) - { - m_assertion = parseAssertion(buffer); - } - + gss_eap_saml_assertion_provider(const gss_eap_attr_ctx *ctx); gss_eap_saml_assertion_provider(const gss_eap_attr_ctx *ctx, gss_cred_id_t acceptorCred, gss_ctx_id_t acceptorCtx); @@ -73,8 +67,8 @@ public: gss_any_t input) const; void marshall(gss_buffer_t buffer) const; - static gss_eap_attr_provider *unmarshall(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer); + bool unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer); void setAssertion(const opensaml::saml2::Assertion *assertion); @@ -124,8 +118,8 @@ public: gss_any_t input) const; void marshall(gss_buffer_t buffer) const; - static gss_eap_attr_provider *unmarshall(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer); + bool unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer); const opensaml::saml2::Attribute * getAttribute(const gss_buffer_t attr) const; diff --git a/mech_eap/util_shib.cpp b/mech_eap/util_shib.cpp index 7d34577..64fd07d 100644 --- a/mech_eap/util_shib.cpp +++ b/mech_eap/util_shib.cpp @@ -285,11 +285,11 @@ gss_eap_shib_attr_provider::marshall(gss_buffer_t buffer) const { } -gss_eap_attr_provider * +bool gss_eap_shib_attr_provider::unmarshall(const gss_eap_attr_ctx *ctx, const gss_buffer_t buffer) { - return NULL; + return false; } bool diff --git a/mech_eap/util_shib.h b/mech_eap/util_shib.h index 1d2e60c..aa5cd14 100644 --- a/mech_eap/util_shib.h +++ b/mech_eap/util_shib.h @@ -41,6 +41,7 @@ namespace shibsp { struct gss_eap_shib_attr_provider : gss_eap_attr_provider { public: + gss_eap_shib_attr_provider(const gss_eap_attr_ctx *ctx); gss_eap_shib_attr_provider(const gss_eap_attr_ctx *ctx, gss_cred_id_t acceptorCred, gss_ctx_id_t acceptorCtx); @@ -63,8 +64,9 @@ public: gss_any_t input) const; void marshall(gss_buffer_t buffer) const; - static gss_eap_attr_provider *unmarshall(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer); + bool unmarshall(const gss_eap_attr_ctx *ctx, + const gss_buffer_t buffer); + static bool init(); static void finalize(); -- 2.1.4