2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file shibsp/handler/Handler.h
24 * Pluggable runtime functionality that implement protocols and services.
27 #ifndef __shibsp_handler_h__
28 #define __shibsp_handler_h__
30 #include <shibsp/SPRequest.h>
31 #include <shibsp/util/PropertySet.h>
36 class SAML_API SPSSODescriptor;
41 namespace xmltooling {
42 class XMLTOOL_API HTTPRequest;
43 class XMLTOOL_API HTTPResponse;
49 * Pluggable runtime functionality that implement protocols and services
51 class SHIBSP_API Handler : public virtual PropertySet
53 MAKE_NONCOPYABLE(Handler);
58 * Log using handler's specific logging object.
60 * @param level logging level
61 * @param msg message to log
63 virtual void log(SPRequest::SPLogLevel level, const std::string& msg) const;
66 * Implements various mechanisms to preserve RelayState,
67 * such as cookies or StorageService-backed keys.
69 * <p>If a supported mechanism can be identified, the input parameter will be
70 * replaced with a suitable state key.
72 * @param application the associated Application
73 * @param response outgoing HTTP response
74 * @param relayState RelayState token to supply with message
76 virtual void preserveRelayState(
77 const Application& application, xmltooling::HTTPResponse& response, std::string& relayState
81 * Implements various mechanisms to recover RelayState,
82 * such as cookies or StorageService-backed keys.
84 * <p>If a supported mechanism can be identified, the input parameter will be
85 * replaced with the recovered state information.
87 * @param application the associated Application
88 * @param request incoming HTTP request
89 * @param response outgoing HTTP response
90 * @param relayState RelayState token supplied with message
91 * @param clear true iff the token state should be cleared
93 virtual void recoverRelayState(
94 const Application& application,
95 const xmltooling::HTTPRequest& request,
96 xmltooling::HTTPResponse& response,
97 std::string& relayState,
105 * Returns an identifier for the protocol family associated with the handler, if any.
107 * @return a protocol identifier, or nullptr
109 virtual const XMLCh* getProtocolFamily() const;
112 * Executes handler functionality as an incoming request.
114 * <p>Handlers can be run either directly by incoming web requests
115 * or indirectly/implicitly during other SP processing.
117 * @param request SP request context
118 * @param isHandler true iff executing in the context of a direct handler invocation
119 * @return a pair containing a "request completed" indicator and a server-specific response code
121 virtual std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const=0;
125 * Generates and/or modifies metadata reflecting the Handler.
127 * <p>The default implementation does nothing.
129 * @param role metadata role to decorate
130 * @param handlerURL base location of handler's endpoint
132 virtual void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const;
135 * Returns the "type" of the Handler plugin.
137 * @return a Handler type
139 virtual const char* getType() const;
143 /** Registers Handler implementations. */
144 void SHIBSP_API registerHandlers();
146 /** Handler for SAML 1.x SSO. */
147 #define SAML1_ASSERTION_CONSUMER_SERVICE "SAML1"
149 /** Handler for SAML 2.0 SSO. */
150 #define SAML20_ASSERTION_CONSUMER_SERVICE "SAML2"
152 /** Handler for SAML 2.0 SLO. */
153 #define SAML20_LOGOUT_HANDLER "SAML2"
155 /** Handler for SAML 2.0 NIM. */
156 #define SAML20_NAMEID_MGMT_SERVICE "SAML2"
158 /** Handler for SAML 2.0 Artifact Resolution. */
159 #define SAML20_ARTIFACT_RESOLUTION_SERVICE "SAML2"
161 /** Handler for hooking new sessions with attribute checking. */
162 #define ATTR_CHECKER_HANDLER "AttributeChecker"
164 /** Handler for metadata generation. */
165 #define DISCOVERY_FEED_HANDLER "DiscoveryFeed"
167 /** Handler for metadata generation. */
168 #define METADATA_GENERATOR_HANDLER "MetadataGenerator"
170 /** Handler for status information. */
171 #define STATUS_HANDLER "Status"
173 /** Handler for session diagnostic information. */
174 #define SESSION_HANDLER "Session"
177 #endif /* __shibsp_handler_h__ */