2 * Copyright 2001-2010 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 xmltooling/io/GenericRequest.h
20 * Interface to generic protocol requests that transport XML messages.
23 #ifndef __xmltooling_genreq_h__
24 #define __xmltooling_genreq_h__
26 #include <xmltooling/base.h>
31 #ifndef XMLTOOLING_NO_XMLSEC
32 # include <xsec/enc/XSECCryptoX509.hpp>
35 namespace xmltooling {
38 * Interface to generic protocol requests that transport XML messages.
40 * <p>This interface need not be threadsafe.
42 class XMLTOOL_API GenericRequest {
43 MAKE_NONCOPYABLE(GenericRequest);
47 virtual ~GenericRequest();
50 * Returns the URL scheme of the request (http, https, ftp, ldap, etc.)
52 * @return the URL scheme
54 virtual const char* getScheme() const=0;
57 * Returns true iff the request is over a confidential channel.
59 * @return confidential channel indicator
61 virtual bool isSecure() const=0;
64 * Returns hostname of service that received request.
66 * @return hostname of service
68 virtual const char* getHostname() const=0;
71 * Returns incoming port.
73 * @return incoming port
75 virtual int getPort() const=0;
78 * Returns the MIME type of the request, if known.
80 * @return the MIME type, or an empty string
82 virtual std::string getContentType() const=0;
85 * Returns the length of the request body, if known.
87 * @return the content length, or -1 if unknown
89 virtual long getContentLength() const=0;
92 * Returns the raw request body.
94 * @return the request body, or nullptr
96 virtual const char* getRequestBody() const=0;
99 * Returns a decoded named parameter value from the request.
100 * If a parameter has multiple values, only one will be returned.
102 * @param name the name of the parameter to return
103 * @return a single parameter value or nullptr
105 virtual const char* getParameter(const char* name) const=0;
108 * Returns all of the decoded values of a named parameter from the request.
109 * All values found will be returned.
111 * @param name the name of the parameter to return
112 * @param values a vector in which to return pointers to the decoded values
113 * @return the number of values returned
115 virtual std::vector<const char*>::size_type getParameters(
116 const char* name, std::vector<const char*>& values
120 * Returns the transport-authenticated identity associated with the request,
121 * if authentication is solely handled by the transport.
123 * @return the authenticated username or an empty string
125 virtual std::string getRemoteUser() const=0;
128 * Gets the authentication type associated with the request.
130 * @return the authentication type or nullptr
132 virtual std::string getAuthType() const {
137 * Returns the IP address of the client.
139 * @return the client's IP address
141 virtual std::string getRemoteAddr() const=0;
144 * Returns the chain of certificates sent by the client.
145 * They are not guaranteed to be valid according to any particular definition.
147 * @return the client's certificate chain
150 #ifndef XMLTOOLING_NO_XMLSEC
151 std::vector<XSECCryptoX509*>&
153 std::vector<std::string>&
155 getClientCertificates() const=0;
159 #endif /* __xmltooling_genreq_h__ */