2 * Copyright 2001-2010 Internet2
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.
18 * @file shibsp/handler/SessionInitiator.h
20 * Pluggable runtime functionality that handles initiating sessions.
23 #ifndef __shibsp_initiator_h__
24 #define __shibsp_initiator_h__
26 #include <shibsp/handler/Handler.h>
34 * Pluggable runtime functionality that handles initiating sessions.
36 * <p>By default, SessionInitiators look for an entityID on the incoming request
37 * and pass control to the specialized run method.
39 class SHIBSP_API SessionInitiator : public virtual Handler
41 friend void SHIBSP_API registerSessionInitiators();
43 /** Property remapper for configuration compatibility. */
44 static std::map<std::string,std::string> m_remapper;
46 /** Set of optional settings supported by handler. */
47 std::set<std::string> m_supportedOptions;
52 * Examines the request and applicable settings to determine whether
53 * the handler is able to support the request.
54 * <p>If the handler is within a chain, the method will return false,
55 * otherwise an exception will be raised.
57 * @param request SP request context
58 * @param isHandler true iff executing in the context of a direct handler invocation
59 * @return true iff the request appears to be compatible
61 bool checkCompatibility(SPRequest& request, bool isHandler) const;
64 virtual ~SessionInitiator();
67 * Indicates the set of optional settings supported by the handler.
69 * @return an array of the optional settings supported
71 virtual const std::set<std::string>& getSupportedOptions() const;
74 * Executes an incoming request.
76 * <p>SessionInitiators can be run either directly by incoming web requests
77 * or indirectly/implicitly during other SP processing.
79 * @param request SP request context
80 * @param entityID the name of an IdP to request a session from, if known
81 * @param isHandler true iff executing in the context of a direct handler invocation
82 * @return a pair containing a "request completed" indicator and a server-specific response code
84 virtual std::pair<bool,long> run(SPRequest& request, std::string& entityID, bool isHandler=true) const=0;
86 std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
89 const char* getType() const;
93 /** Registers SessionInitiator implementations. */
94 void SHIBSP_API registerSessionInitiators();
96 /** SessionInitiator that iterates through a set of protocol-specific versions. */
97 #define CHAINING_SESSION_INITIATOR "Chaining"
99 /** SessionInitiator that supports SAML 2.0 AuthnRequests. */
100 #define SAML2_SESSION_INITIATOR "SAML2"
102 /** SessionInitiator that supports SAML Discovery Service protocol. */
103 #define SAMLDS_SESSION_INITIATOR "SAMLDS"
105 /** SessionInitiator that supports Shibboleth V1 AuthnRequest redirects. */
106 #define SHIB1_SESSION_INITIATOR "Shib1"
108 /** SessionInitiator that supports Shibboleth V1 WAYF redirects when no IdP is supplied. */
109 #define WAYF_SESSION_INITIATOR "WAYF"
111 /** SessionInitiator that attempts a sequence of transforms of an input until an entityID is found. */
112 #define TRANSFORM_SESSION_INITIATOR "Transform"
114 /** SessionInitiator that uses HTML form submission from the user. */
115 #define FORM_SESSION_INITIATOR "Form"
117 /** SessionInitiator that reads the CDC. */
118 #define COOKIE_SESSION_INITIATOR "Cookie"
121 #endif /* __shibsp_initiator_h__ */