#include <exception>
#include <new>
-static gss_eap_attr_create_cb
+static gss_eap_attr_create_factory
gss_eap_attr_factories[ATTR_TYPE_MAX] = {
gss_eap_radius_attr_provider::createAttrContext,
gss_eap_saml_assertion_provider::createAttrContext,
for (i = 0; i < ATTR_TYPE_MAX; i++) {
gss_eap_attr_provider *provider = m_providers[i];
}
+
+ return false;
}
return ATTR_TYPE_LOCAL;
}
-gss_buffer_t
+const gss_buffer_t
gss_eap_attr_ctx::attributeTypeToPrefix(unsigned int type)
{
if (type < ATTR_TYPE_MIN || type >= ATTR_TYPE_LOCAL)
}
}
-void
+std::string
gss_eap_attr_ctx::composeAttributeName(const gss_buffer_t prefix,
- const gss_buffer_t suffix,
- gss_buffer_t attribute)
+ const gss_buffer_t suffix)
{
- size_t len = 0;
- char *p;
-
- attribute->length = 0;
- attribute->value = NULL;
+ std::string str;
if (prefix == GSS_C_NO_BUFFER || prefix->length == 0)
- return;
+ return str;
+
+ str.append((const char *)prefix->value, prefix->length);
- len = prefix->length;
if (suffix != GSS_C_NO_BUFFER) {
- len += 1 + suffix->length;
+ str.append(" ");
+ str.append((const char *)suffix->value, suffix->length);
}
- attribute->value = GSSEAP_MALLOC(len + 1);
- if (attribute->value == NULL) {
- throw new std::bad_alloc;
- }
- attribute->length = len;
+ return str;
+}
- p = (char *)attribute->value;
- memcpy(p, prefix->value, prefix->length);
- if (suffix != NULL) {
- p[prefix->length] = ' ';
- memcpy(p + prefix->length + 1, suffix->value, suffix->length);
- }
+std::string
+gss_eap_attr_ctx::composeAttributeName(unsigned int type,
+ const gss_buffer_t suffix)
+{
+ const gss_buffer_t prefix = attributeTypeToPrefix(type);
- p[attribute->length] = '\0';
+ return composeAttributeName(prefix, suffix);
+}
+
+void
+gss_eap_attr_ctx::composeAttributeName(const gss_buffer_t prefix,
+ const gss_buffer_t suffix,
+ gss_buffer_t attribute)
+{
+ std::string str = composeAttributeName(prefix, suffix);
+
+ if (str.length() != 0) {
+ return duplicateBuffer(str, attribute);
+ } else {
+ attribute->length = 0;
+ attribute->value = NULL;
+ }
}
void
gss_eap_attr_ctx::decomposeAttributeName(const gss_buffer_t attribute,
- unsigned int*type,
+ unsigned int *type,
gss_buffer_t suffix)
{
gss_buffer_desc prefix = GSS_C_EMPTY_BUFFER;
{
gss_buffer_t prefix = attributeTypeToPrefix(type);
- composeAttributeName(prefix, suffix, attribute);
+ return composeAttributeName(prefix, suffix, attribute);
}
OM_uint32
{
if (buffer->length)
GSSEAP_NOT_IMPLEMENTED;
+
+ return GSS_S_COMPLETE;
}
OM_uint32