Linefeed change
[shibboleth/cpp-sp.git] / adfs / internal.h
1 /*
2  *  Copyright 2001-2005 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 /* internal.h
18
19    Scott Cantor
20    2/14/04
21
22    $History:$
23 */
24
25 #ifndef __internal_h__
26 #define __internal_h__
27
28 #include <saml/saml.h>
29 #include <shib/shib.h>
30 #include <shib-target/shib-target.h>
31 #include <shib-target/hresult.h>
32
33 #if defined (_MSC_VER) || defined(__BORLANDC__)
34 # include "config_win32.h"
35 #else
36 # include "config.h"
37 #endif
38
39 #if defined(HAVE_LOG4SHIB)
40 # include <log4shib/Category.hh>
41 # include <log4shib/FixedContextCategory.hh>
42 namespace adfs {
43     namespace logging = log4shib;
44 };
45 #elif defined(HAVE_LOG4CPP)
46 # include <log4cpp/Category.hh>
47 # include <log4cpp/FixedContextCategory.hh>
48 namespace adfs {
49     namespace logging = log4cpp;
50 };
51 #else
52 # error "Supported logging library not available."
53 #endif
54
55
56 #define ADFS_LOGCAT "shibtarget"
57 #define SHIBTRAN_LOGCAT "Shibboleth-TRANSACTION"
58 #define ADFS_L(s) adfs::XML::Literals::s
59
60 namespace adfs {
61
62     extern shibtarget::IListener* g_MemoryListener;
63
64     class XML
65     {
66     public:
67         // URI constants
68         static const XMLCh WSFED_NS[];          // http://schemas.xmlsoap.org/ws/2003/07/secext
69         static const XMLCh WSTRUST_NS[];        // http://schemas.xmlsoap.org/ws/2005/02/trust
70         static const XMLCh WSTRUST_SCHEMA_ID[];
71         
72         struct Literals
73         {
74             static const XMLCh RequestedSecurityToken[];
75             static const XMLCh RequestSecurityTokenResponse[];
76         };
77     };
78
79     // TODO: Publish these classes for reuse by extensions.
80     class CgiParse
81     {
82     public:
83         CgiParse(const char* data, unsigned int len);
84         ~CgiParse();
85         const char* get_value(const char* name) const;
86         
87         static char x2c(char *what);
88         static void url_decode(char *url);
89         static std::string url_encode(const char* s);
90     private:
91         char * fmakeword(char stop, unsigned int *cl, const char** ppch);
92         char * makeword(char *line, char stop);
93         void plustospace(char *str);
94     
95         std::map<std::string,char*> kvp_map;
96     };
97
98     // Helper class for SAML 2.0 Common Domain Cookie operations
99     class CommonDomainCookie
100     {
101     public:
102         CommonDomainCookie(const char* cookie);
103         ~CommonDomainCookie() {}
104         saml::Iterator<std::string> get() {return m_list;}
105         const char* set(const char* providerId);
106         static const char CDCName[];
107     private:
108         std::string m_encoded;
109         std::vector<std::string> m_list;
110     };
111     
112     saml::SAMLAuthenticationStatement* checkAssertionProfile(const saml::SAMLAssertion* a);
113 }
114
115 #endif