ce55e125582deae79240b8936ee5edcf71debbbb
[shibboleth/sp.git] / shibsp / AbstractSPRequest.h
1 /**
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.
6  *
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
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 /**
22  * @file shibsp/AbstractSPRequest.h
23  * 
24  * Abstract base for SPRequest implementations.
25  */
26
27 #ifndef __shibsp_abstreq_h__
28 #define __shibsp_abstreq_h__
29
30 #include <shibsp/SPRequest.h>
31
32 namespace shibsp {
33     
34     class SHIBSP_API CGIParser;
35
36 #if defined (_MSC_VER)
37     #pragma warning( push )
38     #pragma warning( disable : 4251 )
39 #endif
40
41     /**
42      * Abstract base for SPRequest implementations
43      */
44     class SHIBSP_API AbstractSPRequest : public virtual SPRequest
45     {
46     protected:
47         /**
48          * Constructor.
49          *
50          * @param category  logging category to use
51          */
52         AbstractSPRequest(const char* category);
53         
54         /**
55          * Stores a normalized request URI to ensure it contains no %-encoded characters
56          * or other undesirable artifacts.
57          *
58          * @param uri   the request URI as obtained from the client
59          */
60         void setRequestURI(const char* uri);
61
62     public:
63         virtual ~AbstractSPRequest();
64
65         // Virtual function overrides.
66         const ServiceProvider& getServiceProvider() const;
67         RequestMapper::Settings getRequestSettings() const;
68         const Application& getApplication() const;
69         Session* getSession(bool checkTimeout=true, bool ignoreAddress=false, bool cache=true);
70         const char* getRequestURI() const;
71         const char* getRequestURL() const;
72         std::string getRemoteAddr() const;
73         const char* getParameter(const char* name) const;
74         std::vector<const char*>::size_type getParameters(const char* name, std::vector<const char*>& values) const;
75         const char* getHandlerURL(const char* resource=nullptr) const;
76         void log(SPLogLevel level, const std::string& msg) const;
77         bool isPriorityEnabled(SPLogLevel level) const;
78
79     private:
80         ServiceProvider* m_sp;
81         mutable RequestMapper* m_mapper;
82         mutable RequestMapper::Settings m_settings;
83         mutable const Application* m_app;
84         mutable bool m_sessionTried;
85         mutable Session* m_session;
86         std::string m_uri;
87         mutable std::string m_url;
88         void* m_log; // declared void* to avoid log4cpp header conflicts in Apache
89         mutable std::string m_handlerURL;
90         mutable CGIParser* m_parser;
91     };
92
93 #if defined (_MSC_VER)
94     #pragma warning( pop )
95 #endif
96
97 };
98
99 #endif /* __shibsp_abstreq_h__ */