StringAttributeDecoder(const DOMElement* e) : AttributeDecoder(e) {}
~StringAttributeDecoder() {}
+ // deprecated method
shibsp::Attribute* decode(
const vector<string>& 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<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
) const;
};
};
shibsp::Attribute* StringAttributeDecoder::decode(
- const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
+ const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
) const
{
- char* val;
auto_ptr<SimpleAttribute> simple(new SimpleAttribute(ids));
vector<string>& dest = simple->getValues();
- vector<XMLObject*>::const_iterator v,stop;
+ pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
Category& log = Category::getInstance(SHIBSP_LOGCAT".AttributeDecoder.String");
const opensaml::saml2::Attribute* saml2attr = dynamic_cast<const opensaml::saml2::Attribute*>(xmlObject);
if (saml2attr) {
const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- v = values.begin();
- stop = values.end();
+ valrange = valueRange(request, values);
if (log.isDebugEnabled()) {
auto_ptr_char n(saml2attr->getName());
log.debug(
const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);
if (saml1attr) {
const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- v = values.begin();
- stop = values.end();
+ valrange = valueRange(request, values);
if (log.isDebugEnabled()) {
auto_ptr_char n(saml1attr->getAttributeName());
log.debug(
}
}
- for (; v!=stop; ++v) {
- if (!(*v)->hasChildren()) {
- val = toUTF8((*v)->getTextContent());
- if (val && *val)
- dest.push_back(val);
+ for (; valrange.first != valrange.second; ++valrange.first) {
+ if (!(*valrange.first)->hasChildren()) {
+ auto_arrayptr<char> val(toUTF8((*valrange.first)->getTextContent()));
+ if (val.get() && *val.get())
+ dest.push_back(val.get());
else
log.warn("skipping empty AttributeValue");
- delete[] val;
}
else {
log.warn("skipping complex AttributeValue");
auto_ptr_char f(saml2name->getFormat());
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());
+ auto_arrayptr<char> val(toUTF8(saml2name->getName()));
+ if (val.get() && *val.get())
+ dest.push_back(val.get());
+ else
+ log.warn("ignoring empty NameID");
}
else {
const NameIdentifier* saml1name = dynamic_cast<const NameIdentifier*>(xmlObject);
ids.front().c_str(), f.get() ? f.get() : "unspecified"
);
}
- val = toUTF8(saml1name->getName());
+ auto_arrayptr<char> val(toUTF8(saml1name->getName()));
+ if (val.get() && *val.get())
+ dest.push_back(val.get());
+ else
+ log.warn("ignoring empty NameIdentifier");
}
else {
log.warn("XMLObject type not recognized by StringAttributeDecoder, no values returned");
}
}
- if (val && *val)
- dest.push_back(val);
- else
- log.warn("ignoring empty NameID");
- delete[] val;
return dest.empty() ? nullptr : _decode(simple.release());
}