New plugin implementations of Shibboleth APIs
[shibboleth/sp.git] / xmlproviders / internal.h
1 /*
2  * The Shibboleth License, Version 1.
3  * Copyright (c) 2002
4  * University Corporation for Advanced Internet Development, Inc.
5  * All rights reserved
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution, if any, must include
17  * the following acknowledgment: "This product includes software developed by
18  * the University Corporation for Advanced Internet Development
19  * <http://www.ucaid.edu>Internet2 Project. Alternately, this acknowledegement
20  * may appear in the software itself, if and wherever such third-party
21  * acknowledgments normally appear.
22  *
23  * Neither the name of Shibboleth nor the names of its contributors, nor
24  * Internet2, nor the University Corporation for Advanced Internet Development,
25  * Inc., nor UCAID may be used to endorse or promote products derived from this
26  * software without specific prior written permission. For written permission,
27  * please contact shibboleth@shibboleth.org
28  *
29  * Products derived from this software may not be called Shibboleth, Internet2,
30  * UCAID, or the University Corporation for Advanced Internet Development, nor
31  * may Shibboleth appear in their name, without prior written permission of the
32  * University Corporation for Advanced Internet Development.
33  *
34  *
35  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36  * AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
38  * PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED AND THE ENTIRE RISK
39  * OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE.
40  * IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY
41  * CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC. BE LIABLE FOR ANY DIRECT,
42  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48  */
49
50
51 /* internal.h
52
53    Scott Cantor
54    2/14/04
55
56    $History:$
57 */
58
59 #ifndef __internal_h__
60 #define __internal_h__
61
62 #include <saml/saml.h>
63 #include <shib/shib.h>
64 #include <shib/shib-threads.h>
65 #include <openssl/ssl.h>
66
67 #define XMLPROVIDERS_LOGCAT "XMLProviders"
68
69 #define SHIB_L(s) ::XML::Literals::s
70 #define SHIB_L_QNAME(p,s) ::XML::Literals::p##_##s
71
72 // direct OpenSSL error content to log4cpp
73 void log_openssl();
74
75 // build an OpenSSL object out of a base-64 encoded DER buffer (XML style)
76 X509_CRL* B64_to_CRL(const char* buf);
77 X509* B64_to_X509(const char* buf);
78    
79 class ScopedAttribute : public saml::SAMLAttribute
80 {
81 public:
82     ScopedAttribute(const XMLCh* name, const XMLCh* ns, long lifetime=0,
83                     const saml::Iterator<const XMLCh*>& scopes=EMPTY(const XMLCh*),
84                     const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*));
85     ScopedAttribute(DOMElement* e);
86     virtual ~ScopedAttribute();
87
88     virtual saml::SAMLObject* clone() const;
89     
90     virtual saml::Iterator<const XMLCh*> getValues() const;
91     virtual saml::Iterator<std::string> getSingleByteValues() const;
92     virtual void setValues(const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*));
93     virtual void addValue(const XMLCh* value);
94     virtual void removeValue(unsigned int index);
95     
96 protected:
97     virtual void valueToDOM(unsigned int index, DOMElement* e) const;
98     
99     const XMLCh* m_originSite;
100     std::vector<const XMLCh*> m_scopes;
101     mutable std::vector<const XMLCh*> m_scopedValues;
102 };
103     
104 class XML
105 {
106 public:
107         // URI constants
108     static const XMLCh SHIB_NS[];
109     static const XMLCh SHIB_SCHEMA_ID[];
110     static const XMLCh CREDS_NS[];
111     static const XMLCh CREDS_SCHEMA_ID[];
112     static const XMLCh TRUST_NS[];
113     static const XMLCh TRUST_SCHEMA_ID[];
114     
115     // ds:KeyInfo RetrievalMethods
116     static const XMLCh XMLSIG_RETMETHOD_RAWX509[];  // http://www.w3.org/2000/09/xmldsig#rawX509Certificate
117     static const XMLCh XMLSIG_RETMETHOD_RAWX509CRL[]; // http://www.w3.org/2000/09/xmldsig-more#rawX509CRL
118     static const XMLCh SHIB_RETMETHOD_PEMX509[];    // urn:mace:shibboleth:RetrievalMethod:pemX509Certificate
119     static const XMLCh SHIB_RETMETHOD_PEMX509CRL[]; // urn:mace:shibboleth:RetrievalMethod:pemX509CRL
120
121     struct Literals
122     {
123         static const XMLCh AttributeAuthority[];
124         static const XMLCh Contact[];
125         static const XMLCh Domain[];
126         static const XMLCh Email[];
127         static const XMLCh ErrorURL[];
128         static const XMLCh HandleService[];
129         static const XMLCh InvalidHandle[];
130         static const XMLCh Location[];
131         static const XMLCh Name[];
132         static const XMLCh OriginSite[];
133         static const XMLCh SiteGroup[];
134
135         static const XMLCh administrative[];
136         static const XMLCh billing[];
137         static const XMLCh other[];
138         static const XMLCh support[];
139         static const XMLCh technical[];
140
141         // credentials constants
142         static const XMLCh CAPath[];
143         static const XMLCh Class[];
144         static const XMLCh Credentials[];
145         static const XMLCh CustomResolver[];
146         static const XMLCh FileResolver[];
147         static const XMLCh format[];
148         static const XMLCh Id[];
149         static const XMLCh password[];
150         static const XMLCh Path[];
151         
152         static const XMLCh Exponent[];
153         static const XMLCh KeyAuthority[];
154         static const XMLCh KeyName[];
155         static const XMLCh Modulus[];
156         static const XMLCh RetrievalMethod[];
157         static const XMLCh RSAKeyValue[];
158         static const XMLCh Trust[];
159         static const XMLCh URI[];
160         static const XMLCh VerifyDepth[];
161         static const XMLCh X509CRL[];
162
163         static const XMLCh Scope[];
164
165         static const XMLCh Accept[];
166         static const XMLCh Alias[];
167         static const XMLCh AnySite[];
168         static const XMLCh AnyValue[];
169         static const XMLCh AttributeAcceptancePolicy[];
170         static const XMLCh AttributeRule[];
171         static const XMLCh Factory[];
172         static const XMLCh Header[];
173         static const XMLCh Namespace[];
174         static const XMLCh SiteRule[];
175         static const XMLCh Type[];
176         static const XMLCh Value[];
177
178         static const XMLCh literal[];
179         static const XMLCh regexp[];
180         static const XMLCh xpath[];
181
182         static const XMLCh url[];
183     };
184 };
185
186 #endif