2 * Copyright 2001-2007 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/AbstractHandler.h
20 * Base class for handlers based on a DOMPropertySet.
23 #ifndef __shibsp_abshandler_h__
24 #define __shibsp_abshandler_h__
26 #include <shibsp/handler/Handler.h>
27 #include <shibsp/util/DOMPropertySet.h>
30 # include <saml/binding/MessageEncoder.h>
31 # include <saml/saml2/core/Protocols.h>
33 #include <xmltooling/logging.h>
34 #include <xmltooling/XMLObject.h>
35 #include <xmltooling/io/HTTPRequest.h>
36 #include <xmltooling/io/HTTPResponse.h>
40 class SHIBSP_API Application;
41 class SHIBSP_API SPRequest;
43 #if defined (_MSC_VER)
44 #pragma warning( push )
45 #pragma warning( disable : 4250 )
49 * Base class for handlers based on a DOMPropertySet.
51 class SHIBSP_API AbstractHandler : public virtual Handler, public DOMPropertySet
57 * @param e DOM element to load as property set.
58 * @param filter optional filter controls what child elements to include as nested PropertySets
59 * @param remapper optional map of property rename rules for legacy property support
62 const xercesc::DOMElement* e,
63 xmltooling::logging::Category& log,
64 xercesc::DOMNodeFilter* filter=NULL,
65 const std::map<std::string,std::string>* remapper=NULL
70 * Examines a protocol response message for errors and raises an annotated exception
71 * if an error is found.
73 * <p>The base class version understands SAML 1.x and SAML 2.0 responses.
75 * @param response a response message of some known protocol
76 * @param role issuer of message
78 virtual void checkError(
79 const xmltooling::XMLObject* response,
80 const opensaml::saml2md::RoleDescriptor* role=NULL
84 * Prepares Status information in a SAML 2.0 response.
86 * @param response a SAML 2.0 response message
87 * @param code SAML status code
88 * @param ex optional message to pass back
91 opensaml::saml2p::StatusResponseType& response, const XMLCh* code, const XMLCh* subcode=NULL, const char* msg=NULL
95 * Encodes and sends SAML 2.0 message, optionally signing it in the process.
96 * If the method returns, the message MUST NOT be freed by the caller.
98 * @param encoder the MessageEncoder to use
99 * @param msg the message to send
100 * @param relayState any RelayState to include with the message
101 * @param destination location to send message, if not a backchannel response
102 * @param role recipient of message, if known
103 * @param application the Application sending the message
104 * @param httpResponse channel for sending message
105 * @param signIfPossible true iff signing should be attempted regardless of "signing" property
106 * @return the result of sending the message using the encoder
109 const opensaml::MessageEncoder& encoder,
110 xmltooling::XMLObject* msg,
111 const char* relayState,
112 const char* destination,
113 const opensaml::saml2md::RoleDescriptor* role,
114 const Application& application,
115 xmltooling::HTTPResponse& httpResponse,
116 bool signIfPossible=false
121 * Implements various mechanisms to preserve RelayState,
122 * such as cookies or StorageService-backed keys.
124 * <p>If a supported mechanism can be identified, the input parameter will be
125 * replaced with a suitable state key.
127 * @param application the associated Application
128 * @param response outgoing HTTP response
129 * @param relayState RelayState token to supply with message
131 virtual void preserveRelayState(const Application& application, xmltooling::HTTPResponse& response, std::string& relayState) const;
134 * Implements various mechanisms to recover RelayState,
135 * such as cookies or StorageService-backed keys.
137 * <p>If a supported mechanism can be identified, the input parameter will be
138 * replaced with the recovered state information.
140 * @param application the associated Application
141 * @param request incoming HTTP request
142 * @param relayState RelayState token supplied with message
143 * @param clear true iff the token state should be cleared
145 virtual void recoverRelayState(
146 const Application& application, xmltooling::HTTPRequest& request, std::string& relayState, bool clear=true
149 /** Logging object. */
150 xmltooling::logging::Category& m_log;
152 /** Configuration namespace for custom properties. */
153 xmltooling::auto_ptr_char m_configNS;
156 virtual ~AbstractHandler() {}
159 #if defined (_MSC_VER)
160 #pragma warning( pop )
165 #endif /* __shibsp_abshandler_h__ */