Imported Upstream version 2.3+dfsg
[shibboleth/sp.git] / shibsp / handler / SessionInitiator.h
1 /*
2  *  Copyright 2001-2009 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file shibsp/handler/SessionInitiator.h
19  * 
20  * Pluggable runtime functionality that handles initiating sessions.
21  */
22
23 #ifndef __shibsp_initiator_h__
24 #define __shibsp_initiator_h__
25
26 #include <shibsp/handler/Handler.h>
27
28 namespace shibsp {
29
30     /**
31      * Pluggable runtime functionality that handles initiating sessions.
32      *
33      * <p>By default, SessionInitiators look for an entityID on the incoming request
34      * and pass control to the specialized run method.
35      */
36     class SHIBSP_API SessionInitiator : public virtual Handler
37     {
38         friend void SHIBSP_API registerSessionInitiators();
39     protected:
40         /** Property remapper for configuration compatibility. */
41         static std::map<std::string,std::string> m_remapper;
42
43         SessionInitiator();
44
45     public:
46         virtual ~SessionInitiator();
47
48         /**
49          * Executes an incoming request.
50          * 
51          * <p>SessionInitiators can be run either directly by incoming web requests
52          * or indirectly/implicitly during other SP processing.
53          * 
54          * @param request   SP request context
55          * @param entityID  the name of an IdP to request a session from, if known
56          * @param isHandler true iff executing in the context of a direct handler invocation
57          * @return  a pair containing a "request completed" indicator and a server-specific response code
58          */
59         virtual std::pair<bool,long> run(SPRequest& request, std::string& entityID, bool isHandler=true) const=0;
60
61         std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
62
63 #ifndef SHIBSP_LITE
64         const char* getType() const;
65 #endif
66     };
67     
68     /** Registers SessionInitiator implementations. */
69     void SHIBSP_API registerSessionInitiators();
70
71     /** SessionInitiator that iterates through a set of protocol-specific versions. */
72     #define CHAINING_SESSION_INITIATOR "Chaining"
73
74     /** SessionInitiator that supports SAML 2.0 AuthnRequests. */
75     #define SAML2_SESSION_INITIATOR "SAML2"
76
77     /** SessionInitiator that supports SAML Discovery Service protocol. */
78     #define SAMLDS_SESSION_INITIATOR "SAMLDS"
79
80     /** SessionInitiator that supports Shibboleth V1 AuthnRequest redirects. */
81     #define SHIB1_SESSION_INITIATOR "Shib1"
82
83     /** SessionInitiator that supports Shibboleth V1 WAYF redirects when no IdP is supplied. */
84     #define WAYF_SESSION_INITIATOR "WAYF"
85     
86     /** SessionInitiator that attempts a sequence of transforms of an input until an entityID is found. */
87     #define TRANSFORM_SESSION_INITIATOR "Transform"
88
89     /** SessionInitiator that uses HTML form submission from the user. */
90     #define FORM_SESSION_INITIATOR "Form"
91
92     /** SessionInitiator that reads the CDC. */
93     #define COOKIE_SESSION_INITIATOR "Cookie"
94 };
95
96 #endif /* __shibsp_initiator_h__ */