#include <shibsp/exceptions.h>
#include <shibsp/attribute/SimpleAttribute.h>
+#include <shibsp/attribute/BinaryAttribute.h>
+#include <shibsp/attribute/ScopedAttribute.h>
#include <shibresolver/resolver.h>
#include <sstream>
{
string attrStr((char *)attr->value, attr->length);
vector <string> ids(1, attrStr);
- SimpleAttribute *a = new SimpleAttribute(ids);
+ BinaryAttribute *a = new BinaryAttribute(ids);
assert(m_initialized);
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);
if (i >= nvalues)
return false;
- buf.value = (void *)shibAttr->getSerializedValues()[*more].c_str();
- buf.length = strlen((char *)buf.value);
+ binaryAttr = dynamic_cast<const BinaryAttribute *>(shibAttr);
+ if (binaryAttr != NULL) {
+ std::string str = binaryAttr->getValues()[*more];
- if (base64Valid((char *)buf.value)) {
- ssize_t octetLen;
+ valueBuf.value = (void *)str.data();
+ valueBuf.length = str.size();
+ } else {
+ std::string str = shibAttr->getSerializedValues()[*more];
- value->value = GSSEAP_MALLOC(buf.length);
- if (value->value == NULL)
- throw std::bad_alloc();
+ valueBuf.value = (void *)str.c_str();
+ valueBuf.length = str.length();
- octetLen = base64Decode((char *)buf.value, value->value);
- if (octetLen < 0) {
- GSSEAP_FREE(value->value);
- value->value = NULL;
- return false;
- }
-
- value->length = octetLen;
- } else if (buf.length != 0) {
- if (value != NULL)
- duplicateBuffer(buf, value);
-
- if (display_value != NULL)
- duplicateBuffer(buf, display_value);
+ const SimpleAttribute *simpleAttr =
+ dynamic_cast<const SimpleAttribute *>(shibAttr);
+ const ScopedAttribute *scopedAttr =
+ dynamic_cast<const ScopedAttribute *>(shibAttr);
+ if (simpleAttr != NULL || scopedAttr != NULL)
+ displayValueBuf = valueBuf;
}
if (authenticated != NULL)
*authenticated = m_authenticated;
if (complete != NULL)
*complete = true;
-
+ if (value != NULL)
+ duplicateBuffer(valueBuf, value);
+ if (display_value != NULL)
+ duplicateBuffer(displayValueBuf, display_value);
if (nvalues > ++i)
*more = i;
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 {
+ ret = ShibbolethResolver::init();
+ } catch (exception &e) {
+ }
- return true;
+ if (ret)
+ gss_eap_attr_ctx::registerProvider(ATTR_TYPE_LOCAL, createAttrContext);
+
+ return ret;
}
void