X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=util_saml.cpp;h=8722b841592ef5d72228e09b365c0782368a25e4;hb=e063ba4e45d12dbc1a397653f9e77228835e4a2b;hp=69d0379f6b12cd437e0dc888bbd41940b4c3b508;hpb=7db57acddeddad5f96d16288b3776baf6c10c0b1;p=mech_eap.git diff --git a/util_saml.cpp b/util_saml.cpp index 69d0379..8722b84 100644 --- a/util_saml.cpp +++ b/util_saml.cpp @@ -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 @@ -186,7 +186,7 @@ gss_eap_saml_assertion_provider::getAttributeTypes(gss_eap_attr_enumeration_cb a /* just add the prefix */ if (m_assertion != NULL) - ret = addAttribute(this, GSS_C_NO_BUFFER, data); + ret = addAttribute(m_manager, this, GSS_C_NO_BUFFER, data); else ret = true; @@ -194,7 +194,7 @@ gss_eap_saml_assertion_provider::getAttributeTypes(gss_eap_attr_enumeration_cb a } bool -gss_eap_saml_assertion_provider::setAttribute(int complete, +gss_eap_saml_assertion_provider::setAttribute(int complete GSSEAP_UNUSED, const gss_buffer_t attr, const gss_buffer_t value) { @@ -207,7 +207,7 @@ gss_eap_saml_assertion_provider::setAttribute(int complete, } bool -gss_eap_saml_assertion_provider::deleteAttribute(const gss_buffer_t value) +gss_eap_saml_assertion_provider::deleteAttribute(const gss_buffer_t value GSSEAP_UNUSED) { delete m_assertion; m_assertion = NULL; @@ -260,7 +260,7 @@ gss_eap_saml_assertion_provider::getAttribute(const gss_buffer_t attr, int *authenticated, int *complete, gss_buffer_t value, - gss_buffer_t display_value, + gss_buffer_t display_value GSSEAP_UNUSED, int *more) const { string str; @@ -289,7 +289,7 @@ gss_eap_saml_assertion_provider::getAttribute(const gss_buffer_t attr, gss_any_t gss_eap_saml_assertion_provider::mapToAny(int authenticated, - gss_buffer_t type_id) const + gss_buffer_t type_id GSSEAP_UNUSED) const { if (authenticated && !m_authenticated) return (gss_any_t)NULL; @@ -298,54 +298,22 @@ gss_eap_saml_assertion_provider::mapToAny(int authenticated, } void -gss_eap_saml_assertion_provider::releaseAnyNameMapping(gss_buffer_t type_id, +gss_eap_saml_assertion_provider::releaseAnyNameMapping(gss_buffer_t type_id GSSEAP_UNUSED, gss_any_t input) const { delete ((saml2::Assertion *)input); } -void -gss_eap_saml_assertion_provider::exportToBuffer(gss_buffer_t buffer) const +const char * +gss_eap_saml_assertion_provider::prefix(void) const { - ostringstream sink; - string str; - - buffer->length = 0; - buffer->value = NULL; - - if (m_assertion == NULL) - return; - - sink << *m_assertion; - str = sink.str(); - - duplicateBuffer(str, buffer); -} - -bool -gss_eap_saml_assertion_provider::initFromBuffer(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer) -{ - if (!gss_eap_attr_provider::initFromBuffer(ctx, buffer)) - return false; - - if (buffer->length == 0) - return true; - - assert(m_assertion == NULL); - - setAssertion(buffer); - /* TODO XXX how to propagate authenticated flag? */ - - return true; + return "urn:ietf:params:gss-eap:saml-aaa-assertion"; } bool gss_eap_saml_assertion_provider::init(void) { - gss_eap_attr_ctx::registerProvider(ATTR_TYPE_SAML_ASSERTION, - "urn:ietf:params:gss-eap:saml-aaa-assertion", - createAttrContext); + gss_eap_attr_ctx::registerProvider(ATTR_TYPE_SAML_ASSERTION, createAttrContext); return true; } @@ -444,13 +412,17 @@ gss_eap_saml_attr_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAtt const_cast(*s)->getAttributes(); for (vector::const_iterator a = attrs.begin(); a != attrs.end(); ++a) { - const XMLCh *attributeName = (*a)->getName(); - const XMLCh *attributeNameFormat = (*a)->getNameFormat(); + const XMLCh *attributeName, *attributeNameFormat; XMLCh *qualifiedName; XMLCh space[2] = { ' ', 0 }; gss_buffer_desc utf8; bool ret; + attributeName = (*a)->getName(); + attributeNameFormat = (*a)->getNameFormat(); + if (attributeNameFormat == NULL || attributeNameFormat[0] == '\0') + attributeNameFormat = saml2::Attribute::UNSPECIFIED; + qualifiedName = new XMLCh[XMLString::stringLen(attributeNameFormat) + 1 + XMLString::stringLen(attributeName) + 1]; XMLString::copyString(qualifiedName, attributeNameFormat); @@ -460,7 +432,7 @@ gss_eap_saml_attr_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAtt utf8.value = (void *)toUTF8(qualifiedName); utf8.length = strlen((char *)utf8.value); - ret = addAttribute(this, &utf8, data); + ret = addAttribute(m_manager, this, &utf8, data); delete qualifiedName; @@ -491,7 +463,7 @@ decomposeAttributeName(const gss_buffer_t attr) } bool -gss_eap_saml_attr_provider::setAttribute(int complete, +gss_eap_saml_attr_provider::setAttribute(int complete GSSEAP_UNUSED, const gss_buffer_t attr, const gss_buffer_t value) { @@ -619,8 +591,15 @@ gss_eap_saml_attr_provider::getAttribute(const gss_buffer_t attr, const_cast(*s)->getAttributes(); for (vector::const_iterator a = attrs.begin(); a != attrs.end(); ++a) { - if (XMLString::equals((*a)->getNameFormat(), components->elementAt(0)) && - XMLString::equals((*a)->getName(), components->elementAt(1))) { + const XMLCh *attributeName, *attributeNameFormat; + + attributeName = (*a)->getName(); + attributeNameFormat = (*a)->getNameFormat(); + if (attributeNameFormat == NULL || attributeNameFormat[0] == '\0') + attributeNameFormat = saml2::Attribute::UNSPECIFIED; + + if (XMLString::equals(attributeNameFormat, components->elementAt(0)) && + XMLString::equals(attributeName, components->elementAt(1))) { ret = *a; break; } @@ -683,38 +662,28 @@ gss_eap_saml_attr_provider::getAttribute(const gss_buffer_t attr, } gss_any_t -gss_eap_saml_attr_provider::mapToAny(int authenticated, - gss_buffer_t type_id) const +gss_eap_saml_attr_provider::mapToAny(int authenticated GSSEAP_UNUSED, + gss_buffer_t type_id GSSEAP_UNUSED) const { return (gss_any_t)NULL; } void -gss_eap_saml_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id, - gss_any_t input) const +gss_eap_saml_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id GSSEAP_UNUSED, + gss_any_t input GSSEAP_UNUSED) const { } -void -gss_eap_saml_attr_provider::exportToBuffer(gss_buffer_t buffer) const +const char * +gss_eap_saml_attr_provider::prefix(void) const { - buffer->length = 0; - buffer->value = NULL; -} - -bool -gss_eap_saml_attr_provider::initFromBuffer(const gss_eap_attr_ctx *ctx, - const gss_buffer_t buffer) -{ - return gss_eap_attr_provider::initFromBuffer(ctx, buffer); + return "urn:ietf:params:gss-eap:saml-attr"; } bool gss_eap_saml_attr_provider::init(void) { - gss_eap_attr_ctx::registerProvider(ATTR_TYPE_SAML, - "urn:ietf:params:gss-eap:saml-attr", - createAttrContext); + gss_eap_attr_ctx::registerProvider(ATTR_TYPE_SAML, createAttrContext); return true; } @@ -747,5 +716,7 @@ gssEapSamlAttrProvidersFinalize(OM_uint32 *minor) { gss_eap_saml_attr_provider::finalize(); gss_eap_saml_assertion_provider::finalize(); + + *minor = 0; return GSS_S_COMPLETE; }