Upgrade Shibboleth for binary attribute support
authorLuke Howard <lukeh@padl.com>
Mon, 23 May 2011 15:05:30 +0000 (11:05 -0400)
committerLuke Howard <lukeh@padl.com>
Mon, 23 May 2011 15:05:30 +0000 (11:05 -0400)
moonshot/mech_eap/util_shib.cpp
shibboleth/opensaml2
shibboleth/resolver
shibboleth/sp
shibboleth/xmltooling

index 15a8b44..ba83762 100644 (file)
@@ -54,6 +54,7 @@
 #include <saml/saml2/core/Assertions.h>
 
 #include <shibsp/exceptions.h>
+#include <shibsp/attribute/BinaryAttribute.h>
 #include <shibsp/attribute/SimpleAttribute.h>
 #include <shibresolver/resolver.h>
 
@@ -193,7 +194,7 @@ gss_eap_shib_attr_provider::setAttribute(int complete GSSEAP_UNUSED,
 {
     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);
 
@@ -283,7 +284,8 @@ gss_eap_shib_attr_provider::getAttribute(const gss_buffer_t attr,
                                          int *more) const
 {
     const Attribute *shibAttr = NULL;
-    gss_buffer_desc buf;
+    gss_buffer_desc valueBuf = GSS_C_EMPTY_BUFFER;
+    gss_buffer_desc displayValueBuf = GSS_C_EMPTY_BUFFER;
     int nvalues, i = *more;
 
     assert(m_initialized);
@@ -301,39 +303,30 @@ 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);
+    if (typeid(*shibAttr) == typeid(BinaryAttribute)) {
+        const BinaryAttribute *binaryAttr =
+            dynamic_cast<const BinaryAttribute *>(shibAttr);
+        std::string str = binaryAttr->getValues()[*more];
 
-    /* XXX hack until we have proper binary attribute support */
-    if (attr->length == sizeof("urn:mspac:") - 1 &&
-        memcmp(attr->value, "urn:mspac:", attr->length) == 0) {
-        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);
+        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;
 
index c1d7574..99dbaa4 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c1d75749e438628900ae880a3dafd96f4a97f15e
+Subproject commit 99dbaa4bd3135146178eb201c76f024770a02713
index 24967b2..e1448b2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 24967b25cc7d6573d3ab76d0d8a1f02d93c6b106
+Subproject commit e1448b2d4c30435dc69124cfb7b6371275910355
index bdbac80..52e973a 160000 (submodule)
@@ -1 +1 @@
-Subproject commit bdbac801c636a747fdb3c0a39a564f3f77452cf3
+Subproject commit 52e973ac041e2fc3ae3131b1099d435dce6a730d
index ec12184..353b772 160000 (submodule)
@@ -1 +1 @@
-Subproject commit ec12184bd72287b88af4301bde2df916fc475615
+Subproject commit 353b7728052ee906e8950756c5dfacefc1be3089