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_sesinitiator_h__
24 #define __shibsp_sesinitiator_h__
26 #include <shibsp/handler/Handler.h>
35 * Pluggable runtime functionality that handles initiating sessions.
37 * <p>By default, SessionInitiators look for an entityID on the incoming request
38 * and pass control to the specialized run method.
40 class SHIBSP_API SessionInitiator : public virtual Handler
42 friend void SHIBSP_API registerSessionInitiators();
44 /** Property remapper for configuration compatibility. */
45 static std::map<std::string,std::string> m_remapper;
47 /** Set of optional settings supported by handler. */
48 std::set<std::string> m_supportedOptions;
53 * Examines the request and applicable settings to determine whether
54 * the handler is able to support the request.
55 * <p>If the handler is within a chain, the method will return false,
56 * otherwise an exception will be raised.
58 * @param request SP request context
59 * @param isHandler true iff executing in the context of a direct handler invocation
60 * @return true iff the request appears to be compatible
62 bool checkCompatibility(SPRequest& request, bool isHandler) const;
65 virtual ~SessionInitiator();
68 * Indicates the set of optional settings supported by the handler.
70 * @return a set of the optional settings supported
72 virtual const std::set<std::string>& getSupportedOptions() const;
75 * Executes an incoming request.
77 * <p>SessionInitiators can be run either directly by incoming web requests
78 * or indirectly/implicitly during other SP processing.
80 * @param request SP request context
81 * @param entityID the name of an IdP to request a session from, if known
82 * @param isHandler true iff executing in the context of a direct handler invocation
83 * @return a pair containing a "request completed" indicator and a server-specific response code
85 virtual std::pair<bool,long> run(SPRequest& request, std::string& entityID, bool isHandler=true) const=0;
87 std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
90 const char* getType() const;
94 /** Registers SessionInitiator implementations. */
95 void SHIBSP_API registerSessionInitiators();
97 /** SessionInitiator that iterates through a set of protocol-specific versions. */
98 #define CHAINING_SESSION_INITIATOR "Chaining"
100 /** SessionInitiator that supports SAML 2.0 AuthnRequests. */
101 #define SAML2_SESSION_INITIATOR "SAML2"
103 /** SessionInitiator that supports SAML Discovery Service protocol. */
104 #define SAMLDS_SESSION_INITIATOR "SAMLDS"
106 /** SessionInitiator that supports Shibboleth V1 AuthnRequest redirects. */
107 #define SHIB1_SESSION_INITIATOR "Shib1"
109 /** SessionInitiator that supports Shibboleth V1 WAYF redirects when no IdP is supplied. */
110 #define WAYF_SESSION_INITIATOR "WAYF"
112 /** SessionInitiator that attempts a sequence of transforms of an input until an entityID is found. */
113 #define TRANSFORM_SESSION_INITIATOR "Transform"
115 /** SessionInitiator that uses HTML form submission from the user. */
116 #define FORM_SESSION_INITIATOR "Form"
118 /** SessionInitiator that reads the CDC. */
119 #define COOKIE_SESSION_INITIATOR "Cookie"
122 #endif /* __shibsp_sesinitiator_h__ */