-/*
- * Copyright 2001-2007 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
+/**
+ * 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
+ * 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.
+ * 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.
*/
/**
#include "handler/SessionInitiator.h"
#include "util/SPConstants.h"
+#include <boost/bind.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xmltooling/util/XMLHelper.h>
using namespace shibsp;
using namespace xmltooling;
+using namespace boost;
using namespace std;
namespace shibsp {
{
public:
ChainingSessionInitiator(const DOMElement* e, const char* appId);
- virtual ~ChainingSessionInitiator() {
- for_each(m_handlers.begin(), m_handlers.end(), xmltooling::cleanup<SessionInitiator>());
- }
+ virtual ~ChainingSessionInitiator() {}
pair<bool,long> run(SPRequest& request, string& entityID, bool isHandler=true) const;
#ifndef SHIBSP_LITE
void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const {
- for (vector<SessionInitiator*>::const_iterator i = m_handlers.begin(); i!=m_handlers.end(); ++i)
- (*i)->generateMetadata(role, handlerURL);
+ doGenerateMetadata(role, handlerURL); // assumes all chains support the RequestInitiator protocol
+ for_each(m_handlers.begin(), m_handlers.end(), boost::bind(&SessionInitiator::generateMetadata, _1, boost::ref(role), handlerURL));
}
#endif
private:
- vector<SessionInitiator*> m_handlers;
+ ptr_vector<SessionInitiator> m_handlers;
};
#if defined (_MSC_VER)
};
ChainingSessionInitiator::ChainingSessionInitiator(const DOMElement* e, const char* appId)
- : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".SessionInitiator.Chaining"), &g_SINFilter)
+ : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT ".SessionInitiator.Chaining"), &g_SINFilter)
{
SPConfig& conf = SPConfig::getConfig();
// Load up the chain of handlers.
- e = e ? XMLHelper::getFirstChildElement(e, _SessionInitiator) : NULL;
+ e = e ? XMLHelper::getFirstChildElement(e, _SessionInitiator) : nullptr;
while (e) {
- auto_ptr_char type(e->getAttributeNS(NULL,_type));
- if (type.get() && *(type.get())) {
+ string t(XMLHelper::getAttrString(e, nullptr, _type));
+ if (!t.empty()) {
try {
- m_handlers.push_back(conf.SessionInitiatorManager.newPlugin(type.get(),make_pair(e, appId)));
- m_handlers.back()->setParent(this);
+ auto_ptr<SessionInitiator> np(conf.SessionInitiatorManager.newPlugin(t.c_str(), make_pair(e, appId)));
+ m_handlers.push_back(np.get());
+ np.release();
+ m_handlers.back().setParent(this);
}
- catch (exception& ex) {
+ catch (std::exception& ex) {
m_log.error("caught exception processing embedded SessionInitiator element: %s", ex.what());
}
}
e = XMLHelper::getNextSiblingElement(e, _SessionInitiator);
}
+
+ m_supportedOptions.insert("isPassive");
}
pair<bool,long> ChainingSessionInitiator::run(SPRequest& request, string& entityID, bool isHandler) const
{
+ if (!checkCompatibility(request, isHandler))
+ return make_pair(false, 0L);
+
pair<bool,long> ret;
- for (vector<SessionInitiator*>::const_iterator i = m_handlers.begin(); i!=m_handlers.end(); ++i) {
- ret = (*i)->run(request, entityID, isHandler);
+ for (ptr_vector<SessionInitiator>::const_iterator i = m_handlers.begin(); i != m_handlers.end(); ++i) {
+ ret = i->run(request, entityID, isHandler);
if (ret.first)
return ret;
}