X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=moonshot%2Fmech_eap%2Futil_shib.cpp;h=61244840897fa35d032a8a8796b32040bf0c6d9c;hb=46cd48af6af8556f19885f7902602142e8533910;hp=3d2aa2cd55fc53b9c10a5d7e93060aca085d4ea9;hpb=a9bf34aa6f6cf8d8ab975989ae5103798d7e3e75;p=moonshot.git diff --git a/moonshot/mech_eap/util_shib.cpp b/moonshot/mech_eap/util_shib.cpp index 3d2aa2c..6124484 100644 --- a/moonshot/mech_eap/util_shib.cpp +++ b/moonshot/mech_eap/util_shib.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -193,7 +194,7 @@ gss_eap_shib_attr_provider::setAttribute(int complete GSSEAP_UNUSED, { string attrStr((char *)attr->value, attr->length); vector ids(1, attrStr); - SimpleAttribute *a = new SimpleAttribute(ids); + BinaryAttribute *a = new BinaryAttribute(ids); assert(m_initialized); @@ -283,7 +284,9 @@ gss_eap_shib_attr_provider::getAttribute(const gss_buffer_t attr, int *more) const { const Attribute *shibAttr = NULL; - gss_buffer_desc buf; + const BinaryAttribute *binaryAttr; + gss_buffer_desc valueBuf = GSS_C_EMPTY_BUFFER; + gss_buffer_desc displayValueBuf = GSS_C_EMPTY_BUFFER; int nvalues, i = *more; assert(m_initialized); @@ -301,22 +304,29 @@ gss_eap_shib_attr_provider::getAttribute(const gss_buffer_t attr, if (i >= nvalues) return false; - buf.value = (void *)shibAttr->getSerializedValues()[*more].c_str(); - buf.length = strlen((char *)buf.value); + binaryAttr = dynamic_cast(shibAttr); + if (binaryAttr != NULL) { + std::string str = binaryAttr->getValues()[*more]; - if (buf.length != 0) { - if (value != NULL) - duplicateBuffer(buf, value); + valueBuf.value = (void *)str.data(); + valueBuf.length = str.size(); + } else { + std::string str = shibAttr->getSerializedValues()[*more]; - if (display_value != NULL) - duplicateBuffer(buf, display_value); + valueBuf.value = (void *)str.c_str(); + valueBuf.length = str.length(); + + displayValueBuf = valueBuf; } if (authenticated != NULL) *authenticated = m_authenticated; if (complete != NULL) - *complete = false; - + *complete = true; + if (value != NULL) + duplicateBuffer(valueBuf, value); + if (display_value != NULL) + duplicateBuffer(displayValueBuf, display_value); if (nvalues > ++i) *more = i; @@ -417,13 +427,18 @@ gss_eap_shib_attr_provider::initWithJsonObject(const gss_eap_attr_ctx *ctx, bool gss_eap_shib_attr_provider::init(void) { - if (SPConfig::getConfig().getFeatures() == 0 && - ShibbolethResolver::init() == false) - return false; + bool ret = false; - gss_eap_attr_ctx::registerProvider(ATTR_TYPE_LOCAL, createAttrContext); + try { + if (SPConfig::getConfig().getFeatures() == 0) + ret = ShibbolethResolver::init(); + } catch (exception &e) { + } - return true; + if (ret) + gss_eap_attr_ctx::registerProvider(ATTR_TYPE_LOCAL, createAttrContext); + + return ret; } void