more work on SAML ification
[mech_eap.git] / get_name_attribute.c
index 3e0654b..525137f 100644 (file)
 
 #include "gssapiP_eap.h"
 
+OM_uint32
+gss_get_name_attribute(OM_uint32 *minor,
+                       gss_name_t name,
+                       gss_buffer_t attr,
+                       int *authenticated,
+                       int *complete,
+                       gss_buffer_t value,
+                       gss_buffer_t display_value,
+                       int *more)
+{
+    OM_uint32 major, tmpMinor;
+    gss_buffer_desc prefix, suffix;
+    enum gss_eap_attribute_type type;
+
+    if (name == GSS_C_NO_NAME) {
+        *minor = EINVAL;
+        return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME;
+    }
+
+    *authenticated = 0;
+    *complete = 0;
+    value->length = 0;
+    value->value = NULL;
+    display_value->length = 0;
+    display_value->value = NULL;
+    *more = -1;
+
+    GSSEAP_MUTEX_LOCK(&name->mutex);
+
+    major = decomposeAttributeName(minor, attr, &prefix, &suffix);
+    if (GSS_ERROR(major))
+        goto cleanup;
+
+    type = gssEapAttributePrefixToType(&prefix);
+    if (type == ATTR_TYPE_SAML_AAA_ASSERTION) {
+        major = samlGetAssertion(minor, name->samlCtx, value);
+    } else {
+        major = samlGetAttribute(minor, name->samlCtx, &suffix,
+                                 authenticated, complete,
+                                 value, display_value, more);
+    }
+
+cleanup:
+    GSSEAP_MUTEX_UNLOCK(&name->mutex);
+
+    return major;
+}