Remove xmlproviders from build, deleted old AAP interface.
[shibboleth/cpp-sp.git] / shib / shib.h
1 /*
2  *  Copyright 2001-2007 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 /* shib.h - Shibboleth header file
18
19    Scott Cantor
20    6/4/02
21
22    $History:$
23 */
24
25 #ifndef __shib_h__
26 #define __shib_h__
27
28 #include <saml/saml2/metadata/Metadata.h>
29 #include <saml/saml2/metadata/MetadataProvider.h>
30 #include <xmltooling/security/TrustEngine.h>
31
32 #include <saml/saml.h>
33 #undef SAML10_PROTOCOL_ENUM
34
35 #ifdef WIN32
36 # ifndef SHIB_EXPORTS
37 #  define SHIB_EXPORTS __declspec(dllimport)
38 # endif
39 #else
40 # define SHIB_EXPORTS
41 #endif
42
43 namespace shibboleth
44 {
45     struct SHIB_EXPORTS IAttributeFactory : public virtual saml::IPlugIn
46     {
47         virtual saml::SAMLAttribute* build(DOMElement* e) const=0;
48         virtual ~IAttributeFactory() {}
49     };
50
51     // Subclass around the OpenSAML browser profile interface,
52     // incoporates additional functionality using Shib-defined APIs.
53     class SHIB_EXPORTS ShibBrowserProfile : virtual public saml::SAMLBrowserProfile
54     {
55     public:
56         struct SHIB_EXPORTS ITokenValidator {
57             virtual void validateToken(
58                 saml::SAMLAssertion* token,
59                 time_t=0,
60                 const opensaml::saml2md::RoleDescriptor* role=NULL,
61                 const xmltooling::TrustEngine* trustEngine=NULL
62                 ) const=0;
63             virtual ~ITokenValidator() {}
64         };
65
66         ShibBrowserProfile(
67             const ITokenValidator* validator,
68             opensaml::saml2md::MetadataProvider* metadata=NULL,
69             xmltooling::TrustEngine* trust=NULL
70             );
71         virtual ~ShibBrowserProfile();
72
73         virtual saml::SAMLBrowserProfile::BrowserProfileResponse receive(
74             const char* samlResponse,
75             const XMLCh* recipient,
76             saml::IReplayCache* replayCache,
77             int minorVersion=1
78             ) const;
79         virtual saml::SAMLBrowserProfile::BrowserProfileResponse receive(
80             saml::Iterator<const char*> artifacts,
81             const XMLCh* recipient,
82             saml::SAMLBrowserProfile::ArtifactMapper* artifactMapper,
83             saml::IReplayCache* replayCache,
84             int minorVersion=1
85             ) const;
86
87     private:
88         void postprocess(saml::SAMLBrowserProfile::BrowserProfileResponse& bpr, int minorVersion=1) const;
89
90         saml::SAMLBrowserProfile* m_profile;
91         opensaml::saml2md::MetadataProvider* m_metadata;
92         xmltooling::TrustEngine* m_trust;
93         const ITokenValidator* m_validator;
94     };
95
96     class SHIB_EXPORTS ShibConfig
97     {
98     public:
99         ShibConfig() {}
100         virtual ~ShibConfig() {}
101
102         // global per-process setup and shutdown of Shibboleth runtime
103         virtual bool init();
104         virtual void term();
105
106         // manages specific attribute name to factory mappings
107         void regAttributeMapping(const XMLCh* name, const IAttributeFactory* factory);
108         void unregAttributeMapping(const XMLCh* name);
109         void clearAttributeMappings();
110
111         // enables runtime and clients to access configuration
112         static ShibConfig& getConfig();
113     };
114 }
115
116 #endif