cleanup
authorLuke Howard <lukeh@padl.com>
Fri, 17 Sep 2010 22:51:02 +0000 (00:51 +0200)
committerLuke Howard <lukeh@padl.com>
Fri, 17 Sep 2010 22:51:02 +0000 (00:51 +0200)
mech_eap/util_attr.cpp
mech_eap/util_attr.h
mech_eap/util_radius.cpp
mech_eap/util_radius.h
mech_eap/util_saml.cpp
mech_eap/util_saml.h
mech_eap/util_shib.cpp
mech_eap/util_shib.h

index 2686f24..5228645 100644 (file)
@@ -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;
 
index abdcb99..5407c10 100644 (file)
@@ -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();
 
index 6cc0dd2..a2a54c7 100644 (file)
@@ -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
index 33c6c89..7a264e3 100644 (file)
@@ -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,
index b859d9b..669458b 100644 (file)
@@ -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<gss_eap_saml_assertion_provider *>
+        (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<gss_eap_saml_assertion_provider *>
-            (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<gss_eap_radius_attr_provider *>
-            (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<gss_eap_radius_attr_provider *>
+        (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);
 }
index 7065326..8c5a548 100644 (file)
@@ -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;
index 7d34577..64fd07d 100644 (file)
@@ -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
index 1d2e60c..aa5cd14 100644 (file)
@@ -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();