Form generator for discovery along with sample form.
[shibboleth/sp.git] / shibsp / handler / SessionInitiator.h
1 /*
2  *  Copyright 2001-2007 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     protected:
39         SessionInitiator() {}
40
41     public:
42         virtual ~SessionInitiator() {}
43
44         /**
45          * Executes an incoming request.
46          * 
47          * <p>SessionInitiators can be run either directly by incoming web requests
48          * or indirectly/implicitly during other SP processing.
49          * 
50          * @param request   SP request context
51          * @param entityID  the name of an IdP to request a session from, if known
52          * @param isHandler true iff executing in the context of a direct handler invocation
53          * @return  a pair containing a "request completed" indicator and a server-specific response code
54          */
55         virtual std::pair<bool,long> run(SPRequest& request, std::string& entityID, bool isHandler=true) const=0;
56
57         std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
58
59 #ifndef SHIBSP_LITE
60         const char* getType() const {
61             return "SessionInitiator";
62         }
63 #endif
64     };
65     
66     /** Registers SessionInitiator implementations. */
67     void SHIBSP_API registerSessionInitiators();
68
69     /** SessionInitiator that iterates through a set of protocol-specific versions. */
70     #define CHAINING_SESSION_INITIATOR "Chaining"
71
72     /** SessionInitiator that supports SAML 2.0 AuthnRequests. */
73     #define SAML2_SESSION_INITIATOR "SAML2"
74
75     /** SessionInitiator that supports SAML Discovery Service protocol. */
76     #define SAMLDS_SESSION_INITIATOR "SAMLDS"
77
78     /** SessionInitiator that supports Shibboleth V1 AuthnRequest redirects. */
79     #define SHIB1_SESSION_INITIATOR "Shib1"
80
81     /** SessionInitiator that supports Shibboleth V1 WAYF redirects when no IdP is supplied. */
82     #define WAYF_SESSION_INITIATOR "WAYF"
83     
84     /** SessionInitiator that attempts a sequence of transforms of an input until an entityID is found. */
85     #define TRANSFORM_SESSION_INITIATOR "Transform"
86
87     /** SessionInitiator that uses HTML form submission from the user. */
88     #define FORM_SESSION_INITIATOR "Form"
89 };
90
91 #endif /* __shibsp_initiator_h__ */