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 xmltooling/io/GenericRequest.h
24 * Interface to generic protocol requests that transport XML messages.
27 #ifndef __xmltooling_genreq_h__
28 #define __xmltooling_genreq_h__
30 #include <xmltooling/base.h>
35 #ifndef XMLTOOLING_NO_XMLSEC
36 # include <xsec/enc/XSECCryptoX509.hpp>
39 namespace xmltooling {
42 * Interface to generic protocol requests that transport XML messages.
44 * <p>This interface need not be threadsafe.
46 class XMLTOOL_API GenericRequest {
47 MAKE_NONCOPYABLE(GenericRequest);
51 virtual ~GenericRequest();
54 * Returns the URL scheme of the request (http, https, ftp, ldap, etc.)
56 * @return the URL scheme
58 virtual const char* getScheme() const=0;
61 * Returns true iff the request is over a confidential channel.
63 * @return confidential channel indicator
65 virtual bool isSecure() const=0;
68 * Returns hostname of service that received request.
70 * @return hostname of service
72 virtual const char* getHostname() const=0;
75 * Returns incoming port.
77 * @return incoming port
79 virtual int getPort() const=0;
82 * Returns the MIME type of the request, if known.
84 * @return the MIME type, or an empty string
86 virtual std::string getContentType() const=0;
89 * Returns the length of the request body, if known.
91 * @return the content length, or -1 if unknown
93 virtual long getContentLength() const=0;
96 * Returns the raw request body.
98 * @return the request body, or nullptr
100 virtual const char* getRequestBody() const=0;
103 * Returns a decoded named parameter value from the request.
104 * If a parameter has multiple values, only one will be returned.
106 * @param name the name of the parameter to return
107 * @return a single parameter value or nullptr
109 virtual const char* getParameter(const char* name) const=0;
112 * Returns all of the decoded values of a named parameter from the request.
113 * All values found will be returned.
115 * @param name the name of the parameter to return
116 * @param values a vector in which to return pointers to the decoded values
117 * @return the number of values returned
119 virtual std::vector<const char*>::size_type getParameters(
120 const char* name, std::vector<const char*>& values
124 * Returns the transport-authenticated identity associated with the request,
125 * if authentication is solely handled by the transport.
127 * @return the authenticated username or an empty string
129 virtual std::string getRemoteUser() const=0;
132 * Gets the authentication type associated with the request.
134 * @return the authentication type or nullptr
136 virtual std::string getAuthType() const {
141 * Returns the IP address of the client.
143 * @return the client's IP address
145 virtual std::string getRemoteAddr() const=0;
148 * Returns the chain of certificates sent by the client.
149 * They are not guaranteed to be valid according to any particular definition.
151 * @return the client's certificate chain
154 #ifndef XMLTOOLING_NO_XMLSEC
155 std::vector<XSECCryptoX509*>&
157 std::vector<std::string>&
159 getClientCertificates() const=0;
163 #endif /* __xmltooling_genreq_h__ */