Revamped binding classes with security policy layer.
[shibboleth/cpp-opensaml.git] / saml / binding / GenericRequest.h
1 /*
2  *  Copyright 2001-2006 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 the MIME type of the request, if known.
62          * 
63          * @return the MIME type, or an empty string
64          */
65         virtual std::string getContentType() const=0;
66
67         /**
68          * Returns the length of the request body, if known.
69          * 
70          * @return the content length, or -1 if unknown
71          */
72         virtual long getContentLength() const=0;
73
74         /**
75          * Returns the raw request body.
76          * 
77          * @return the request body, or NULL
78          */
79         virtual const char* getRequestBody() const=0;
80         
81         /**
82          * Returns a decoded named parameter value from the request.
83          * If a parameter has multiple values, only one will be returned.
84          * 
85          * @param name  the name of the parameter to return
86          * @return a single parameter value or NULL
87          */
88         virtual const char* getParameter(const char* name) const=0;
89
90         /**
91          * Returns all of the decoded values of a named parameter from the request.
92          * All values found will be returned.
93          * 
94          * @param name      the name of the parameter to return
95          * @param values    a vector in which to return pointers to the decoded values
96          * @return  the number of values returned
97          */            
98         virtual std::vector<const char*>::size_type getParameters(
99             const char* name, std::vector<const char*>& values
100             ) const=0;
101
102         /**
103          * Returns the transport-authenticated identity associated with the request,
104          * if authentication is solely handled by the transport.
105          * 
106          * @return the authenticated username or an empty string
107          */
108         virtual std::string getRemoteUser() const=0;
109
110         /**
111          * Returns the IP address of the client.
112          * 
113          * @return the client's IP address
114          */
115         virtual std::string getRemoteAddr() const=0;
116         
117         /**
118          * Returns the chain of certificates sent by the client.
119          * They are not guaranteed to be valid according to any particular definition.
120          * 
121          * @return the client's certificate chain 
122          */
123         virtual const std::vector<XSECCryptoX509*>& getClientCertificates() const=0;
124     };
125 };
126
127 #endif /* __saml_genreq_h__ */