Improve property inheritance, first batch of SessionInitiators, rename providerId.
[shibboleth/sp.git] / shibsp / handler / AbstractHandler.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/AbstractHandler.h
19  * 
20  * Base class for handlers based on a DOMPropertySet. 
21  */
22
23 #ifndef __shibsp_abshandler_h__
24 #define __shibsp_abshandler_h__
25
26 #include <shibsp/handler/Handler.h>
27 #include <shibsp/util/DOMPropertySet.h>
28
29 #include <log4cpp/Category.hh>
30 #include <saml/binding/HTTPRequest.h>
31 #include <xmltooling/XMLObject.h>
32
33 namespace shibsp {
34
35     class SHIBSP_API SPRequest;
36
37 #if defined (_MSC_VER)
38     #pragma warning( push )
39     #pragma warning( disable : 4250 )
40 #endif
41
42     /**
43      * Base class for handlers based on a DOMPropertySet.
44      */
45     class SHIBSP_API AbstractHandler : public virtual Handler, public DOMPropertySet
46     {
47     protected:
48         /**
49          * Constructor
50          * 
51          * @param e         DOM element to load as property set. 
52          * @param filter    optional filter controls what child elements to include as nested PropertySets
53          * @param remapper  optional map of property rename rules for legacy property support
54          */
55         AbstractHandler(
56             const DOMElement* e,
57             log4cpp::Category& log,
58             DOMNodeFilter* filter=NULL,
59             const std::map<std::string,std::string>* remapper=NULL
60             );
61
62         /**
63          * Examines a protocol response message for errors and raises an annotated exception
64          * if an error is found.
65          * 
66          * <p>The base class version understands SAML 1.x and SAML 2.0 responses.
67          * 
68          * @param response      a response message of some known protocol
69          */
70         virtual void checkError(const xmltooling::XMLObject* response) const;
71         
72         /**
73          * Implements various mechanisms to preserve RelayState,
74          * such as cookies or StorageService-backed keys.
75          * 
76          * <p>If a supported mechanism can be identified, the input parameter will be
77          * replaced with a suitable state key, URL-encoded.
78          * 
79          * @param request       the active SPRequest
80          * @param relayState    RelayState token to supply with message
81          */
82         virtual void preserveRelayState(SPRequest& request, std::string& relayState) const;
83
84         /**
85          * Implements various mechanisms to recover RelayState,
86          * such as cookies or StorageService-backed keys.
87          * 
88          * <p>If a supported mechanism can be identified, the input parameter will be
89          * replaced with the recovered state information.
90          * 
91          * @param httpRequest   incoming HTTP request
92          * @param relayState    RelayState token supplied with message
93          */
94         virtual void recoverRelayState(opensaml::HTTPRequest& httpRequest, std::string& relayState) const;
95         
96         /** Logging object. */
97         log4cpp::Category& m_log;
98         
99     public:
100         virtual ~AbstractHandler() {}
101     };
102
103 #if defined (_MSC_VER)
104     #pragma warning( pop )
105 #endif
106
107 };
108
109 #endif /* __shibsp_abshandler_h__ */