From: cantor Date: Mon, 6 Aug 2007 02:17:10 +0000 (+0000) Subject: Add back alias support for attributes. X-Git-Tag: 2.4~817 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fsp.git;a=commitdiff_plain;h=ab611786d6ab9b900e60dc1d0b3a240004b81380 Add back alias support for attributes. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2386 cb58f699-b61c-0410-a6fe-9272a202ed29 --- diff --git a/schemas/shibboleth-2.0-attribute-map.xsd b/schemas/shibboleth-2.0-attribute-map.xsd index 1e4fb20..7f88ac1 100644 --- a/schemas/shibboleth-2.0-attribute-map.xsd +++ b/schemas/shibboleth-2.0-attribute-map.xsd @@ -15,6 +15,10 @@ + + + + @@ -39,6 +43,11 @@ The internal attribute ID to which this SAML attribute maps. + + + Optional aliases for the internal attribute to which this SAML attribute maps. + + The SAML 1 AttributeName or SAML 2 Name of the attribute. diff --git a/shibsp/attribute/Attribute.h b/shibsp/attribute/Attribute.h index 4b0e474..c8ff978 100644 --- a/shibsp/attribute/Attribute.h +++ b/shibsp/attribute/Attribute.h @@ -57,9 +57,9 @@ namespace shibsp { /** * Constructor * - * @param id Attribute identifier + * @param ids array with primary identifier in first position, followed by any aliases */ - Attribute(const char* id) : m_id(id ? id : ""), m_caseSensitive(true) { + Attribute(const std::vector& ids) : m_id(ids), m_caseSensitive(true) { } /** @@ -74,12 +74,19 @@ namespace shibsp { Attribute(DDF& in) : m_caseSensitive(in["case_insensitive"].isnull()) { const char* id = in.first().name(); if (id && *id) - m_id = id; + m_id.push_back(id); else throw AttributeException("No id found in marshalled attribute content."); + DDF aliases = in["aliases"]; + if (aliases.islist()) { + DDF alias = aliases.first(); + while (alias.isstring()) { + m_id.push_back(alias.string()); + alias = aliases.next(); + } + } } - /** * Maintains a copy of serialized attribute values, when possible. * @@ -93,10 +100,19 @@ namespace shibsp { /** * Returns the Attribute identifier. * - * @return Attribute identifier + * @return the Attribute identifier */ const char* getId() const { - return m_id.c_str(); + return m_id.front().c_str(); + } + + /** + * Returns all of the effective names for the Attribute. + * + * @return immutable array of identifiers, with the primary ID in the first position + */ + const std::vector& getAliases() const { + return m_id; } /** @@ -181,9 +197,17 @@ namespace shibsp { */ virtual DDF marshall() const { DDF ddf(NULL); - ddf.structure().addmember(m_id.c_str()).list(); + ddf.structure().addmember(m_id.front().c_str()).list(); if (!m_caseSensitive) ddf.addmember("case_insensitive"); + if (m_id.size() > 1) { + DDF alias; + DDF aliases = ddf.addmember("aliases").list(); + for (std::vector::const_iterator a = m_id.begin() + 1; a != m_id.end(); ++a) { + alias = DDF(NULL).string(a->c_str()); + aliases.add(alias); + } + } return ddf; } @@ -226,7 +250,7 @@ namespace shibsp { private: static std::map m_factoryMap; - std::string m_id; + std::vector m_id; bool m_caseSensitive; }; diff --git a/shibsp/attribute/AttributeDecoder.h b/shibsp/attribute/AttributeDecoder.h index dd16148..4d0fe94 100644 --- a/shibsp/attribute/AttributeDecoder.h +++ b/shibsp/attribute/AttributeDecoder.h @@ -51,14 +51,17 @@ namespace shibsp { /** * Decodes an XMLObject into a resolved Attribute. * - * @param id ID of resolved attribute + * @param ids array containing primary identifier in first position, followed by any aliases * @param xmlObject XMLObject to decode * @param assertingParty name of the party asserting the attribute * @param relyingParty name of the party relying on the attribute * @return a resolved Attribute, or NULL */ virtual Attribute* decode( - const char* id, const xmltooling::XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL + const std::vector& ids, + const xmltooling::XMLObject* xmlObject, + const char* assertingParty=NULL, + const char* relyingParty=NULL ) const=0; }; diff --git a/shibsp/attribute/NameIDAttribute.h b/shibsp/attribute/NameIDAttribute.h index 3b674aa..d508ef2 100644 --- a/shibsp/attribute/NameIDAttribute.h +++ b/shibsp/attribute/NameIDAttribute.h @@ -43,12 +43,12 @@ namespace shibsp { { public: /** - * Constructor + * Constructor. * - * @param id Attribute identifier + * @param ids array with primary identifier in first position, followed by any aliases */ - NameIDAttribute(const char* id, const char* formatter=DEFAULT_NAMEID_FORMATTER) - : Attribute(id), m_formatter(formatter) { + NameIDAttribute(const std::vector& ids, const char* formatter=DEFAULT_NAMEID_FORMATTER) + : Attribute(ids), m_formatter(formatter) { } /** diff --git a/shibsp/attribute/NameIDAttributeDecoder.cpp b/shibsp/attribute/NameIDAttributeDecoder.cpp index 19ea010..e813bc1 100644 --- a/shibsp/attribute/NameIDAttributeDecoder.cpp +++ b/shibsp/attribute/NameIDAttributeDecoder.cpp @@ -43,7 +43,7 @@ namespace shibsp { ~NameIDAttributeDecoder() {} shibsp::Attribute* decode( - const char* id, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL + const vector& ids, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL ) const; private: @@ -63,11 +63,11 @@ namespace shibsp { }; shibsp::Attribute* NameIDAttributeDecoder::decode( - const char* id, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty + const vector& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty ) const { auto_ptr nameid( - new NameIDAttribute(id, (m_formatter.get() && *m_formatter.get()) ? m_formatter.get() : DEFAULT_NAMEID_FORMATTER) + new NameIDAttribute(ids, (m_formatter.get() && *m_formatter.get()) ? m_formatter.get() : DEFAULT_NAMEID_FORMATTER) ); nameid->setCaseSensitive(m_caseSensitive); vector& dest = nameid->getValues(); @@ -83,7 +83,10 @@ shibsp::Attribute* NameIDAttributeDecoder::decode( stop = values.end(); if (log.isDebugEnabled()) { auto_ptr_char n(saml2attr->getName()); - log.debug("decoding NameIDAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size()); + log.debug( + "decoding NameIDAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", + ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size() + ); } } else { @@ -94,7 +97,10 @@ shibsp::Attribute* NameIDAttributeDecoder::decode( stop = values.end(); if (log.isDebugEnabled()) { auto_ptr_char n(saml1attr->getAttributeName()); - log.debug("decoding NameIDAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size()); + log.debug( + "decoding NameIDAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", + ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size() + ); } } else { @@ -132,7 +138,7 @@ shibsp::Attribute* NameIDAttributeDecoder::decode( if (saml2name) { if (log.isDebugEnabled()) { auto_ptr_char f(saml2name->getFormat()); - log.debug("decoding NameIDAttribute (%s) from SAML 2 NameID with Format (%s)", id, f.get() ? f.get() : "unspecified"); + log.debug("decoding NameIDAttribute (%s) from SAML 2 NameID with Format (%s)", ids.front().c_str(), f.get() ? f.get() : "unspecified"); } extract(saml2name, dest); } @@ -141,7 +147,10 @@ shibsp::Attribute* NameIDAttributeDecoder::decode( if (saml1name) { if (log.isDebugEnabled()) { auto_ptr_char f(saml1name->getFormat()); - log.debug("decoding NameIDAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", id, f.get() ? f.get() : "unspecified"); + log.debug( + "decoding NameIDAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", + ids.front().c_str(), f.get() ? f.get() : "unspecified" + ); } extract(saml1name, dest); } diff --git a/shibsp/attribute/ScopedAttribute.h b/shibsp/attribute/ScopedAttribute.h index 0e79398..5c87fe8 100644 --- a/shibsp/attribute/ScopedAttribute.h +++ b/shibsp/attribute/ScopedAttribute.h @@ -46,12 +46,14 @@ namespace shibsp { { public: /** - * Constructor + * Constructor. * - * @param id Attribute identifier + * @param ids array with primary identifier in first position, followed by any aliases * @param delimeter value/scope delimeter when serializing */ - ScopedAttribute(const char* id, char delimeter='@') : Attribute(id), m_delimeter(delimeter) {} + ScopedAttribute(const std::vector& ids, char delimeter='@') + : Attribute(ids), m_delimeter(delimeter) { + } /** * Constructs based on a remoted ScopedAttribute. diff --git a/shibsp/attribute/ScopedAttributeDecoder.cpp b/shibsp/attribute/ScopedAttributeDecoder.cpp index 587d346..c194896 100644 --- a/shibsp/attribute/ScopedAttributeDecoder.cpp +++ b/shibsp/attribute/ScopedAttributeDecoder.cpp @@ -51,7 +51,7 @@ namespace shibsp { ~ScopedAttributeDecoder() {} shibsp::Attribute* decode( - const char* id, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL + const vector& ids, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL ) const; private: @@ -65,14 +65,14 @@ namespace shibsp { }; shibsp::Attribute* ScopedAttributeDecoder::decode( - const char* id, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty + const vector& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty ) const { char* val; char* scope; const XMLCh* xmlscope; QName scopeqname(NULL,Scope); - auto_ptr scoped(new ScopedAttribute(id,m_delimeter)); + auto_ptr scoped(new ScopedAttribute(ids, m_delimeter)); scoped->setCaseSensitive(m_caseSensitive); vector< pair >& dest = scoped->getValues(); vector::const_iterator v,stop; @@ -87,7 +87,10 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( stop = values.end(); if (log.isDebugEnabled()) { auto_ptr_char n(saml2attr->getName()); - log.debug("decoding ScopedAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size()); + log.debug( + "decoding ScopedAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", + ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size() + ); } } else { @@ -98,7 +101,10 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( stop = values.end(); if (log.isDebugEnabled()) { auto_ptr_char n(saml1attr->getAttributeName()); - log.debug("decoding ScopedAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size()); + log.debug( + "decoding ScopedAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", + ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size() + ); } } else { @@ -149,7 +155,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( if (saml2name) { if (log.isDebugEnabled()) { auto_ptr_char f(saml2name->getFormat()); - log.debug("decoding ScopedAttribute (%s) from SAML 2 NameID with Format (%s)", id, f.get() ? f.get() : "unspecified"); + log.debug("decoding ScopedAttribute (%s) from SAML 2 NameID with Format (%s)", ids.front().c_str(), f.get() ? f.get() : "unspecified"); } val = toUTF8(saml2name->getName()); } @@ -158,7 +164,10 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( if (saml1name) { if (log.isDebugEnabled()) { auto_ptr_char f(saml1name->getFormat()); - log.debug("decoding ScopedAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", id, f.get() ? f.get() : "unspecified"); + log.debug( + "decoding ScopedAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", + ids.front().c_str(), f.get() ? f.get() : "unspecified" + ); } val = toUTF8(saml1name->getName()); } diff --git a/shibsp/attribute/SimpleAttribute.h b/shibsp/attribute/SimpleAttribute.h index 452beaf..39f869c 100644 --- a/shibsp/attribute/SimpleAttribute.h +++ b/shibsp/attribute/SimpleAttribute.h @@ -34,11 +34,11 @@ namespace shibsp { { public: /** - * Constructor + * Constructor. * - * @param id Attribute identifier + * @param ids array with primary identifier in first position, followed by any aliases */ - SimpleAttribute(const char* id) : Attribute(id) {} + SimpleAttribute(const std::vector& ids) : Attribute(ids) {} /** * Constructs based on a remoted SimpleAttribute. diff --git a/shibsp/attribute/StringAttributeDecoder.cpp b/shibsp/attribute/StringAttributeDecoder.cpp index b652ee0..0e075dd 100644 --- a/shibsp/attribute/StringAttributeDecoder.cpp +++ b/shibsp/attribute/StringAttributeDecoder.cpp @@ -41,7 +41,7 @@ namespace shibsp { ~StringAttributeDecoder() {} shibsp::Attribute* decode( - const char* id, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL + const vector& ids, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL ) const; }; @@ -52,11 +52,11 @@ namespace shibsp { }; shibsp::Attribute* StringAttributeDecoder::decode( - const char* id, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty + const vector& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty ) const { char* val; - auto_ptr simple(new SimpleAttribute(id)); + auto_ptr simple(new SimpleAttribute(ids)); simple->setCaseSensitive(m_caseSensitive); vector& dest = simple->getValues(); vector::const_iterator v,stop; @@ -71,7 +71,10 @@ shibsp::Attribute* StringAttributeDecoder::decode( stop = values.end(); if (log.isDebugEnabled()) { auto_ptr_char n(saml2attr->getName()); - log.debug("decoding SimpleAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size()); + log.debug( + "decoding SimpleAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", + ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size() + ); } } else { @@ -82,7 +85,10 @@ shibsp::Attribute* StringAttributeDecoder::decode( stop = values.end(); if (log.isDebugEnabled()) { auto_ptr_char n(saml1attr->getAttributeName()); - log.debug("decoding SimpleAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size()); + log.debug( + "decoding SimpleAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", + ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size() + ); } } else { @@ -112,7 +118,7 @@ shibsp::Attribute* StringAttributeDecoder::decode( if (saml2name) { if (log.isDebugEnabled()) { auto_ptr_char f(saml2name->getFormat()); - log.debug("decoding SimpleAttribute (%s) from SAML 2 NameID with Format (%s)", id, f.get() ? f.get() : "unspecified"); + log.debug("decoding SimpleAttribute (%s) from SAML 2 NameID with Format (%s)", ids.front().c_str(), f.get() ? f.get() : "unspecified"); } val = toUTF8(saml2name->getName()); } @@ -121,7 +127,10 @@ shibsp::Attribute* StringAttributeDecoder::decode( if (saml1name) { if (log.isDebugEnabled()) { auto_ptr_char f(saml1name->getFormat()); - log.debug("decoding SimpleAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", id, f.get() ? f.get() : "unspecified"); + log.debug( + "decoding SimpleAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", + ids.front().c_str(), f.get() ? f.get() : "unspecified" + ); } val = toUTF8(saml1name->getName()); } diff --git a/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp b/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp index e0942e2..e7915c4 100644 --- a/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp +++ b/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp @@ -87,9 +87,9 @@ namespace shibsp { Category& m_log; DOMDocument* m_document; #ifdef HAVE_GOOD_STL - typedef map< pair,pair > attrmap_t; + typedef map< pair,pair< AttributeDecoder*,vector > > attrmap_t; #else - typedef map< pair,pair > attrmap_t; + typedef map< pair,pair< AttributeDecoder*,vector > > attrmap_t; #endif attrmap_t m_attrMap; vector m_attributeIds; @@ -133,6 +133,7 @@ namespace shibsp { static const XMLCh _AttributeDecoder[] = UNICODE_LITERAL_16(A,t,t,r,i,b,u,t,e,D,e,c,o,d,e,r); static const XMLCh Attributes[] = UNICODE_LITERAL_10(A,t,t,r,i,b,u,t,e,s); static const XMLCh _id[] = UNICODE_LITERAL_2(i,d); + static const XMLCh _aliases[] = UNICODE_LITERAL_7(a,l,i,a,s,e,s); static const XMLCh _name[] = UNICODE_LITERAL_4(n,a,m,e); static const XMLCh nameFormat[] = UNICODE_LITERAL_10(n,a,m,e,F,o,r,m,a,t); }; @@ -201,11 +202,11 @@ XMLExtractorImpl::XMLExtractorImpl(const DOMElement* e, Category& log) : m_log(l // Fetch/create the map entry and see if it's a duplicate rule. #ifdef HAVE_GOOD_STL - pair& decl = m_attrMap[make_pair(name,format)]; + pair< AttributeDecoder*,vector >& decl = m_attrMap[make_pair(name,format)]; #else auto_ptr_char n(name); auto_ptr_char f(format); - pair& decl = m_attrMap[make_pair(n.get(),f.get())]; + pair< AttributeDecoder*,vector >& decl = m_attrMap[make_pair(n.get(),f.get())]; #endif if (decl.first) { m_log.warn("skipping duplicate Attribute mapping (same name and nameFormat)"); @@ -223,8 +224,32 @@ XMLExtractorImpl::XMLExtractorImpl(const DOMElement* e, Category& log) : m_log(l } decl.first = decoder; - decl.second = id.get(); + decl.second.push_back(id.get()); m_attributeIds.push_back(id.get()); + + name = child->getAttributeNS(NULL, _aliases); + if (name && *name) { + auto_ptr_char aliases(name); + char* pos; + char* start = const_cast(aliases.get()); + while (start && *start) { + while (*start && isspace(*start)) + start++; + if (!*start) + break; + pos = strchr(start,' '); + if (pos) + *pos=0; + if (strcmp(start, "REMOTE_USER")) { + decl.second.push_back(start); + m_attributeIds.push_back(start); + } + else { + m_log.warn("skipping alias, REMOTE_USER is a reserved name"); + } + start = pos ? pos+1 : NULL; + } + } child = XMLHelper::getNextSiblingElement(child, shibspconstants::SHIB2ATTRIBUTEMAP_NS, saml1::Attribute::LOCAL_NAME); } @@ -235,9 +260,9 @@ void XMLExtractorImpl::extractAttributes( ) const { #ifdef HAVE_GOOD_STL - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #else - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #endif const XMLCh* format = nameid.getFormat(); @@ -249,7 +274,7 @@ void XMLExtractorImpl::extractAttributes( auto_ptr_char temp(format); if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) { #endif - Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &nameid, assertingParty, application.getString("entityID").second); + Attribute* a = rule->second.first->decode(rule->second.second, &nameid, assertingParty, application.getString("entityID").second); if (a) attributes.push_back(a); } @@ -260,9 +285,9 @@ void XMLExtractorImpl::extractAttributes( ) const { #ifdef HAVE_GOOD_STL - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #else - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #endif const XMLCh* format = nameid.getFormat(); @@ -274,7 +299,7 @@ void XMLExtractorImpl::extractAttributes( auto_ptr_char temp(format); if ((rule=m_attrMap.find(make_pair(temp.get(),string()))) != m_attrMap.end()) { #endif - Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &nameid, assertingParty, application.getString("entityID").second); + Attribute* a = rule->second.first->decode(rule->second.second, &nameid, assertingParty, application.getString("entityID").second); if (a) attributes.push_back(a); } @@ -285,9 +310,9 @@ void XMLExtractorImpl::extractAttributes( ) const { #ifdef HAVE_GOOD_STL - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #else - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #endif const XMLCh* name = attr.getAttributeName(); @@ -303,7 +328,7 @@ void XMLExtractorImpl::extractAttributes( auto_ptr_char temp2(format); if ((rule=m_attrMap.find(make_pair(temp1.get(),temp2.get()))) != m_attrMap.end()) { #endif - Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &attr, assertingParty, application.getString("entityID").second); + Attribute* a = rule->second.first->decode(rule->second.second, &attr, assertingParty, application.getString("entityID").second); if (a) attributes.push_back(a); } @@ -314,9 +339,9 @@ void XMLExtractorImpl::extractAttributes( ) const { #ifdef HAVE_GOOD_STL - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #else - map< pair,pair >::const_iterator rule; + map< pair,pair< AttributeDecoder*,vector > >::const_iterator rule; #endif const XMLCh* name = attr.getName(); @@ -334,7 +359,7 @@ void XMLExtractorImpl::extractAttributes( auto_ptr_char temp2(format); if ((rule=m_attrMap.find(make_pair(temp1.get(),temp2.get()))) != m_attrMap.end()) { #endif - Attribute* a = rule->second.first->decode(rule->second.second.c_str(), &attr, assertingParty, application.getString("entityID").second); + Attribute* a = rule->second.first->decode(rule->second.second, &attr, assertingParty, application.getString("entityID").second); if (a) attributes.push_back(a); } diff --git a/shibsp/impl/RemotedSessionCache.cpp b/shibsp/impl/RemotedSessionCache.cpp index e7bdbc9..48266ff 100644 --- a/shibsp/impl/RemotedSessionCache.cpp +++ b/shibsp/impl/RemotedSessionCache.cpp @@ -105,8 +105,15 @@ namespace shibsp { return m_attributes; } const multimap& getIndexedAttributes() const { - if (m_attributes.empty()) - unmarshallAttributes(); + if (m_attributeIndex.empty()) { + if (m_attributes.empty()) + unmarshallAttributes(); + for (vector::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a) { + const vector& aliases = (*a)->getAliases(); + for (vector::const_iterator alias = aliases.begin(); alias != aliases.end(); ++alias) + m_attributeIndex.insert(make_pair(*alias, *a)); + } + } return m_attributeIndex; } const vector& getAssertionIDs() const { @@ -177,7 +184,6 @@ void RemotedSession::unmarshallAttributes() const try { attribute = Attribute::unmarshall(attr); m_attributes.push_back(attribute); - m_attributeIndex.insert(make_pair(attribute->getId(),attribute)); if (m_cache->m_log.isDebugEnabled()) m_cache->m_log.debug("unmarshalled attribute (ID: %s) with %d value%s", attribute->getId(), attr.first().integer(), attr.first().integer()!=1 ? "s" : ""); diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp index c1e7256..f310a55 100644 --- a/shibsp/impl/StorageServiceSessionCache.cpp +++ b/shibsp/impl/StorageServiceSessionCache.cpp @@ -112,9 +112,16 @@ namespace shibsp { return m_attributes; } const multimap& getIndexedAttributes() const { - if (m_attributes.empty()) - unmarshallAttributes(); - return m_attributeIndex; + if (m_attributeIndex.empty()) { + if (m_attributes.empty()) + unmarshallAttributes(); + for (vector::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a) { + const vector& aliases = (*a)->getAliases(); + for (vector::const_iterator alias = aliases.begin(); alias != aliases.end(); ++alias) + m_attributeIndex.insert(make_pair(*alias, *a)); + } + } + return m_attributeIndex; } const vector& getAssertionIDs() const { if (m_ids.empty()) {