From: Scott Cantor Date: Sun, 11 Mar 2007 00:34:15 +0000 (+0000) Subject: Fix format handling in resolver, correct DDF looping bugs. X-Git-Tag: 2.0-alpha1~103 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=8340d90ef1ab324a16021f716db2d968bb058630;p=shibboleth%2Fcpp-sp.git Fix format handling in resolver, correct DDF looping bugs. --- diff --git a/shibsp/attribute/NameIDAttribute.h b/shibsp/attribute/NameIDAttribute.h index 39f2f13..1e05a4d 100644 --- a/shibsp/attribute/NameIDAttribute.h +++ b/shibsp/attribute/NameIDAttribute.h @@ -75,7 +75,7 @@ namespace shibsp { pch = val["SPProvidedID"].string(); if (pch) v.m_SPProvidedID = pch; - val = val.next(); + val = in.first().next(); } } diff --git a/shibsp/attribute/NameIDAttributeDecoder.cpp b/shibsp/attribute/NameIDAttributeDecoder.cpp index 76659c4..2a4beef 100644 --- a/shibsp/attribute/NameIDAttributeDecoder.cpp +++ b/shibsp/attribute/NameIDAttributeDecoder.cpp @@ -90,7 +90,7 @@ shibsp::Attribute* NameIDAttributeDecoder::decode( else { const opensaml::saml1::Attribute* saml1attr = dynamic_cast(xmlObject); if (saml1attr) { - const vector& values = saml2attr->getAttributeValues(); + const vector& values = saml1attr->getAttributeValues(); v = values.begin(); stop = values.end(); if (log.isDebugEnabled()) { diff --git a/shibsp/attribute/ScopedAttribute.h b/shibsp/attribute/ScopedAttribute.h index 0e73c86..98b01bd 100644 --- a/shibsp/attribute/ScopedAttribute.h +++ b/shibsp/attribute/ScopedAttribute.h @@ -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(); } } diff --git a/shibsp/attribute/ScopedAttributeDecoder.cpp b/shibsp/attribute/ScopedAttributeDecoder.cpp index 516474d..312f3d4 100644 --- a/shibsp/attribute/ScopedAttributeDecoder.cpp +++ b/shibsp/attribute/ScopedAttributeDecoder.cpp @@ -83,7 +83,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( else { const opensaml::saml1::Attribute* saml1attr = dynamic_cast(xmlObject); if (saml1attr) { - const vector& values = saml2attr->getAttributeValues(); + const vector& values = saml1attr->getAttributeValues(); v = values.begin(); stop = values.end(); if (log.isDebugEnabled()) { diff --git a/shibsp/attribute/SimpleAttribute.h b/shibsp/attribute/SimpleAttribute.h index 7420b6f..0f2bd15 100644 --- a/shibsp/attribute/SimpleAttribute.h +++ b/shibsp/attribute/SimpleAttribute.h @@ -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(); } } diff --git a/shibsp/attribute/SimpleAttributeDecoder.cpp b/shibsp/attribute/SimpleAttributeDecoder.cpp index f781f38..1bcf8e6 100644 --- a/shibsp/attribute/SimpleAttributeDecoder.cpp +++ b/shibsp/attribute/SimpleAttributeDecoder.cpp @@ -78,7 +78,7 @@ shibsp::Attribute* SimpleAttributeDecoder::decode( else { const opensaml::saml1::Attribute* saml1attr = dynamic_cast(xmlObject); if (saml1attr) { - const vector& values = saml2attr->getAttributeValues(); + const vector& values = saml1attr->getAttributeValues(); v = values.begin(); stop = values.end(); if (log.isDebugEnabled()) { diff --git a/shibsp/attribute/resolver/impl/SimpleAttributeResolver.cpp b/shibsp/attribute/resolver/impl/SimpleAttributeResolver.cpp index 43a2c6c..b2da14e 100644 --- a/shibsp/attribute/resolver/impl/SimpleAttributeResolver.cpp +++ b/shibsp/attribute/resolver/impl/SimpleAttributeResolver.cpp @@ -336,21 +336,20 @@ void SimpleResolverImpl::resolve( // Check the NameID based on the format. const XMLCh* name; const XMLCh* format = ctx.getNameID().getFormat(); - if (!format) { + if (!format || !*format) format = NameID::UNSPECIFIED; #ifdef HAVE_GOOD_STL - if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) { + if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) { #else - auto_ptr_char temp(format); - if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) { + auto_ptr_char temp(format); + if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) { #endif - if (aset.empty() || aset.count(rule->second.second)) { - resolved.push_back( - rule->second.first->decode( - rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty - ) - ); - } + if (aset.empty() || aset.count(rule->second.second)) { + resolved.push_back( + rule->second.first->decode( + rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty + ) + ); } } @@ -362,7 +361,7 @@ void SimpleResolverImpl::resolve( format = (*a)->getAttributeNamespace(); if (!name || !*name) continue; - if (!format) + if (!format || XMLString::equals(format, shibspconstants::SHIB1_ATTRIBUTE_NAMESPACE_URI)) format = &chNull; #ifdef HAVE_GOOD_STL if ((rule=m_attrMap.find(make_pair(name,format))) != m_attrMap.end()) { @@ -404,21 +403,20 @@ void SimpleResolverImpl::resolve( // Check the NameID based on the format. const XMLCh* name; const XMLCh* format = ctx.getNameID().getFormat(); - if (!format) { + if (!format || !*format) format = NameID::UNSPECIFIED; #ifdef HAVE_GOOD_STL - if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) { + if ((rule=m_attrMap.find(make_pair(format,xstring()))) != m_attrMap.end()) { #else - auto_ptr_char temp(format); - if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) { + auto_ptr_char temp(format); + if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) { #endif - if (aset.empty() || aset.count(rule->second.second)) { - resolved.push_back( - rule->second.first->decode( - rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty - ) - ); - } + if (aset.empty() || aset.count(rule->second.second)) { + resolved.push_back( + rule->second.first->decode( + rule->second.second.c_str(), &ctx.getNameID(), assertingParty.get(), relyingParty + ) + ); } } @@ -430,7 +428,9 @@ void SimpleResolverImpl::resolve( format = (*a)->getNameFormat(); if (!name || !*name) continue; - if (!format) + if (!format || !*format) + format = saml2::Attribute::UNSPECIFIED; + else if (XMLString::equals(format, saml2::Attribute::URI_REFERENCE)) format = &chNull; #ifdef HAVE_GOOD_STL if ((rule=m_attrMap.find(make_pair(name,format))) != m_attrMap.end()) { diff --git a/shibsp/impl/RemotedSessionCache.cpp b/shibsp/impl/RemotedSessionCache.cpp index a64222d..f3f6d07 100644 --- a/shibsp/impl/RemotedSessionCache.cpp +++ b/shibsp/impl/RemotedSessionCache.cpp @@ -121,10 +121,11 @@ namespace shibsp { } const vector& getAssertionIDs() const { if (m_ids.empty()) { - DDF id = m_obj["assertions"].first(); + DDF ids = m_obj["assertions"]; + DDF id = ids.first(); while (id.isstring()) { m_ids.push_back(id.string()); - id = id.next(); + id = ids.next(); } } return m_ids; @@ -203,7 +204,8 @@ namespace shibsp { void RemotedSession::unmarshallAttributes() const { Attribute* attribute; - DDF attr = m_obj["attributes"].first(); + DDF attrs = m_obj["attributes"]; + DDF attr = attrs.first(); while (!attr.isnull()) { try { attribute = Attribute::unmarshall(attr); @@ -216,7 +218,7 @@ void RemotedSession::unmarshallAttributes() const const char* id = attr.first().name(); m_cache->m_log.error("error unmarshalling attribute (ID: %s): %s", id ? id : "none", ex.what()); } - attr = attr.next(); + attr = attrs.next(); } } diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp index 142b77c..9a2d8ce 100644 --- a/shibsp/impl/StorageServiceSessionCache.cpp +++ b/shibsp/impl/StorageServiceSessionCache.cpp @@ -110,10 +110,11 @@ namespace shibsp { } const vector& getAssertionIDs() const { if (m_ids.empty()) { - DDF id = m_obj["assertions"].first(); + DDF ids = m_obj["assertions"]; + DDF id = ids.first(); while (id.isstring()) { m_ids.push_back(id.string()); - id = id.next(); + id = ids.next(); } } return m_ids; @@ -181,7 +182,8 @@ StoredSession::~StoredSession() void StoredSession::unmarshallAttributes() const { Attribute* attribute; - DDF attr = m_obj["attributes"].first(); + DDF attrs = m_obj["attributes"]; + DDF attr = attrs.first(); while (!attr.isnull()) { try { attribute = Attribute::unmarshall(attr); @@ -194,7 +196,7 @@ void StoredSession::unmarshallAttributes() const const char* id = attr.first().name(); m_cache->m_log.error("error unmarshalling attribute (ID: %s): %s", id ? id : "none", ex.what()); } - attr = attr.next(); + attr = attrs.next(); } }