2 * Copyright 2010 JANET(UK)
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * An embeddable component interface to Shibboleth SP attribute processing.
25 #include <shibsp/ServiceProvider.h>
26 #include <shibsp/attribute/Attribute.h>
27 #include <shibsp/remoting/ListenerService.h>
29 using namespace shibresolver;
30 using namespace shibsp;
32 using namespace opensaml;
34 using namespace xmltooling;
37 namespace shibresolver {
38 class SHIBRESOLVER_DLLLOCAL RemotedResolver : public Remoted {
43 void receive(DDF& in, ostream& out);
46 static RemotedResolver g_Remoted;
49 ShibbolethResolver* ShibbolethResolver::create()
51 return new ShibbolethResolver();
54 ShibbolethResolver::ShibbolethResolver()
60 ShibbolethResolver::~ShibbolethResolver()
62 for_each(m_resolvedAttributes.begin(), m_resolvedAttributes.end(), xmltooling::cleanup<Attribute>());
69 void ShibbolethResolver::setServiceURI(const char* uri)
76 void ShibbolethResolver::setApplicationID(const char* appID)
83 void ShibbolethResolver::setIssuer(const char* issuer)
90 void ShibbolethResolver::addToken(
92 const XMLObject* token
94 const saml2::Assertion* token
99 m_tokens.push_back(token);
102 void ShibbolethResolver::addAttribute(Attribute* attr)
105 m_inputAttributes.push_back(attr);
108 vector<Attribute*>& ShibbolethResolver::getResolvedAttributes()
110 return m_resolvedAttributes;
113 RequestMapper::Settings ShibbolethResolver::getSettings() const
118 void ShibbolethResolver::resolve()
122 void RemotedResolver::receive(DDF& in, ostream& out)
126 bool ShibbolethResolver::init(unsigned long features, const char* config, bool rethrow)
128 SPConfig::getConfig().setFeatures(features | SPConfig::AttributeResolution | SPConfig::Metadata | SPConfig::Trust);
129 if (!SPConfig::getConfig().init())
131 if (!SPConfig::getConfig().instantiate(config, rethrow))
137 * Shuts down runtime.
139 * Each process using the library SHOULD call this function exactly once before terminating itself.
141 void ShibbolethResolver::term()
143 SPConfig::getConfig().term();
147 extern "C" int SHIBRESOLVER_EXPORTS xmltooling_extension_init(void*)
149 #ifdef SHIBRESOLVER_SHIBSP_HAS_REMOTING
150 SPConfig& conf = SPConfig::getConfig();
151 if (conf.isEnabled(SPConfig::OutOfProcess) && !conf.isEnabled(SPConfig::InProcess) && conf.isEnabled(SPConfig::Listener))
152 conf.getServiceProvider()->regListener("org.project-moonshot.shibresolver", &g_Remoted);
154 return 0; // signal success
157 extern "C" void SHIBRESOLVER_EXPORTS xmltooling_extension_term()
159 // Factories normally get unregistered during library shutdown, so no work usually required here.