cleanup, fix uninitialized variable warning
[mech_eap.orig] / util_shib.cpp
index 04ef90f..b2a83f6 100644 (file)
@@ -156,10 +156,10 @@ gss_eap_shib_attr_provider::initFromGssContext(const gss_eap_attr_ctx *manager,
 {
     const gss_eap_saml_assertion_provider *saml;
     const gss_eap_radius_attr_provider *radius;
+#if 0
     gss_buffer_desc nameBuf = GSS_C_EMPTY_BUFFER;
-    ShibbolethResolver *resolver;
     OM_uint32 minor;
-
+#endif
     if (!gss_eap_attr_provider::initFromGssContext(manager, gssCred, gssCtx))
         return false;
 
@@ -168,13 +168,21 @@ gss_eap_shib_attr_provider::initFromGssContext(const gss_eap_attr_ctx *manager,
     radius = static_cast<const gss_eap_radius_attr_provider *>
         (m_manager->getProvider(ATTR_TYPE_RADIUS));
 
-    resolver = ShibbolethResolver::create();
+    auto_ptr<ShibbolethResolver> resolver(ShibbolethResolver::create());
 
+    /*
+     * For now, leave ApplicationID defaulted.
+     * Later on, we could allow this via config option to the mechanism
+     * or rely on an SPRequest interface to pass in a URI identifying the
+     * acceptor.
+     */
+#if 0
     if (gssCred != GSS_C_NO_CREDENTIAL &&
         gssEapDisplayName(&minor, gssCred->name, &nameBuf, NULL) == GSS_S_COMPLETE) {
         resolver->setApplicationID((const char *)nameBuf.value);
         gss_release_buffer(&minor, &nameBuf);
     }
+#endif
 
     m_authenticated = false;
 
@@ -194,13 +202,9 @@ gss_eap_shib_attr_provider::initFromGssContext(const gss_eap_attr_ctx *manager,
         m_attributes = resolver->getResolvedAttributes();
         resolver->getResolvedAttributes().clear();
     } catch (exception &e) {
-#if 0
-        delete resolver;
-        throw e;
-#endif
+        //fprintf(stderr, "%s", e.what());
     }
 
-    delete resolver;
     return true;
 }
 
@@ -331,7 +335,7 @@ gss_eap_shib_attr_provider::getAttribute(const gss_buffer_t attr,
     else if (i >= nvalues)
         return false;
 
-    buf.value = (void *)shibAttr->getString(*more);
+    buf.value = (void *)shibAttr->getSerializedValues()[*more].c_str();
     buf.length = strlen((char *)buf.value);
 
     if (buf.length != 0) {
@@ -397,7 +401,7 @@ gss_eap_shib_attr_provider::exportToBuffer(gss_buffer_t buffer) const
     }
 
     ostringstream sink;
-    sink << attrs;
+    sink << obj;
     string str = sink.str();
 
     duplicateBuffer(str, buffer);