-/*
- * Copyright 2001-2010 Internet2
+/**
+ * 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.
*
- * 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
+ * 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/AbstractHandler.h"
#include "handler/SessionInitiator.h"
+#include <boost/algorithm/string.hpp>
#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/impl/AnyElement.h>
#include <xmltooling/util/URLEncoder.h>
using namespace shibsp;
using namespace opensaml;
using namespace xmltooling;
+using namespace boost;
using namespace std;
#ifndef SHIBSP_LITE
#ifndef SHIBSP_LITE
void generateMetadata(SPSSODescriptor& role, const char* handlerURL) const {
- static const XMLCh LOCAL_NAME[] = UNICODE_LITERAL_17(D,i,s,c,o,v,e,r,y,R,e,s,p,o,n,s,e);
-
// Initial guess at index to use.
pair<bool,unsigned int> ix = getUnsignedInt("index");
if (!ix.first)
if (role.getExtensions()) {
const vector<XMLObject*>& exts = const_cast<const Extensions*>(role.getExtensions())->getUnknownXMLObjects();
for (vector<XMLObject*>::const_reverse_iterator i = exts.rbegin(); i != exts.rend(); ++i) {
- if (XMLString::equals((*i)->getElementQName().getLocalPart(), LOCAL_NAME) &&
- XMLString::equals((*i)->getElementQName().getNamespaceURI(), m_discoNS.get())) {
- const AttributeExtensibleXMLObject* sub = dynamic_cast<const AttributeExtensibleXMLObject*>(*i);
- if (sub) {
- const XMLCh* val = sub->getAttribute(xmltooling::QName(nullptr,IndexedEndpointType::INDEX_ATTRIB_NAME));
- if (val) {
- int maxindex = XMLString::parseInt(val);
- if (ix.second <= maxindex)
- ix.second = maxindex + 1;
- break;
- }
+ const DiscoveryResponse* sub = dynamic_cast<DiscoveryResponse*>(*i);
+ if (sub) {
+ pair<bool,int> val = sub->getIndex();
+ if (val.first) {
+ if (ix.second <= val.second)
+ ix.second = val.second + 1;
+ break;
}
}
}
hurl += loc;
auto_ptr_XMLCh widen(hurl.c_str());
- ostringstream os;
- os << ix.second;
- auto_ptr_XMLCh widen2(os.str().c_str());
-
- ElementProxy* ep = new AnyElementImpl(m_discoNS.get(), LOCAL_NAME);
- ep->setAttribute(xmltooling::QName(nullptr,EndpointType::LOCATION_ATTRIB_NAME), widen.get());
- ep->setAttribute(xmltooling::QName(nullptr,EndpointType::BINDING_ATTRIB_NAME), m_discoNS.get());
- ep->setAttribute(xmltooling::QName(nullptr,IndexedEndpointType::INDEX_ATTRIB_NAME), widen2.get());
+ DiscoveryResponse* ep = DiscoveryResponseBuilder::buildDiscoveryResponse();
+ ep->setLocation(widen.get());
+ ep->setBinding(samlconstants::IDP_DISCOVERY_PROTOCOL_NS);
+ ep->setIndex(ix.second);
Extensions* ext = role.getExtensions();
if (!ext) {
ext = ExtensionsBuilder::buildExtensions();
const char* m_url;
const char* m_returnParam;
vector<string> m_preservedOptions;
-#ifndef SHIBSP_LITE
- auto_ptr_XMLCh m_discoNS;
-#endif
};
#if defined (_MSC_VER)
};
SAMLDSSessionInitiator::SAMLDSSessionInitiator(const DOMElement* e, const char* appId)
- : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".SessionInitiator.SAMLDS")), m_url(nullptr), m_returnParam(nullptr)
-#ifndef SHIBSP_LITE
- ,m_discoNS("urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol")
-#endif
+ : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT ".SessionInitiator.SAMLDS")), m_url(nullptr), m_returnParam(nullptr)
{
pair<bool,const char*> url = getString("URL");
if (!url.first)
pair<bool,const char*> options = getString("preservedOptions");
if (options.first) {
- int j = 0;
string opt = options.second;
- for (unsigned int i = 0; i < opt.length(); i++) {
- if (opt.at(i) == ' ') {
- m_preservedOptions.push_back(opt.substr(j, i-j));
- j = i+1;
- }
- }
- m_preservedOptions.push_back(opt.substr(j, opt.length()-j));
+ trim(opt);
+ split(m_preservedOptions, opt, is_space(), algorithm::token_compress_on);
}
else {
m_preservedOptions.push_back("isPassive");
string target;
pair<bool,const char*> prop;
- bool isPassive=false;
- const Application& app=request.getApplication();
+ bool isPassive = false;
+ const Application& app = request.getApplication();
pair<bool,const char*> discoveryURL = pair<bool,const char*>(true, m_url);
if (isHandler) {
req = req + "&returnIDParam=" + m_returnParam;
if (isPassive)
req += "&isPassive=true";
+ prop = getString("discoveryPolicy");
+ if (prop.first)
+ req += "&policy=" + urlenc->encode(prop.second);
return make_pair(true, request.sendRedirect(req.c_str()));
}