[cpp-sp] branch main updated: Remove AttributeDecoder code.
Scott Cantor
cantor.2 at osu.edu
Wed Oct 30 21:27:25 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=5f6ef96fcd65ce3b18b882e5a221745eb3e33eb8
The following commit(s) were added to refs/heads/main by this push:
new 5f6ef96f Remove AttributeDecoder code.
5f6ef96f is described below
commit 5f6ef96fcd65ce3b18b882e5a221745eb3e33eb8
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 30 17:27:21 2024 -0400
Remove AttributeDecoder code.
---
shibsp/Makefile.am | 1 -
shibsp/attribute/AttributeDecoder.h | 142 ------------
shibsp/attribute/Base64AttributeDecoder.cpp | 183 ----------------
shibsp/attribute/DOMAttributeDecoder.cpp | 234 --------------------
shibsp/attribute/KeyInfoAttributeDecoder.cpp | 168 --------------
shibsp/attribute/NameIDAttributeDecoder.cpp | 242 ---------------------
.../attribute/NameIDFromScopedAttributeDecoder.cpp | 163 --------------
shibsp/attribute/ScopedAttributeDecoder.cpp | 196 -----------------
shibsp/attribute/StringAttributeDecoder.cpp | 151 -------------
shibsp/attribute/XMLAttributeDecoder.cpp | 142 ------------
10 files changed, 1622 deletions(-)
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index ec2ae137..e33099eb 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -39,7 +39,6 @@ libshibspinclude_HEADERS = \
attrinclude_HEADERS = \
attribute/Attribute.h \
- attribute/AttributeDecoder.h \
attribute/BinaryAttribute.h \
attribute/ExtensibleAttribute.h \
attribute/NameIDAttribute.h \
diff --git a/shibsp/attribute/AttributeDecoder.h b/shibsp/attribute/AttributeDecoder.h
deleted file mode 100644
index 8a0d5218..00000000
--- a/shibsp/attribute/AttributeDecoder.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * @file shibsp/attribute/AttributeDecoder.h
- *
- * Decodes SAML NameID/Attribute objects into resolved Attributes.
- */
-
-#ifndef __shibsp_attrdecoder_h__
-#define __shibsp_attrdecoder_h__
-
-#include <shibsp/base.h>
-
-#include <string>
-#include <vector>
-
-namespace xmltooling {
- class XMLTOOL_API GenericRequest;
- class XMLTOOL_API QName;
- class XMLTOOL_API XMLObject;
-};
-
-namespace shibsp {
-
- class SHIBSP_API Attribute;
-
- /**
- * Decodes XML objects into resolved Attributes.
- */
- class SHIBSP_API AttributeDecoder
- {
- MAKE_NONCOPYABLE(AttributeDecoder);
- protected:
- /**
- * Constructor.
- *
- * @param e root of DOM to configure the decoder
- */
- AttributeDecoder(const xercesc::DOMElement* e);
-
- /** Flag for case sensitivity of decoded attributes. */
- bool m_caseSensitive;
-
- /** Flag for hiding attributes from CGI export. */
- bool m_internal;
-
- /** Flag for language aware decoding. */
- bool m_langAware;
-
- /** Hash algorithm to apply to decoded values. */
- std::string m_hashAlg;
-
- /**
- * Helper method to handle base class decoding housekeeping.
- *
- * @param attr the new Attribute object being created
- * @return the attr parameter
- */
- virtual Attribute* _decode(Attribute* attr) const;
-
- /**
- * Helper method that returns a range of objects the decoder should operate on,
- * based on the language settings of the decoder and the client request.
- *
- * @param request the client request, if any
- * @param objects the objects to examine
- * @return a pair of iterators representing the range of objects to examine
- */
- virtual std::pair<std::vector<xmltooling::XMLObject*>::const_iterator,std::vector<xmltooling::XMLObject*>::const_iterator> valueRange(
- const xmltooling::GenericRequest* request, const std::vector<xmltooling::XMLObject*>& objects
- ) const;
-
- public:
- virtual ~AttributeDecoder();
-
- /**
- * Decodes an XMLObject into a resolved Attribute.
- *
- * @param request request triggering the decode, if any
- * @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 nullptr
- */
- virtual Attribute* decode(
- const xmltooling::GenericRequest* request,
- const std::vector<std::string>& ids,
- const xmltooling::XMLObject* xmlObject,
- const char* assertingParty=nullptr,
- const char* relyingParty=nullptr
- ) const=0;
- };
-
-
- /** Decodes into a SimpleAttribute. */
- extern SHIBSP_API xmltooling::QName StringAttributeDecoderType;
-
- /** Decodes scoped and NameID attributes into a ScopedAttribute. */
- extern SHIBSP_API xmltooling::QName ScopedAttributeDecoderType;
-
- /** Decodes NameID information into a NameIDAttribute. */
- extern SHIBSP_API xmltooling::QName NameIDAttributeDecoderType;
-
- /** Decodes scoped attributes into a NameIDAttribute. */
- extern SHIBSP_API xmltooling::QName NameIDFromScopedAttributeDecoderType;
-
- /** Decodes KeyInfo information into a SimpleAttribute. */
- extern SHIBSP_API xmltooling::QName KeyInfoAttributeDecoderType;
-
- /** Decodes arbitrary DOM information into an ExtensibleAttribute. */
- extern SHIBSP_API xmltooling::QName DOMAttributeDecoderType;
-
- /** Decodes arbitrary XML into an XMLAttribute. */
- extern SHIBSP_API xmltooling::QName XMLAttributeDecoderType;
-
- /** Decodes base64-encoded data into a SimpleAttribute. */
- extern SHIBSP_API xmltooling::QName Base64AttributeDecoderType;
-
- /** Registers built-in AttributeDecoders into the runtime. */
- void registerAttributeDecoders();
-};
-
-#endif /* __shibsp_attrdecoder_h__ */
diff --git a/shibsp/attribute/Base64AttributeDecoder.cpp b/shibsp/attribute/Base64AttributeDecoder.cpp
deleted file mode 100644
index fb22b242..00000000
--- a/shibsp/attribute/Base64AttributeDecoder.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * Base64AttributeDecoder.cpp
- *
- * Decodes SAML containing base64-encoded values into SimpleAttributes.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/SimpleAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-
-#include <xercesc/util/Base64.hpp>
-
-using namespace shibsp;
-using namespace opensaml::saml1;
-using namespace opensaml::saml2;
-using namespace xmltooling::logging;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- class SHIBSP_DLLLOCAL Base64AttributeDecoder : virtual public AttributeDecoder
- {
- public:
- Base64AttributeDecoder(const DOMElement* e) : AttributeDecoder(e) {
- SPConfig::getConfig().deprecation().warn("Base64AttributeDecoder");
- }
- ~Base64AttributeDecoder() {}
-
- shibsp::Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL Base64AttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new Base64AttributeDecoder(e);
- }
-};
-
-shibsp::Attribute* Base64AttributeDecoder::decode(
- const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- auto_ptr<SimpleAttribute> simple(new SimpleAttribute(ids));
- vector<string>& dest = simple->getValues();
- pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
-
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.Base64");
-
- 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) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- log.debug(
- "decoding SimpleAttribute (%s) from SAML 2 Attribute (%s) with %lu base64-encoded value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- log.debug(
- "decoding SimpleAttribute (%s) from SAML 1 Attribute (%s) with %lu base64-encoded value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- log.warn("XMLObject type not recognized by Base64AttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- for (; valrange.first != valrange.second; ++valrange.first) {
- if (!(*valrange.first)->hasChildren()) {
- auto_ptr_char val((*valrange.first)->getTextContent());
- if (val.get() && *val.get()) {
- XMLSize_t x;
- XMLByte* decoded=Base64::decode(reinterpret_cast<const XMLByte*>(val.get()),&x);
- if (decoded) {
- dest.push_back(reinterpret_cast<char*>(decoded));
- XMLString::release((char**)&decoded);
- }
- else {
- log.warn("skipping AttributeValue, unable to base64-decode");
- }
- }
- else
- log.warn("skipping empty AttributeValue");
- }
- else {
- log.warn("skipping complex AttributeValue");
- }
- }
-
- return dest.empty() ? nullptr : _decode(simple.release());
- }
-
- const NameID* saml2name = dynamic_cast<const NameID*>(xmlObject);
- if (saml2name) {
- if (log.isDebugEnabled()) {
- 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");
- }
- auto_ptr_char val(saml2name->getName());
- if (val.get() && *val.get()) {
- XMLSize_t x;
- XMLByte* decoded=Base64::decode(reinterpret_cast<const XMLByte*>(val.get()),&x);
- if (decoded) {
- dest.push_back(reinterpret_cast<char*>(decoded));
- XMLString::release((char**)&decoded);
- }
- else {
- log.warn("ignoring NameID, unable to base64-decode");
- }
- }
- else
- log.warn("ignoring empty NameID");
- }
- else {
- const NameIdentifier* saml1name = dynamic_cast<const NameIdentifier*>(xmlObject);
- if (saml1name) {
- if (log.isDebugEnabled()) {
- auto_ptr_char f(saml1name->getFormat());
- log.debug(
- "decoding SimpleAttribute (%s) from SAML 1 NameIdentifier with Format (%s)",
- ids.front().c_str(), f.get() ? f.get() : "unspecified"
- );
- }
- auto_ptr_char val(saml1name->getName());
- if (val.get() && *val.get()) {
- XMLSize_t x;
- XMLByte* decoded=Base64::decode(reinterpret_cast<const XMLByte*>(val.get()),&x);
- if (decoded) {
- dest.push_back(reinterpret_cast<char*>(decoded));
- XMLString::release((char**)&decoded);
- }
- else {
- log.warn("ignoring NameIdentifier, unable to base64-decode");
- }
- }
- else
- log.warn("ignoring empty NameIdentifier");
- }
- else {
- log.warn("XMLObject type not recognized by Base64AttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- return dest.empty() ? nullptr : _decode(simple.release());
-}
diff --git a/shibsp/attribute/DOMAttributeDecoder.cpp b/shibsp/attribute/DOMAttributeDecoder.cpp
deleted file mode 100644
index 6d815c3c..00000000
--- a/shibsp/attribute/DOMAttributeDecoder.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * DOMAttributeDecoder.cpp
- *
- * Decodes a DOM into an ExtensibleAttribute.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/ExtensibleAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-#include <xmltooling/util/XMLHelper.h>
-
-using namespace shibsp;
-using namespace opensaml;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- class SHIBSP_DLLLOCAL DOMAttributeDecoder : virtual public AttributeDecoder
- {
- public:
- DOMAttributeDecoder(const DOMElement* e);
- ~DOMAttributeDecoder() {}
-
- Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
-
- private:
- DDF convert(DOMElement* e, bool nameit=true) const;
- string m_formatter;
- map<pair<xstring,xstring>,string> m_tagMap;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL DOMAttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new DOMAttributeDecoder(e);
- }
-
- static const XMLCh Mapping[] = UNICODE_LITERAL_7(M,a,p,p,i,n,g);
- static const XMLCh _from[] = UNICODE_LITERAL_4(f,r,o,m);
- static const XMLCh _to[] = UNICODE_LITERAL_2(t,o);
- static const XMLCh formatter[] =UNICODE_LITERAL_9(f,o,r,m,a,t,t,e,r);
-};
-
-DOMAttributeDecoder::DOMAttributeDecoder(const DOMElement* e)
- : AttributeDecoder(e), m_formatter(XMLHelper::getAttrString(e, nullptr, formatter))
-{
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.DOM");
-
- SPConfig::getConfig().deprecation().warn("DOMAttributeDecoder");
-
- e = XMLHelper::getFirstChildElement(e, Mapping);
- while (e) {
- if (e->hasAttributeNS(nullptr, _from) && e->hasAttributeNS(nullptr, _to)) {
- auto_ptr<xmltooling::QName> f(XMLHelper::getNodeValueAsQName(e->getAttributeNodeNS(nullptr, _from)));
- auto_ptr_char t(e->getAttributeNS(nullptr, _to));
- if (f.get() && t.get() && *t.get()) {
- if (log.isDebugEnabled())
- log.debug("mapping (%s) to (%s)", f->toString().c_str(), t.get());
- m_tagMap.insert(
- pair< const pair<xstring,xstring>,string>(
- pair<xstring,xstring>(f->getLocalPart(), f->hasNamespaceURI() ? f->getNamespaceURI() : &chNull),
- t.get()
- )
- );
- }
- }
- e = XMLHelper::getNextSiblingElement(e, Mapping);
- }
-}
-
-Attribute* DOMAttributeDecoder::decode(
- const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.DOM");
-
- if (!xmlObject)
- return nullptr;
-
- auto_ptr<ExtensibleAttribute> attr(new ExtensibleAttribute(ids, m_formatter.c_str()));
- DDF dest = attr->getValues();
- vector<XMLObject*> genericObjectWrapper; // used to support stand-alone object decoding
- pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
-
- const saml2::Attribute* saml2attr = dynamic_cast<const saml2::Attribute*>(xmlObject);
- if (saml2attr) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- log.debug(
- "decoding ExtensibleAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- const saml1::Attribute* saml1attr = dynamic_cast<const saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- log.debug(
- "decoding ExtensibleAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- log.debug("decoding arbitrary XMLObject type (%s)", xmlObject->getElementQName().toString().c_str());
- genericObjectWrapper.push_back(const_cast<XMLObject*>(xmlObject));
- valrange.first = genericObjectWrapper.begin();
- valrange.second = genericObjectWrapper.end();
- }
- }
-
- for (; valrange.first != valrange.second; ++valrange.first) {
- DOMElement* e = (*valrange.first)->getDOM();
- if (e) {
- DDF converted = convert(e, false);
- if (!converted.isnull())
- dest.add(converted);
- }
- else
- log.warn("skipping XMLObject without a backing DOM");
- }
-
- return dest.integer() ? _decode(attr.release()) : nullptr;
-}
-
-DDF DOMAttributeDecoder::convert(DOMElement* e, bool nameit) const
-{
- const XMLCh* nsURI;
- const XMLCh* local;
- map<pair<xstring,xstring>,string>::const_iterator mapping;
- DDF obj = DDF(nullptr).structure();
-
- if (nameit) {
- // Name this structure.
- nsURI = e->getNamespaceURI();
- local = e->getLocalName();
- mapping = m_tagMap.find(pair<xstring,xstring>(local,nsURI));
- if (mapping == m_tagMap.end()) {
- auto_ptr_char temp(local);
- obj.name(temp.get());
- }
- else {
- obj.name(mapping->second.c_str());
- }
- }
-
- // Process non-xmlns attributes.
- DOMNamedNodeMap* attrs = e->getAttributes();
- for (XMLSize_t a = attrs->getLength(); a > 0; --a) {
- DOMNode* attr = attrs->item(a-1);
- nsURI = attr->getNamespaceURI();
- if (XMLString::equals(nsURI, xmlconstants::XMLNS_NS))
- continue;
- local = attr->getLocalName();
- mapping = m_tagMap.find(pair<xstring,xstring>(local, nsURI ? nsURI : &chNull));
- if (mapping == m_tagMap.end()) {
- auto_ptr_char temp(local);
- obj.addmember(temp.get()).string(toUTF8(attr->getNodeValue(), true), false);
- }
- else {
- obj.addmember(mapping->second.c_str()).string(toUTF8(attr->getNodeValue(), true), false);
- }
- }
-
- DOMElement* child = XMLHelper::getFirstChildElement(e);
- if (!child && e->hasChildNodes()) {
- // Attach a _text member if text data is present.
- XMLCh* value = XMLHelper::getWholeTextContent(e);
- ArrayJanitor<XMLCh> jan(value);
- if (value && *value)
- obj.addmember("_string").string(toUTF8(value, true), false);
- }
- else {
- while (child) {
- // Convert the child element.
- DDF converted = convert(child);
- if (!converted.isnull()) {
- // Now identify it and attach it.
- if (obj[converted.name()].isnull()) {
- // We're a new child, so just attach as a structure member.
- obj.add(converted);
- }
- else if (obj[converted.name()].islist()) {
- // We're already a repeating child, so add it to the list.
- obj[converted.name()].add(converted);
- }
- else if (obj[converted.name()].isstruct()) {
- // This is the complex case where we see a child for the second
- // time and have to convert a structure member into a named list.
- DDF newlist = DDF(converted.name()).list();
- newlist.add(obj[converted.name()].remove());
- newlist.add(converted);
- obj.add(newlist);
- }
- }
- child = XMLHelper::getNextSiblingElement(child);
- }
- }
-
- // If we're empty, just delete.
- if (obj.integer() == 0)
- obj.destroy();
- return obj;
-}
diff --git a/shibsp/attribute/KeyInfoAttributeDecoder.cpp b/shibsp/attribute/KeyInfoAttributeDecoder.cpp
deleted file mode 100644
index ec318063..00000000
--- a/shibsp/attribute/KeyInfoAttributeDecoder.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * KeyInfoAttributeDecoder.cpp
- *
- * Decodes KeyInfo information into a SimpleAttribute.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/SimpleAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/security/Credential.h>
-#include <xmltooling/security/KeyInfoResolver.h>
-#include <xmltooling/security/SecurityHelper.h>
-#include <xmltooling/signature/KeyInfo.h>
-
-using namespace shibsp;
-using namespace opensaml;
-using namespace xmlsignature;
-using namespace xmltooling;
-using namespace boost;
-using namespace std;
-
-namespace shibsp {
- class SHIBSP_DLLLOCAL KeyInfoAttributeDecoder : virtual public AttributeDecoder
- {
- public:
- KeyInfoAttributeDecoder(const DOMElement* e, bool deprecationSupport=true);
- ~KeyInfoAttributeDecoder() {}
-
- Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
-
- private:
- void extract(const KeyInfo* k, vector<string>& dest) const {
- scoped_ptr<Credential> cred(getKeyInfoResolver()->resolve(k, Credential::RESOLVE_KEYS));
- if (cred) {
- dest.push_back(string());
- dest.back() = SecurityHelper::getDEREncoding(*cred, m_hash ? m_keyInfoHashAlg.c_str() : nullptr);
- if (dest.back().empty())
- dest.pop_back();
- }
- }
-
- const KeyInfoResolver* getKeyInfoResolver() const {
- return m_keyInfoResolver ? m_keyInfoResolver.get() : XMLToolingConfig::getConfig().getKeyInfoResolver();
- }
-
- bool m_hash;
- string m_keyInfoHashAlg;
- scoped_ptr<KeyInfoResolver> m_keyInfoResolver;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL KeyInfoAttributeDecoderFactory(const DOMElement* const & e, bool deprecationSupport)
- {
- return new KeyInfoAttributeDecoder(e, deprecationSupport);
- }
-
- static const XMLCh _KeyInfoResolver[] = UNICODE_LITERAL_15(K,e,y,I,n,f,o,R,e,s,o,l,v,e,r);
- static const XMLCh _hash[] = UNICODE_LITERAL_4(h,a,s,h);
- static const XMLCh keyInfoHashAlg[] = UNICODE_LITERAL_14(k,e,y,I,n,f,o,H,a,s,h,A,l,g);
- static const XMLCh _type[] = UNICODE_LITERAL_4(t,y,p,e);
-};
-
-KeyInfoAttributeDecoder::KeyInfoAttributeDecoder(const DOMElement* e, bool deprecationSupport)
- : AttributeDecoder(e),
- m_hash(XMLHelper::getAttrBool(e, false, _hash)),
- m_keyInfoHashAlg(XMLHelper::getAttrString(e, "SHA1", keyInfoHashAlg)) {
-
- SPConfig::getConfig().deprecation().warn("KeyInfoAttributeDecoder");
-
- e = XMLHelper::getFirstChildElement(e, _KeyInfoResolver);
- if (e) {
- string t(XMLHelper::getAttrString(e, nullptr, _type));
- if (t.empty())
- throw UnknownExtensionException("<KeyInfoResolver> element found with no type attribute");
- m_keyInfoResolver.reset(XMLToolingConfig::getConfig().KeyInfoResolverManager.newPlugin(t.c_str(), e, deprecationSupport));
- }
-}
-
-Attribute* KeyInfoAttributeDecoder::decode(
- const GenericRequest*, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.KeyInfo");
-
- if (!xmlObject || !XMLString::equals(saml1::Attribute::LOCAL_NAME, xmlObject->getElementQName().getLocalPart())) {
- log.warn("XMLObject type not recognized by KeyInfoAttributeDecoder, no values returned");
- return nullptr;
- }
-
- auto_ptr<SimpleAttribute> attr(new SimpleAttribute(ids));
- vector<string>& dest = attr->getValues();
- vector<XMLObject*>::const_iterator v,stop;
-
- const saml2::Attribute* saml2attr = dynamic_cast<const saml2::Attribute*>(xmlObject);
- if (saml2attr) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- v = values.begin();
- stop = values.end();
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- log.debug(
- "decoding KeyInfo information (%s) from SAML 2 Attribute (%s) with %lu value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- const saml1::Attribute* saml1attr = dynamic_cast<const saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- v = values.begin();
- stop = values.end();
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- log.debug(
- "decoding KeyInfo information (%s) from SAML 1 Attribute (%s) with %lu value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- log.warn("XMLObject type not recognized by KeyInfoAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- for (; v != stop; ++v) {
- const KeyInfo* k = dynamic_cast<const KeyInfo*>(*v);
- if (k)
- extract(k, dest);
- else if ((*v)->hasChildren()) {
- const list<XMLObject*>& children = (*v)->getOrderedChildren();
- for (list<XMLObject*>::const_iterator vv = children.begin(); vv != children.end(); ++vv) {
- if (k=dynamic_cast<const KeyInfo*>(*vv))
- extract(k, dest);
- else
- log.warn("skipping AttributeValue without a recognizable KeyInfo");
- }
- }
- }
-
- return dest.empty() ? nullptr : _decode(attr.release());
-}
diff --git a/shibsp/attribute/NameIDAttributeDecoder.cpp b/shibsp/attribute/NameIDAttributeDecoder.cpp
deleted file mode 100644
index a6fa742b..00000000
--- a/shibsp/attribute/NameIDAttributeDecoder.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * NameIDAttributeDecoder.cpp
- *
- * Decodes SAML into NameIDAttributes.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/NameIDAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-
-using namespace shibsp;
-using namespace opensaml::saml1;
-using namespace opensaml::saml2;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- static const XMLCh formatter[] = UNICODE_LITERAL_9(f,o,r,m,a,t,t,e,r);
- static const XMLCh defaultQualifiers[] = UNICODE_LITERAL_17(d,e,f,a,u,l,t,Q,u,a,l,i,f,i,e,r,s);
-
- class SHIBSP_DLLLOCAL NameIDAttributeDecoder : virtual public AttributeDecoder
- {
- public:
- NameIDAttributeDecoder(const DOMElement* e)
- : AttributeDecoder(e),
- m_formatter(XMLHelper::getAttrString(e, nullptr, formatter)),
- m_defaultQualifiers(XMLHelper::getAttrBool(e, false, defaultQualifiers)) {
- }
- ~NameIDAttributeDecoder() {}
-
- shibsp::Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
-
- private:
- void extract(
- const NameIDType* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty
- ) const;
- void extract(
- const NameIdentifier* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty
- ) const;
- string m_formatter;
- bool m_defaultQualifiers;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL NameIDAttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new NameIDAttributeDecoder(e);
- }
-};
-
-shibsp::Attribute* NameIDAttributeDecoder::decode(
- const GenericRequest*, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- auto_ptr<NameIDAttribute> nameid(
- new NameIDAttribute(ids, (!m_formatter.empty()) ? m_formatter.c_str() : DEFAULT_NAMEID_FORMATTER, m_hashAlg.c_str())
- );
- vector<NameIDAttribute::Value>& dest = nameid->getValues();
- vector<XMLObject*>::const_iterator v,stop;
-
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.NameID");
-
- 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) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- v = values.begin();
- 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)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- 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();
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- 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 {
- log.warn("XMLObject type not recognized by NameIDAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- for (; v != stop; ++v) {
- const NameIDType* n2 = dynamic_cast<const NameIDType*>(*v);
- if (n2) {
- log.debug("decoding AttributeValue element of saml2:NameIDType type");
- extract(n2, dest, assertingParty, relyingParty);
- }
- else {
- const NameIdentifier* n1=dynamic_cast<const NameIdentifier*>(*v);
- if (n1) {
- log.debug("decoding AttributeValue element of saml1:NameIdentifier type");
- extract(n1, dest, assertingParty, relyingParty);
- }
- else if ((*v)->hasChildren()) {
- const list<XMLObject*>& values = (*v)->getOrderedChildren();
- for (list<XMLObject*>::const_iterator vv = values.begin(); vv!=values.end(); ++vv) {
- if (n2=dynamic_cast<const NameIDType*>(*vv)) {
- log.debug("decoding saml2:NameID child element of AttributeValue");
- extract(n2, dest, assertingParty, relyingParty);
- }
- else if (n1=dynamic_cast<const NameIdentifier*>(*vv)) {
- log.debug("decoding saml1:NameIdentifier child element of AttributeValue");
- extract(n1, dest, assertingParty, relyingParty);
- }
- else {
- log.warn("skipping AttributeValue child element not recognizable as NameID/NameIdentifier");
- }
- }
- }
- else {
- log.warn("AttributeValue was not of a supported type and contains no child elements");
- }
- }
- }
-
- return dest.empty() ? nullptr : nameid.release();
- }
-
- const NameIDType* saml2name = dynamic_cast<const NameIDType*>(xmlObject);
- if (saml2name) {
- if (log.isDebugEnabled()) {
- auto_ptr_char f(saml2name->getFormat());
- log.debug("decoding NameIDAttribute (%s) from SAML 2 NameID with Format (%s)", ids.front().c_str(), f.get() ? f.get() : "unspecified");
- }
- extract(saml2name, dest, assertingParty, relyingParty);
- }
- else {
- const NameIdentifier* saml1name = dynamic_cast<const NameIdentifier*>(xmlObject);
- if (saml1name) {
- if (log.isDebugEnabled()) {
- auto_ptr_char f(saml1name->getFormat());
- log.debug(
- "decoding NameIDAttribute (%s) from SAML 1 NameIdentifier with Format (%s)",
- ids.front().c_str(), f.get() ? f.get() : "unspecified"
- );
- }
- extract(saml1name, dest, assertingParty, relyingParty);
- }
- else {
- log.warn("XMLObject type not recognized by NameIDAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- return dest.empty() ? nullptr : nameid.release();
-}
-
-void NameIDAttributeDecoder::extract(
- const NameIDType* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty
- ) const
-{
- auto_arrayptr<char> name(toUTF8(n->getName()));
- if (name.get() && *name.get()) {
- dest.push_back(NameIDAttribute::Value());
- NameIDAttribute::Value& val = dest.back();
- val.m_Name = name.get();
-
- auto_arrayptr<char> format(toUTF8(n->getFormat()));
- if (format.get())
- val.m_Format = format.get();
-
- auto_arrayptr<char> nameQualifier(toUTF8(n->getNameQualifier()));
- if (nameQualifier.get() && *nameQualifier.get())
- val.m_NameQualifier = nameQualifier.get();
- else if (m_defaultQualifiers && assertingParty)
- val.m_NameQualifier = assertingParty;
-
- auto_arrayptr<char> spNameQualifier(toUTF8(n->getSPNameQualifier()));
- if (spNameQualifier.get() && *spNameQualifier.get())
- val.m_SPNameQualifier = spNameQualifier.get();
- else if (m_defaultQualifiers && relyingParty)
- val.m_SPNameQualifier = relyingParty;
-
- auto_arrayptr<char> spProvidedID(toUTF8(n->getSPProvidedID()));
- if (spProvidedID.get())
- val.m_SPProvidedID = spProvidedID.get();
- }
-}
-
-void NameIDAttributeDecoder::extract(
- const NameIdentifier* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty
- ) const
-{
- auto_arrayptr<char> name(toUTF8(n->getName()));
- if (name.get() && *name.get()) {
- dest.push_back(NameIDAttribute::Value());
- NameIDAttribute::Value& val = dest.back();
- val.m_Name = name.get();
-
- auto_arrayptr<char> format(toUTF8(n->getFormat()));
- if (format.get())
- val.m_Format = format.get();
-
- auto_arrayptr<char> nameQualifier(toUTF8(n->getNameQualifier()));
- if (nameQualifier.get() && *nameQualifier.get())
- val.m_NameQualifier = nameQualifier.get();
- else if (m_defaultQualifiers && assertingParty)
- val.m_NameQualifier = assertingParty;
-
- if (m_defaultQualifiers && relyingParty)
- val.m_SPNameQualifier = relyingParty;
- }
-}
diff --git a/shibsp/attribute/NameIDFromScopedAttributeDecoder.cpp b/shibsp/attribute/NameIDFromScopedAttributeDecoder.cpp
deleted file mode 100644
index c5d5d36f..00000000
--- a/shibsp/attribute/NameIDFromScopedAttributeDecoder.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * NameIDFromNameIDFromScopedAttributeDecoder.cpp
- *
- * Decodes SAML "scoped" attributes into NameIDAttributes.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/NameIDAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-
-using namespace shibsp;
-using namespace opensaml::saml1;
-using namespace opensaml::saml2;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- static const XMLCh defaultQualifiers[] =UNICODE_LITERAL_17(d,e,f,a,u,l,t,Q,u,a,l,i,f,i,e,r,s);
- static const XMLCh format[] = UNICODE_LITERAL_6(f,o,r,m,a,t);
- static const XMLCh formatter[] = UNICODE_LITERAL_9(f,o,r,m,a,t,t,e,r);
- 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);
-
- class SHIBSP_DLLLOCAL NameIDFromScopedAttributeDecoder : virtual public AttributeDecoder
- {
- public:
- NameIDFromScopedAttributeDecoder(const DOMElement* e)
- : AttributeDecoder(e),
- m_delimeter('@'),
- m_format(XMLHelper::getAttrString(e, nullptr, format)),
- m_formatter(XMLHelper::getAttrString(e, nullptr, formatter)),
- m_defaultQualifiers(XMLHelper::getAttrBool(e, false, defaultQualifiers)) {
- if (e && e->hasAttributeNS(nullptr,scopeDelimeter)) {
- auto_ptr_char d(e->getAttributeNS(nullptr,scopeDelimeter));
- m_delimeter = *(d.get());
- }
- }
- ~NameIDFromScopedAttributeDecoder() {}
-
- shibsp::Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
-
- private:
- char m_delimeter;
- string m_format,m_formatter;
- bool m_defaultQualifiers;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL NameIDFromScopedAttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new NameIDFromScopedAttributeDecoder(e);
- }
-};
-
-shibsp::Attribute* NameIDFromScopedAttributeDecoder::decode(
- const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
-
- char* val;
- char* scope;
- const XMLCh* xmlscope;
- xmltooling::QName scopeqname(nullptr,Scope);
- auto_ptr<NameIDAttribute> nameid(
- new NameIDAttribute(ids, (!m_formatter.empty()) ? m_formatter.c_str() : DEFAULT_NAMEID_FORMATTER, m_hashAlg.c_str())
- );
- vector<NameIDAttribute::Value>& dest = nameid->getValues();
- pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
-
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.NameIDFromScoped");
-
- 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) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- 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 {
- const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- 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 {
- log.warn("XMLObject type not recognized by NameIDFromScopedAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- for (; valrange.first != valrange.second; ++valrange.first) {
- if (!(*valrange.first)->hasChildren()) {
- val = toUTF8((*valrange.first)->getTextContent());
- if (val && *val) {
- dest.push_back(NameIDAttribute::Value());
- NameIDAttribute::Value& destval = dest.back();
- const AttributeExtensibleXMLObject* aexo=dynamic_cast<const AttributeExtensibleXMLObject*>(*valrange.first);
- xmlscope = aexo ? aexo->getAttribute(scopeqname) : nullptr;
- if (!xmlscope || !*xmlscope) {
- // Terminate the value at the scope delimiter.
- if (scope = strchr(val, m_delimeter))
- *scope++ = 0;
- }
- destval.m_Name = val;
- destval.m_Format = m_format;
- if (m_defaultQualifiers && assertingParty)
- destval.m_NameQualifier = assertingParty;
- if (m_defaultQualifiers && relyingParty)
- destval.m_SPNameQualifier = relyingParty;
- }
- else {
- log.warn("skipping empty AttributeValue");
- }
- delete[] val;
- }
- else {
- log.warn("skipping complex AttributeValue");
- }
- }
-
- return dest.empty() ? nullptr : nameid.release();
- }
-
- log.warn("XMLObject type not recognized by NameIDFromScopedAttributeDecoder, no values returned");
- return nullptr;
-}
diff --git a/shibsp/attribute/ScopedAttributeDecoder.cpp b/shibsp/attribute/ScopedAttributeDecoder.cpp
deleted file mode 100644
index 2bc3cf9e..00000000
--- a/shibsp/attribute/ScopedAttributeDecoder.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * ScopedAttributeDecoder.cpp
- *
- * Decodes SAML into ScopedAttributes.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/ScopedAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-
-using namespace shibsp;
-using namespace opensaml::saml1;
-using namespace opensaml::saml2;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- static const XMLCh Scope[] = UNICODE_LITERAL_5(S,c,o,p,e);
- 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_delimiter('@') {
- if (e && e->hasAttributeNS(nullptr,scopeDelimiter)) {
- auto_ptr_char d(e->getAttributeNS(nullptr,scopeDelimiter));
- m_delimiter = *(d.get());
- }
- }
- ~ScopedAttributeDecoder() {}
-
- shibsp::Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
-
- private:
- char m_delimiter;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL ScopedAttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new ScopedAttributeDecoder(e);
- }
-};
-
-shibsp::Attribute* ScopedAttributeDecoder::decode(
- const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- char* val;
- char* scope;
- const XMLCh* xmlscope;
- xmltooling::QName scopeqname(nullptr,Scope);
- auto_ptr<ScopedAttribute> scoped(new ScopedAttribute(ids, m_delimiter));
- vector< pair<string,string> >& dest = scoped->getValues();
- pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
-
- 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) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- 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 {
- const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- 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 {
- log.warn("XMLObject type not recognized by ScopedAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- for (; valrange.first != valrange.second; ++valrange.first) {
- if (!(*valrange.first)->hasChildren()) {
- val = toUTF8((*valrange.first)->getTextContent());
- if (val && *val) {
- const AttributeExtensibleXMLObject* aexo=dynamic_cast<const AttributeExtensibleXMLObject*>(*valrange.first);
- xmlscope = aexo ? aexo->getAttribute(scopeqname) : nullptr;
- if (xmlscope && *xmlscope) {
- auto_arrayptr<char> noninlinescope(toUTF8(xmlscope));
- dest.push_back(pair<string,string>(val,noninlinescope.get()));
- }
- else {
- scope = strchr(val, m_delimiter);
- if (scope) {
- *scope++ = 0;
- if (*scope)
- dest.push_back(pair<string,string>(val,scope));
- else
- log.warn("ignoring unscoped AttributeValue");
- }
- else {
- log.warn("ignoring unscoped AttributeValue");
- }
- }
- }
- else {
- log.warn("skipping empty AttributeValue");
- }
- delete[] val;
- }
- else {
- log.warn("skipping complex AttributeValue");
- }
- }
-
- return dest.empty() ? nullptr : _decode(scoped.release());
- }
-
- const NameID* saml2name = dynamic_cast<const NameID*>(xmlObject);
- if (saml2name) {
- if (log.isDebugEnabled()) {
- auto_ptr_char f(saml2name->getFormat());
- 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());
- }
- else {
- const NameIdentifier* saml1name = dynamic_cast<const NameIdentifier*>(xmlObject);
- if (saml1name) {
- if (log.isDebugEnabled()) {
- auto_ptr_char f(saml1name->getFormat());
- 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());
- }
- else {
- log.warn("XMLObject type not recognized by ScopedAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- if (val && *val && *val != m_delimiter) {
- scope = strchr(val, m_delimiter);
- if (scope) {
- *scope++ = 0;
- if (*scope)
- dest.push_back(pair<string,string>(val,scope));
- else
- log.warn("ignoring NameID with no scope");
- }
- else {
- log.warn("ignoring NameID with no scope delimiter (%c)", m_delimiter);
- }
- }
- else {
- log.warn("ignoring empty NameID");
- }
- delete[] val;
- return dest.empty() ? nullptr : _decode(scoped.release());
-}
diff --git a/shibsp/attribute/StringAttributeDecoder.cpp b/shibsp/attribute/StringAttributeDecoder.cpp
deleted file mode 100644
index 4f5858a1..00000000
--- a/shibsp/attribute/StringAttributeDecoder.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * StringAttributeDecoder.cpp
- *
- * Decodes SAML into SimpleAttributes.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/SimpleAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-
-using namespace shibsp;
-using namespace opensaml::saml1;
-using namespace opensaml::saml2;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- class SHIBSP_DLLLOCAL StringAttributeDecoder : virtual public AttributeDecoder
- {
- public:
- StringAttributeDecoder(const DOMElement* e) : AttributeDecoder(e) {}
- ~StringAttributeDecoder() {}
-
- shibsp::Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL StringAttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new StringAttributeDecoder(e);
- }
-};
-
-shibsp::Attribute* StringAttributeDecoder::decode(
- const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- auto_ptr<SimpleAttribute> simple(new SimpleAttribute(ids));
- vector<string>& dest = simple->getValues();
- pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
-
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.String");
-
- 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) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- 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 {
- const opensaml::saml1::Attribute* saml1attr = dynamic_cast<const opensaml::saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- 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 {
- log.warn("XMLObject type not recognized by StringAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- 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");
- }
- else {
- log.warn("skipping complex AttributeValue");
- }
- }
-
- return dest.empty() ? nullptr : _decode(simple.release());
- }
-
- const NameID* saml2name = dynamic_cast<const NameID*>(xmlObject);
- if (saml2name) {
- if (log.isDebugEnabled()) {
- 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");
- }
- 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);
- if (saml1name) {
- if (log.isDebugEnabled()) {
- auto_ptr_char f(saml1name->getFormat());
- log.debug(
- "decoding SimpleAttribute (%s) from SAML 1 NameIdentifier with Format (%s)",
- ids.front().c_str(), f.get() ? f.get() : "unspecified"
- );
- }
- 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");
- return nullptr;
- }
- }
-
- return dest.empty() ? nullptr : _decode(simple.release());
-}
diff --git a/shibsp/attribute/XMLAttributeDecoder.cpp b/shibsp/attribute/XMLAttributeDecoder.cpp
deleted file mode 100644
index 932c574d..00000000
--- a/shibsp/attribute/XMLAttributeDecoder.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * XMLAttributeDecoder.cpp
- *
- * Decodes arbitrary XML into an XMLAttribute.
- */
-
-#include "internal.h"
-#include "attribute/AttributeDecoder.h"
-#include "attribute/XMLAttribute.h"
-
-#include <saml/saml1/core/Assertions.h>
-#include <saml/saml2/core/Assertions.h>
-#include <xmltooling/util/XMLHelper.h>
-
-using namespace shibsp;
-using namespace opensaml;
-using namespace xmltooling;
-using namespace std;
-
-namespace shibsp {
- class SHIBSP_DLLLOCAL XMLAttributeDecoder : virtual public AttributeDecoder
- {
- public:
- XMLAttributeDecoder(const DOMElement* e) : AttributeDecoder(e) {
- SPConfig::getConfig().deprecation().warn("XMLAttributeDecoder");
- }
- ~XMLAttributeDecoder() {}
-
- Attribute* decode(
- const GenericRequest*, const vector<string>&, const XMLObject*, const char* assertingParty=nullptr, const char* relyingParty=nullptr
- ) const;
-
- private:
- DDF convert(DOMElement* e, bool nameit=true) const;
- auto_ptr_char m_formatter;
- map<pair<xstring,xstring>,string> m_tagMap;
- };
-
- AttributeDecoder* SHIBSP_DLLLOCAL XMLAttributeDecoderFactory(const DOMElement* const & e, bool)
- {
- return new XMLAttributeDecoder(e);
- }
-};
-
-
-Attribute* XMLAttributeDecoder::decode(
- const GenericRequest* request, const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty, const char* relyingParty
- ) const
-{
- if (!xmlObject)
- return nullptr;
-
- Category& log = Category::getInstance(SHIBSP_LOGCAT ".AttributeDecoder.XML");
-
- auto_ptr<XMLAttribute> attr(new XMLAttribute(ids));
- vector<string>& dest = attr->getValues();
-
- // Handle any non-Attribute object directly.
- if (!xmlObject || !XMLString::equals(saml1::Attribute::LOCAL_NAME, xmlObject->getElementQName().getLocalPart())) {
- DOMElement* e = xmlObject->getDOM();
- if (e) {
- if (log.isDebugEnabled()) {
- log.debug(
- "decoding XMLAttribute (%s) from XMLObject (%s)",
- ids.front().c_str(),
- (xmlObject->getSchemaType() ? xmlObject->getSchemaType()->toString() : xmlObject->getElementQName().toString()).c_str()
- );
- }
- dest.push_back(string());
- XMLHelper::serialize(e, dest.back());
- }
- else {
- log.warn("skipping XMLObject without a backing DOM");
- }
- return dest.empty() ? nullptr : _decode(attr.release());
- }
-
- pair<vector<XMLObject*>::const_iterator,vector<XMLObject*>::const_iterator> valrange;
-
- const saml2::Attribute* saml2attr = dynamic_cast<const saml2::Attribute*>(xmlObject);
- if (saml2attr) {
- const vector<XMLObject*>& values = saml2attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml2attr->getName());
- log.debug(
- "decoding XMLAttribute (%s) from SAML 2 Attribute (%s) with %lu value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- const saml1::Attribute* saml1attr = dynamic_cast<const saml1::Attribute*>(xmlObject);
- if (saml1attr) {
- const vector<XMLObject*>& values = saml1attr->getAttributeValues();
- valrange = valueRange(request, values);
- if (log.isDebugEnabled()) {
- auto_ptr_char n(saml1attr->getAttributeName());
- log.debug(
- "decoding XMLAttribute (%s) from SAML 1 Attribute (%s) with %lu value(s)",
- ids.front().c_str(), n.get() ? n.get() : "unnamed", values.size()
- );
- }
- }
- else {
- log.warn("XMLObject type not recognized by XMLAttributeDecoder, no values returned");
- return nullptr;
- }
- }
-
- for (; valrange.first != valrange.second; ++valrange.first) {
- DOMElement* e = (*valrange.first)->getDOM();
- if (e) {
- dest.push_back(string());
- XMLHelper::serialize(e, dest.back());
- }
- else
- log.warn("skipping AttributeValue without a backing DOM");
- }
-
- return dest.empty() ? nullptr : _decode(attr.release());
-}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list