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>
29 #include <log4cpp/Category.hh>
31 # include <saml/binding/MessageEncoder.h>
32 # include <saml/saml2/core/Protocols.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 log4cpp::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 signingOption name of property to lookup controlling signing
106 * @param signIfPossible true iff signing should be attempted regardless of property
107 * @return the result of sending the message using the encoder
110 const opensaml::MessageEncoder& encoder,
111 xmltooling::XMLObject* msg,
112 const char* relayState,
113 const char* destination,
114 const opensaml::saml2md::RoleDescriptor* role,
115 const Application& application,
116 xmltooling::HTTPResponse& httpResponse,
117 const char* signingOption,
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 log4cpp::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__ */