1124fd6e809dc7133762d04df1f18a8180830f75
[shibboleth/cpp-sp.git] / shib / 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 - internally visible classes
18
19    Scott Cantor
20    9/6/02
21
22    $History:$
23 */
24
25 #ifndef __shib_internal_h__
26 #define __shib_internal_h__
27
28 #ifdef WIN32
29 # define _CRT_NONSTDC_NO_DEPRECATE 1
30 # define _CRT_SECURE_NO_DEPRECATE 1
31 # define SHIB_EXPORTS __declspec(dllexport)
32 #endif
33
34 // eventually we might be able to support autoconf via cygwin...
35 #if defined (_MSC_VER) || defined(__BORLANDC__)
36 # include "config_win32.h"
37 #else
38 # include "config.h"
39 #endif
40
41 #include "shib.h"
42
43 #include <log4cpp/Category.hh>
44
45 #define SHIB_LOGCAT "Shibboleth"
46
47 namespace shibboleth {
48     class BasicTrust : public ITrust
49     {
50     public:
51         BasicTrust(const DOMElement* e);
52         ~BasicTrust();
53
54         bool validate(void* certEE, const saml::Iterator<void*>& certChain, const IRoleDescriptor* role, bool checkName=true);
55         bool validate(const saml::SAMLSignedObject& token, const IRoleDescriptor* role, ITrust* certValidator=NULL);
56     
57     protected:
58         std::vector<saml::KeyInfoResolver*> m_resolvers;
59     };
60
61     class ScopedAttribute : public saml::SAMLAttribute
62     {
63     public:
64         ScopedAttribute(
65             const XMLCh* name=NULL,
66             const XMLCh* ns=NULL,
67             const saml::QName* type=NULL,
68             long lifetime=0,
69             const saml::Iterator<const XMLCh*>& scopes=EMPTY(const XMLCh*),
70             const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*)
71             );
72         ScopedAttribute(DOMElement* e);
73         ScopedAttribute(std::istream& in);
74         ~ScopedAttribute();
75     
76         saml::SAMLObject* clone() const;
77         
78         saml::Iterator<const XMLCh*> getValues() const;
79         saml::Iterator<std::string> getSingleByteValues() const;
80         void setValues(const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*));
81         void addValue(const XMLCh* value);
82         void removeValue(unsigned long index);
83         
84         static const XMLCh Scope[];
85     protected:
86         void valueToDOM(unsigned int index, DOMElement* e) const;
87         void valueFromDOM(DOMElement* e);
88         void ownStrings();
89         
90         std::vector<const XMLCh*> m_scopes;
91         mutable std::vector<const XMLCh*> m_scopedValues;
92     };
93 }
94
95 #endif