Update copyright.
[shibboleth/cpp-opensaml.git] / saml / binding / GenericRequest.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file saml/binding/GenericRequest.h
19  * 
20  * Interface to generic protocol requests that transport SAML messages. 
21  */
22
23 #ifndef __saml_genreq_h__
24 #define __saml_genreq_h__
25
26 #include <saml/base.h>
27 #include <string>
28 #include <vector>
29 #include <xsec/enc/XSECCryptoX509.hpp>
30
31 namespace opensaml {
32     
33     /**
34      * Interface to caller-supplied shim for accessing generic transport
35      * request context.
36      * 
37      * <p>This interface need not be threadsafe.
38      */
39     class SAML_API GenericRequest {
40         MAKE_NONCOPYABLE(GenericRequest);
41     protected:
42         GenericRequest() {}
43     public:
44         virtual ~GenericRequest() {}
45         
46         /**
47          * Returns the URL scheme of the request (http, https, ftp, ldap, etc.)
48          * 
49          * @return the URL scheme
50          */
51         virtual const char* getScheme() const=0;
52         
53         /**
54          * Returns true iff the request is over a confidential channel.
55          * 
56          * @return confidential channel indicator
57          */
58         virtual bool isSecure() const=0;
59         
60         /**
61          * Returns hostname of service that received request.
62          * 
63          * @return hostname of service
64          */
65         virtual const char* getHostname() const=0;
66
67         /**
68          * Returns incoming port.
69          * 
70          * @return  incoming port 
71          */
72         virtual int getPort() const=0;
73         
74         /**
75          * Returns the MIME type of the request, if known.
76          * 
77          * @return the MIME type, or an empty string
78          */
79         virtual std::string getContentType() const=0;
80
81         /**
82          * Returns the length of the request body, if known.
83          * 
84          * @return the content length, or -1 if unknown
85          */
86         virtual long getContentLength() const=0;
87
88         /**
89          * Returns the raw request body.
90          * 
91          * @return the request body, or NULL
92          */
93         virtual const char* getRequestBody() const=0;
94         
95         /**
96          * Returns a decoded named parameter value from the request.
97          * If a parameter has multiple values, only one will be returned.
98          * 
99          * @param name  the name of the parameter to return
100          * @return a single parameter value or NULL
101          */
102         virtual const char* getParameter(const char* name) const=0;
103
104         /**
105          * Returns all of the decoded values of a named parameter from the request.
106          * All values found will be returned.
107          * 
108          * @param name      the name of the parameter to return
109          * @param values    a vector in which to return pointers to the decoded values
110          * @return  the number of values returned
111          */            
112         virtual std::vector<const char*>::size_type getParameters(
113             const char* name, std::vector<const char*>& values
114             ) const=0;
115
116         /**
117          * Returns the transport-authenticated identity associated with the request,
118          * if authentication is solely handled by the transport.
119          * 
120          * @return the authenticated username or an empty string
121          */
122         virtual std::string getRemoteUser() const=0;
123
124         /**
125          * Returns the IP address of the client.
126          * 
127          * @return the client's IP address
128          */
129         virtual std::string getRemoteAddr() const=0;
130         
131         /**
132          * Returns the chain of certificates sent by the client.
133          * They are not guaranteed to be valid according to any particular definition.
134          * 
135          * @return the client's certificate chain 
136          */
137         virtual const std::vector<XSECCryptoX509*>& getClientCertificates() const=0;
138     };
139 };
140
141 #endif /* __saml_genreq_h__ */