8b5249a9aaffff9e0b0c1b97c20d73f3cfa1dcea
[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 #include <log4cpp/Category.hh>
34
35 #define ADFS_LOGCAT "shibtarget"
36 #define SHIBTRAN_LOGCAT "Shibboleth-TRANSACTION"
37 #define ADFS_L(s) adfs::XML::Literals::s
38
39 namespace adfs {
40
41     extern shibtarget::IListener* g_MemoryListener;
42
43     class XML
44     {
45     public:
46         // URI constants
47         static const XMLCh WSFED_NS[];          // http://schemas.xmlsoap.org/ws/2003/07/secext
48         static const XMLCh WSTRUST_NS[];        // http://schemas.xmlsoap.org/ws/2005/02/trust
49         static const XMLCh WSTRUST_SCHEMA_ID[];
50         
51         struct Literals
52         {
53             static const XMLCh RequestedSecurityToken[];
54             static const XMLCh RequestSecurityTokenResponse[];
55         };
56     };
57
58     // TODO: Publish these classes for reuse by extensions.
59     class CgiParse
60     {
61     public:
62         CgiParse(const char* data, unsigned int len);
63         ~CgiParse();
64         const char* get_value(const char* name) const;
65         
66         static char x2c(char *what);
67         static void url_decode(char *url);
68         static std::string url_encode(const char* s);
69     private:
70         char * fmakeword(char stop, unsigned int *cl, const char** ppch);
71         char * makeword(char *line, char stop);
72         void plustospace(char *str);
73     
74         std::map<std::string,char*> kvp_map;
75     };
76
77     // Helper class for SAML 2.0 Common Domain Cookie operations
78     class CommonDomainCookie
79     {
80     public:
81         CommonDomainCookie(const char* cookie);
82         ~CommonDomainCookie() {}
83         saml::Iterator<std::string> get() {return m_list;}
84         const char* set(const char* providerId);
85         static const char CDCName[];
86     private:
87         std::string m_encoded;
88         std::vector<std::string> m_list;
89     };
90     
91     saml::SAMLAuthenticationStatement* checkAssertionProfile(const saml::SAMLAssertion* a);
92 }
93
94 #endif