/*
- * Copyright 2001-2007 Internet2
- *
+ * Copyright 2001-2010 Internet2
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
/**
* ScopedAttributeDecoder.cpp
- *
- * Decodes SAML into ScopedAttributes
+ *
+ * Decodes SAML into ScopedAttributes.
*/
#include "internal.h"
namespace shibsp {
static const XMLCh Scope[] = UNICODE_LITERAL_5(S,c,o,p,e);
- static const XMLCh scopeDelimeter[] = UNICODE_LITERAL_14(s,c,o,p,e,D,e,l,i,m,e,t,e,r);
+ static const XMLCh scopeDelimiter[] = UNICODE_LITERAL_14(s,c,o,p,e,D,e,l,i,m,i,t,e,r);
class SHIBSP_DLLLOCAL ScopedAttributeDecoder : virtual public AttributeDecoder
{
public:
- ScopedAttributeDecoder(const DOMElement* e) : AttributeDecoder(e), m_delimeter('@') {
- if (e) {
- if (e->hasAttributeNS(NULL,scopeDelimeter)) {
- auto_ptr_char d(e->getAttributeNS(NULL,scopeDelimeter));
- m_delimeter = *(d.get());
- }
+ ScopedAttributeDecoder(const DOMElement* e) : AttributeDecoder(e), m_delimiter('@') {
+ if (e && e->hasAttributeNS(nullptr,scopeDelimiter)) {
+ auto_ptr_char d(e->getAttributeNS(nullptr,scopeDelimiter));
+ m_delimiter = *(d.get());
}
}
~ScopedAttributeDecoder() {}
shibsp::Attribute* decode(
- const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL
+ const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty=nullptr, const char* relyingParty=nullptr
) const;
private:
- char m_delimeter;
+ char m_delimiter;
};
AttributeDecoder* SHIBSP_DLLLOCAL ScopedAttributeDecoderFactory(const DOMElement* const & e)
char* val;
char* scope;
const XMLCh* xmlscope;
- QName scopeqname(NULL,Scope);
- auto_ptr<ScopedAttribute> scoped(new ScopedAttribute(ids, m_delimeter));
- scoped->setCaseSensitive(m_caseSensitive);
+ xmltooling::QName scopeqname(nullptr,Scope);
+ auto_ptr<ScopedAttribute> scoped(new ScopedAttribute(ids, m_delimiter));
vector< pair<string,string> >& dest = scoped->getValues();
vector<XMLObject*>::const_iterator v,stop;
- Category& log = Category::getInstance(SHIBSP_LOGCAT".AttributeDecoder");
-
+ 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<const opensaml::saml2::Attribute*>(xmlObject);
if (saml2attr) {
}
else {
log.warn("XMLObject type not recognized by ScopedAttributeDecoder, no values returned");
- return NULL;
+ return nullptr;
}
}
val = toUTF8((*v)->getTextContent());
if (val && *val) {
const AttributeExtensibleXMLObject* aexo=dynamic_cast<const AttributeExtensibleXMLObject*>(*v);
- xmlscope = aexo->getAttribute(scopeqname);
+ xmlscope = aexo ? aexo->getAttribute(scopeqname) : nullptr;
if (xmlscope && *xmlscope) {
scope = toUTF8(xmlscope);
dest.push_back(pair<string,string>(val,scope));
delete[] scope;
}
else {
- scope = strchr(val, m_delimeter);
+ scope = strchr(val, m_delimiter);
if (scope) {
*scope++ = 0;
if (*scope)
}
}
- return dest.empty() ? NULL : scoped.release();
+ return dest.empty() ? nullptr : _decode(scoped.release());
}
const NameID* saml2name = dynamic_cast<const NameID*>(xmlObject);
}
else {
log.warn("XMLObject type not recognized by ScopedAttributeDecoder, no values returned");
- return NULL;
+ return nullptr;
}
}
- if (val && *val && *val!=m_delimeter) {
- scope = strchr(val, m_delimeter);
+ if (val && *val && *val!=m_delimiter) {
+ scope = strchr(val, m_delimiter);
if (scope) {
*scope++ = 0;
if (*scope)
log.warn("ignoring NameID with no scope");
}
else {
- log.warn("ignoring NameID with no scope delimiter (%c)", m_delimeter);
+ log.warn("ignoring NameID with no scope delimiter (%c)", m_delimiter);
}
}
else {
log.warn("ignoring empty NameID");
}
delete[] val;
- return dest.empty() ? NULL : scoped.release();
+ return dest.empty() ? nullptr : _decode(scoped.release());
}