/*\r
- * Copyright 2001-2007 Internet2\r
- * \r
+ * Copyright 2001-2009 Internet2\r
+ *\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
\r
/**\r
* StringAttributeDecoder.cpp\r
- * \r
+ *\r
* Decodes SAML into SimpleAttributes\r
*/\r
\r
#include "attribute/AttributeDecoder.h"\r
#include "attribute/SimpleAttribute.h"\r
\r
-#include <log4cpp/Category.hh>\r
#include <saml/saml1/core/Assertions.h>\r
#include <saml/saml2/core/Assertions.h>\r
\r
using namespace opensaml::saml1;\r
using namespace opensaml::saml2;\r
using namespace xmltooling;\r
-using namespace log4cpp;\r
using namespace std;\r
\r
namespace shibsp {\r
~StringAttributeDecoder() {}\r
\r
shibsp::Attribute* decode(\r
- const char* id, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL\r
+ const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL\r
) const;\r
};\r
\r
};\r
\r
shibsp::Attribute* StringAttributeDecoder::decode(\r
- const char* id, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty\r
+ const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty\r
) const\r
{\r
char* val;\r
- auto_ptr<SimpleAttribute> simple(new SimpleAttribute(id));\r
- simple->setCaseSensitive(m_caseSensitive);\r
+ auto_ptr<SimpleAttribute> simple(new SimpleAttribute(ids));\r
vector<string>& dest = simple->getValues();\r
vector<XMLObject*>::const_iterator v,stop;\r
\r
- Category& log = Category::getInstance(SHIBSP_LOGCAT".AttributeDecoder");\r
+ Category& log = Category::getInstance(SHIBSP_LOGCAT".AttributeDecoder.String");\r
\r
if (xmlObject && XMLString::equals(opensaml::saml1::Attribute::LOCAL_NAME,xmlObject->getElementQName().getLocalPart())) {\r
const opensaml::saml2::Attribute* saml2attr = dynamic_cast<const opensaml::saml2::Attribute*>(xmlObject);\r
stop = values.end();\r
if (log.isDebugEnabled()) {\r
auto_ptr_char n(saml2attr->getName());\r
- log.debug("decoding SimpleAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size());\r
+ log.debug(\r
+ "decoding SimpleAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)",\r
+ ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()\r
+ );\r
}\r
}\r
else {\r
stop = values.end();\r
if (log.isDebugEnabled()) {\r
auto_ptr_char n(saml1attr->getAttributeName());\r
- log.debug("decoding SimpleAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)", id, n.get() ? n.get() : "unnamed", values.size());\r
+ log.debug(\r
+ "decoding SimpleAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)",\r
+ ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()\r
+ );\r
}\r
}\r
else {\r
}\r
}\r
\r
- return dest.empty() ? NULL : simple.release();\r
+ return dest.empty() ? NULL : _decode(simple.release());\r
}\r
\r
const NameID* saml2name = dynamic_cast<const NameID*>(xmlObject);\r
if (saml2name) {\r
if (log.isDebugEnabled()) {\r
auto_ptr_char f(saml2name->getFormat());\r
- log.debug("decoding SimpleAttribute (%s) from SAML 2 NameID with Format (%s)", id, f.get() ? f.get() : "unspecified");\r
+ log.debug("decoding SimpleAttribute (%s) from SAML 2 NameID with Format (%s)", ids.front().c_str(), f.get() ? f.get() : "unspecified");\r
}\r
val = toUTF8(saml2name->getName());\r
}\r
if (saml1name) {\r
if (log.isDebugEnabled()) {\r
auto_ptr_char f(saml1name->getFormat());\r
- log.debug("decoding SimpleAttribute (%s) from SAML 1 NameIdentifier with Format (%s)", id, f.get() ? f.get() : "unspecified");\r
+ log.debug(\r
+ "decoding SimpleAttribute (%s) from SAML 1 NameIdentifier with Format (%s)",\r
+ ids.front().c_str(), f.get() ? f.get() : "unspecified"\r
+ );\r
}\r
val = toUTF8(saml1name->getName());\r
}\r
else\r
log.warn("ignoring empty NameID");\r
delete[] val;\r
- return dest.empty() ? NULL : simple.release();\r
+ return dest.empty() ? NULL : _decode(simple.release());\r
}\r