X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibsp%2Fattribute%2FScopedAttributeDecoder.cpp;h=7a667b764fac64285381b251e0a6bbb9d5ee9c2c;hb=c51bfd77603cf0ddb0b5e374c35586a8435895d6;hp=7e4526c53f941148aa3fe269436070d92a449a3e;hpb=db2b0568bef31c09a03238005c6871d1ab8637b5;p=shibboleth%2Fcpp-sp.git diff --git a/shibsp/attribute/ScopedAttributeDecoder.cpp b/shibsp/attribute/ScopedAttributeDecoder.cpp index 7e4526c..7a667b7 100644 --- a/shibsp/attribute/ScopedAttributeDecoder.cpp +++ b/shibsp/attribute/ScopedAttributeDecoder.cpp @@ -52,8 +52,15 @@ namespace shibsp { } ~ScopedAttributeDecoder() {} + // deprecated method shibsp::Attribute* decode( const vector& ids, const XMLObject* xmlObject, const char* assertingParty=nullptr, const char* relyingParty=nullptr + ) const { + return decode(nullptr, ids, xmlObject, assertingParty, relyingParty); + } + + shibsp::Attribute* decode( + const GenericRequest*, const vector&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr ) const; private: @@ -67,7 +74,7 @@ namespace shibsp { }; shibsp::Attribute* ScopedAttributeDecoder::decode( - const vector& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty + const GenericRequest* request, const vector& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty ) const { char* val; @@ -76,16 +83,15 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( xmltooling::QName scopeqname(nullptr,Scope); auto_ptr scoped(new ScopedAttribute(ids, m_delimiter)); vector< pair >& dest = scoped->getValues(); - vector::const_iterator v,stop; + pair::const_iterator,vector::const_iterator> valrange; - Category& log = Category::getInstance(SHIBSP_LOGCAT".AttributeDecoder.Scoped"); + Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.Scoped"); if (xmlObject && XMLString::equals(opensaml::saml1::Attribute::LOCAL_NAME,xmlObject->getElementQName().getLocalPart())) { const opensaml::saml2::Attribute* saml2attr = dynamic_cast(xmlObject); if (saml2attr) { const vector& values = saml2attr->getAttributeValues(); - v = values.begin(); - stop = values.end(); + valrange = valueRange(request, values); if (log.isDebugEnabled()) { auto_ptr_char n(saml2attr->getName()); log.debug( @@ -98,8 +104,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( const opensaml::saml1::Attribute* saml1attr = dynamic_cast(xmlObject); if (saml1attr) { const vector& values = saml1attr->getAttributeValues(); - v = values.begin(); - stop = values.end(); + valrange = valueRange(request, values); if (log.isDebugEnabled()) { auto_ptr_char n(saml1attr->getAttributeName()); log.debug( @@ -114,16 +119,15 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( } } - for (; v!=stop; ++v) { - if (!(*v)->hasChildren()) { - val = toUTF8((*v)->getTextContent()); + for (; valrange.first != valrange.second; ++valrange.first) { + if (!(*valrange.first)->hasChildren()) { + val = toUTF8((*valrange.first)->getTextContent()); if (val && *val) { - const AttributeExtensibleXMLObject* aexo=dynamic_cast(*v); + const AttributeExtensibleXMLObject* aexo=dynamic_cast(*valrange.first); xmlscope = aexo ? aexo->getAttribute(scopeqname) : nullptr; if (xmlscope && *xmlscope) { - scope = toUTF8(xmlscope); - dest.push_back(pair(val,scope)); - delete[] scope; + auto_arrayptr noninlinescope(toUTF8(xmlscope)); + dest.push_back(pair(val,noninlinescope.get())); } else { scope = strchr(val, m_delimiter); @@ -178,7 +182,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode( } } - if (val && *val && *val!=m_delimiter) { + if (val && *val && *val != m_delimiter) { scope = strchr(val, m_delimiter); if (scope) { *scope++ = 0;