Fix format handling in resolver, correct DDF looping bugs.
authorScott Cantor <cantor.2@osu.edu>
Sun, 11 Mar 2007 00:34:15 +0000 (00:34 +0000)
committerScott Cantor <cantor.2@osu.edu>
Sun, 11 Mar 2007 00:34:15 +0000 (00:34 +0000)
shibsp/attribute/NameIDAttribute.h
shibsp/attribute/NameIDAttributeDecoder.cpp
shibsp/attribute/ScopedAttribute.h
shibsp/attribute/ScopedAttributeDecoder.cpp
shibsp/attribute/SimpleAttribute.h
shibsp/attribute/SimpleAttributeDecoder.cpp
shibsp/attribute/resolver/impl/SimpleAttributeResolver.cpp
shibsp/impl/RemotedSessionCache.cpp
shibsp/impl/StorageServiceSessionCache.cpp

index 39f2f13..1e05a4d 100644 (file)
@@ -75,7 +75,7 @@ namespace shibsp {
                 pch = val["SPProvidedID"].string();
                 if (pch)
                     v.m_SPProvidedID = pch;
-                val = val.next();
+                val = in.first().next();
             }
         }
         
index 76659c4..2a4beef 100644 (file)
@@ -90,7 +90,7 @@ shibsp::Attribute* NameIDAttributeDecoder::decode(
         else {\r
             const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);\r
             if (saml1attr) {\r
-                const vector<XMLObject*>& values = saml2attr->getAttributeValues();\r
+                const vector<XMLObject*>& values = saml1attr->getAttributeValues();\r
                 v = values.begin();\r
                 stop = values.end();\r
                 if (log.isDebugEnabled()) {\r
index 0e73c86..98b01bd 100644 (file)
@@ -61,7 +61,7 @@ namespace shibsp {
             DDF val = in.first().first();
             while (val.name() && val.string()) {
                 m_values.push_back(std::make_pair(val.name(), val.string()));
-                val = val.next();
+                val = in.first().next();
             }
         }
         
index 516474d..312f3d4 100644 (file)
@@ -83,7 +83,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode(
         else {\r
             const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);\r
             if (saml1attr) {\r
-                const vector<XMLObject*>& values = saml2attr->getAttributeValues();\r
+                const vector<XMLObject*>& values = saml1attr->getAttributeValues();\r
                 v = values.begin();\r
                 stop = values.end();\r
                 if (log.isDebugEnabled()) {\r
index 7420b6f..0f2bd15 100644 (file)
@@ -49,7 +49,7 @@ namespace shibsp {
             DDF val = in.first().first();
             while (val.string()) {
                 m_serialized.push_back(val.string());
-                val = val.next();
+                val = in.first().next();
             }
         }
         
index f781f38..1bcf8e6 100644 (file)
@@ -78,7 +78,7 @@ shibsp::Attribute* SimpleAttributeDecoder::decode(
         else {\r
             const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);\r
             if (saml1attr) {\r
-                const vector<XMLObject*>& values = saml2attr->getAttributeValues();\r
+                const vector<XMLObject*>& values = saml1attr->getAttributeValues();\r
                 v = values.begin();\r
                 stop = values.end();\r
                 if (log.isDebugEnabled()) {\r
index 43a2c6c..b2da14e 100644 (file)
@@ -336,21 +336,20 @@ void SimpleResolverImpl::resolve(
     // Check the NameID based on the format.\r
     const XMLCh* name;\r
     const XMLCh* format = ctx.getNameID().getFormat();\r
-    if (!format) {\r
+    if (!format || !*format)\r
         format = NameID::UNSPECIFIED;\r
 #ifdef HAVE_GOOD_STL\r
-        if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) {\r
+    if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) {\r
 #else\r
-        auto_ptr_char temp(format);\r
-        if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) {\r
+    auto_ptr_char temp(format);\r
+    if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) {\r
 #endif\r
-            if (aset.empty() || aset.count(rule->second.second)) {\r
-                resolved.push_back(\r
-                    rule->second.first->decode(\r
-                        rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty\r
-                        )\r
-                    );\r
-            }\r
+        if (aset.empty() || aset.count(rule->second.second)) {\r
+            resolved.push_back(\r
+                rule->second.first->decode(\r
+                    rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty\r
+                    )\r
+                );\r
         }\r
     }\r
 \r
@@ -362,7 +361,7 @@ void SimpleResolverImpl::resolve(
             format = (*a)->getAttributeNamespace();\r
             if (!name || !*name)\r
                 continue;\r
-            if (!format)\r
+            if (!format || XMLString::equals(format, shibspconstants::SHIB1_ATTRIBUTE_NAMESPACE_URI))\r
                 format = &chNull;\r
 #ifdef HAVE_GOOD_STL\r
             if ((rule=m_attrMap.find(make_pair(name,format))) != m_attrMap.end()) {\r
@@ -404,21 +403,20 @@ void SimpleResolverImpl::resolve(
     // Check the NameID based on the format.\r
     const XMLCh* name;\r
     const XMLCh* format = ctx.getNameID().getFormat();\r
-    if (!format) {\r
+    if (!format || !*format)\r
         format = NameID::UNSPECIFIED;\r
 #ifdef HAVE_GOOD_STL\r
-        if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) {\r
+    if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) {\r
 #else\r
-        auto_ptr_char temp(format);\r
-        if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) {\r
+    auto_ptr_char temp(format);\r
+    if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) {\r
 #endif\r
-            if (aset.empty() || aset.count(rule->second.second)) {\r
-                resolved.push_back(\r
-                    rule->second.first->decode(\r
-                        rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty\r
-                        )\r
-                    );\r
-            }\r
+        if (aset.empty() || aset.count(rule->second.second)) {\r
+            resolved.push_back(\r
+                rule->second.first->decode(\r
+                    rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty\r
+                    )\r
+                );\r
         }\r
     }\r
 \r
@@ -430,7 +428,9 @@ void SimpleResolverImpl::resolve(
             format = (*a)->getNameFormat();\r
             if (!name || !*name)\r
                 continue;\r
-            if (!format)\r
+            if (!format || !*format)\r
+                format = saml2::Attribute::UNSPECIFIED;\r
+            else if (XMLString::equals(format, saml2::Attribute::URI_REFERENCE))\r
                 format = &chNull;\r
 #ifdef HAVE_GOOD_STL\r
             if ((rule=m_attrMap.find(make_pair(name,format))) != m_attrMap.end()) {\r
index a64222d..f3f6d07 100644 (file)
@@ -121,10 +121,11 @@ namespace shibsp {
         }\r
         const vector<const char*>& getAssertionIDs() const {\r
             if (m_ids.empty()) {\r
-                DDF id = m_obj["assertions"].first();\r
+                DDF ids = m_obj["assertions"];\r
+                DDF id = ids.first();\r
                 while (id.isstring()) {\r
                     m_ids.push_back(id.string());\r
-                    id = id.next();\r
+                    id = ids.next();\r
                 }\r
             }\r
             return m_ids;\r
@@ -203,7 +204,8 @@ namespace shibsp {
 void RemotedSession::unmarshallAttributes() const\r
 {\r
     Attribute* attribute;\r
-    DDF attr = m_obj["attributes"].first();\r
+    DDF attrs = m_obj["attributes"];\r
+    DDF attr = attrs.first();\r
     while (!attr.isnull()) {\r
         try {\r
             attribute = Attribute::unmarshall(attr);\r
@@ -216,7 +218,7 @@ void RemotedSession::unmarshallAttributes() const
             const char* id = attr.first().name();\r
             m_cache->m_log.error("error unmarshalling attribute (ID: %s): %s", id ? id : "none", ex.what());\r
         }\r
-        attr = attr.next();\r
+        attr = attrs.next();\r
     }\r
 }\r
 \r
index 142b77c..9a2d8ce 100644 (file)
@@ -110,10 +110,11 @@ namespace shibsp {
         }\r
         const vector<const char*>& getAssertionIDs() const {\r
             if (m_ids.empty()) {\r
-                DDF id = m_obj["assertions"].first();\r
+                DDF ids = m_obj["assertions"];\r
+                DDF id = ids.first();\r
                 while (id.isstring()) {\r
                     m_ids.push_back(id.string());\r
-                    id = id.next();\r
+                    id = ids.next();\r
                 }\r
             }\r
             return m_ids;\r
@@ -181,7 +182,8 @@ StoredSession::~StoredSession()
 void StoredSession::unmarshallAttributes() const\r
 {\r
     Attribute* attribute;\r
-    DDF attr = m_obj["attributes"].first();\r
+    DDF attrs = m_obj["attributes"];\r
+    DDF attr = attrs.first();\r
     while (!attr.isnull()) {\r
         try {\r
             attribute = Attribute::unmarshall(attr);\r
@@ -194,7 +196,7 @@ void StoredSession::unmarshallAttributes() const
             const char* id = attr.first().name();\r
             m_cache->m_log.error("error unmarshalling attribute (ID: %s): %s", id ? id : "none", ex.what());\r
         }\r
-        attr = attr.next();\r
+        attr = attrs.next();\r
     }\r
 }\r
 \r