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/RemotedHandler.h
24 * Base class for handlers that need SP request/response layer to be remoted.
27 #ifndef __shibsp_remhandler_h__
28 #define __shibsp_remhandler_h__
30 #include <shibsp/handler/Handler.h>
31 #include <shibsp/remoting/ListenerService.h>
35 namespace xmltooling {
36 class XMLTOOL_API HTTPRequest;
37 class XMLTOOL_API HTTPResponse;
43 * Base class for handlers that need HTTP request/response layer to be remoted.
45 class SHIBSP_API RemotedHandler : public virtual Handler, public Remoted
47 static std::set<std::string> m_remotedHeaders;
50 virtual ~RemotedHandler();
53 * Ensures that a request header will be remoted.
55 * @param header name of request header to remote
57 static void addRemotedHeader(const char* header);
63 * Establishes message remoting using the supplied address.
65 * @param address a unique "address" for remote message handling
67 void setAddress(const char* address);
70 * Wraps a request by creating an outgoing data flow with the data needed
71 * to remote the request information.
73 * @param request an SPRequest to remote
74 * @param headers array of additional request headers to copy to remote request
75 * @param certs true iff client certificates should be available for the remote request
76 * @return the input dataflow object
78 DDF wrap(const SPRequest& request, const std::vector<std::string>* headers=nullptr, bool certs=false) const;
81 * Unwraps a response by examining an incoming data flow to determine
82 * whether a response was produced by the remoted handler.
84 * @param request SP request context
85 * @param out the dataflow object to unpack
86 * @return a pair containing a "request completed" indicator and a server-specific response code
88 virtual std::pair<bool,long> unwrap(SPRequest& request, DDF& out) const;
91 * Builds a new request instance around a remoted data object.
93 * @param in the dataflow object containing the remoted request
94 * @return a call-specific request object based on the input, to be freed by the caller
96 xmltooling::HTTPRequest* getRequest(DDF& in) const;
99 * Builds a new response instance around an outgoing data object.
101 * @param out the dataflow object to be returned by the caller
102 * @return a call-specific response object, to be freed by the caller
104 xmltooling::HTTPResponse* getResponse(DDF& out) const;
106 /** Message address for remote half. */
107 std::string m_address;
111 #endif /* __shibsp_remhandler_h__ */