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