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 log logging category to use
59 * @param filter optional filter controls what child elements to include as nested PropertySets
60 * @param remapper optional map of property rename rules for legacy property support
63 const xercesc::DOMElement* e,
64 xmltooling::logging::Category& log,
65 xercesc::DOMNodeFilter* filter=NULL,
66 const std::map<std::string,std::string>* remapper=NULL
71 * Examines a protocol response message for errors and raises an annotated exception
72 * if an error is found.
74 * <p>The base class version understands SAML 1.x and SAML 2.0 responses.
76 * @param response a response message of some known protocol
77 * @param role issuer of message
79 virtual void checkError(
80 const xmltooling::XMLObject* response,
81 const opensaml::saml2md::RoleDescriptor* role=NULL
85 * Prepares Status information in a SAML 2.0 response.
87 * @param response SAML 2.0 response message
88 * @param code SAML status code
89 * @param subcode optional SAML substatus code
90 * @param msg optional message to pass back
93 opensaml::saml2p::StatusResponseType& response, const XMLCh* code, const XMLCh* subcode=NULL, const char* msg=NULL
97 * Encodes and sends SAML 2.0 message, optionally signing it in the process.
98 * If the method returns, the message MUST NOT be freed by the caller.
100 * @param encoder the MessageEncoder to use
101 * @param msg the message to send
102 * @param relayState any RelayState to include with the message
103 * @param destination location to send message, if not a backchannel response
104 * @param role recipient of message, if known
105 * @param application the Application sending the message
106 * @param httpResponse channel for sending message
107 * @param signIfPossible true iff signing should be attempted regardless of "signing" property
108 * @return the result of sending the message using the encoder
111 const opensaml::MessageEncoder& encoder,
112 xmltooling::XMLObject* msg,
113 const char* relayState,
114 const char* destination,
115 const opensaml::saml2md::RoleDescriptor* role,
116 const Application& application,
117 xmltooling::HTTPResponse& httpResponse,
118 bool signIfPossible=false
123 * Implements various mechanisms to preserve RelayState,
124 * such as cookies or StorageService-backed keys.
126 * <p>If a supported mechanism can be identified, the input parameter will be
127 * replaced with a suitable state key.
129 * @param application the associated Application
130 * @param response outgoing HTTP response
131 * @param relayState RelayState token to supply with message
133 virtual void preserveRelayState(const Application& application, xmltooling::HTTPResponse& response, std::string& relayState) const;
136 * Implements various mechanisms to recover RelayState,
137 * such as cookies or StorageService-backed keys.
139 * <p>If a supported mechanism can be identified, the input parameter will be
140 * replaced with the recovered state information.
142 * @param application the associated Application
143 * @param request incoming HTTP request
144 * @param relayState RelayState token supplied with message
145 * @param clear true iff the token state should be cleared
147 virtual void recoverRelayState(
148 const Application& application, xmltooling::HTTPRequest& request, std::string& relayState, bool clear=true
151 /** Logging object. */
152 xmltooling::logging::Category& m_log;
154 /** Configuration namespace for custom properties. */
155 xmltooling::auto_ptr_char m_configNS;
158 virtual ~AbstractHandler() {}
161 #if defined (_MSC_VER)
162 #pragma warning( pop )
167 #endif /* __shibsp_abshandler_h__ */