remove debugging statement
[moonshot.git] / mech_eap / inquire_name.c
index 6c640f3..2a4e0e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, JANET(UK)
+ * Copyright (c) 2011, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * SUCH DAMAGE.
  */
 
-#include "gssapiP_eap.h"
-
-struct gss_eap_attribute_args {
-    enum gss_eap_attribute_type type;
-    gss_buffer_set_t attrs;
-};
-
 /*
- * The purpose of this callback interface is to not expose the attribute
- * prefixes to the attribute providers themselves.
+ * Enumerate name attributes.
  */
-static OM_uint32
-addAttribute(OM_uint32 *minor,
-             gss_name_t name,
-             gss_buffer_t attribute,
-             void *data)
-{
-    struct gss_eap_attribute_args *args = (struct gss_eap_attribute_args *)data;
-    OM_uint32 major, tmpMinor;
-    gss_buffer_desc qualifiedAttr;
-    gss_buffer_t prefix;
-
-    if (args->type != ATTR_TYPE_NONE)
-        prefix = gssEapAttributeTypeToPrefix(args->type);
-    else
-        prefix = GSS_C_NO_BUFFER;
 
-    if (prefix != GSS_C_NO_BUFFER && attribute != GSS_C_NO_BUFFER) {
-        major = composeAttributeName(minor, prefix, attribute, &qualifiedAttr);
-        if (GSS_ERROR(major))
-            return major;
-        major = gss_add_buffer_set_member(minor, &qualifiedAttr, &args->attrs);
-
-        gss_release_buffer(&tmpMinor, &qualifiedAttr);
-    } else {
-        assert(prefix != GSS_C_NO_BUFFER);
-        major = gss_add_buffer_set_member(minor, prefix, &args->attrs);
-    }
-
-    return major;
-}
+#include "gssapiP_eap.h"
 
 OM_uint32 gss_inquire_name(OM_uint32 *minor,
                            gss_name_t name,
@@ -79,62 +43,28 @@ OM_uint32 gss_inquire_name(OM_uint32 *minor,
                            gss_buffer_set_t *attrs)
 {
     OM_uint32 major, tmpMinor;
-    krb5_context krbContext;
-    struct gss_eap_attribute_args args;
 
-    *name_is_MN = 1;
-    *MN_mech = GSS_EAP_MECHANISM;
-    *attrs = GSS_C_NO_BUFFER_SET;
+    *minor = 0;
+
+    if (name_is_MN != NULL)
+        *name_is_MN = 0;
+    if (MN_mech != NULL)
+        *MN_mech = GSS_C_NO_OID;
+    if (attrs != NULL)
+        *attrs = GSS_C_NO_BUFFER_SET;
 
     if (name == GSS_C_NO_NAME) {
         *minor = EINVAL;
         return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME;
     }
 
-    GSSEAP_KRB_INIT(&krbContext);
-    GSSEAP_MUTEX_LOCK(&name->mutex);
-
-    major = gss_create_empty_buffer_set(minor, attrs);
-    if (GSS_ERROR(major))
-        goto cleanup;
-
-    args.attrs = *attrs;
-
-    if (name->flags & NAME_FLAG_SAML_ATTRIBUTES) {
-        /* The assertion itself */
-        args.type = ATTR_TYPE_SAML_AAA_ASSERTION;
+    if (attrs == NULL)
+        return GSS_S_COMPLETE;
 
-        major = addAttribute(minor, name, GSS_C_NO_BUFFER, &args);
-        if (GSS_ERROR(major))
-            goto cleanup;
-
-        /* Raw SAML attributes */
-#if 0
-        args.type = ATTR_TYPE_SAML_ATTR;
-        major = samlGetAttributeTypes(minor, args.type,
-                                      name, addAttribute, &args);
-        if (GSS_ERROR(major))
-            goto cleanup;
-#endif
-
-        /* Cooked local attributes */
-        args.type = ATTR_TYPE_NONE;
-        major = samlGetAttributeTypes(minor, name, args.type,
-                                      addAttribute, &args);
-        if (GSS_ERROR(major))
-            goto cleanup;
-    }
+    GSSEAP_MUTEX_LOCK(&name->mutex);
 
-    if (name->flags & NAME_FLAG_RADIUS_ATTRIBUTES) {
-        /* Raw RADIUS attributes */
-        args.type = ATTR_TYPE_RADIUS_AVP;
-        major = radiusGetAttributeTypes(minor, name,
-                                        addAttribute, &args);
-        if (GSS_ERROR(major))
-            goto cleanup;
-    }
+    major = gssEapInquireName(minor, name, name_is_MN, MN_mech, attrs);
 
-cleanup:
     GSSEAP_MUTEX_UNLOCK(&name->mutex);
 
     if (GSS_ERROR(major))