2 * Copyright 2001-2007 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /* shib.h - Shibboleth header file
28 #include <saml/saml2/metadata/Metadata.h>
29 #include <saml/saml2/metadata/MetadataProvider.h>
30 #include <xmltooling/security/TrustEngine.h>
32 #include <saml/saml.h>
33 #undef SAML10_PROTOCOL_ENUM
37 # define SHIB_EXPORTS __declspec(dllimport)
45 // Attribute acceptance processing interfaces, applied to incoming attributes.
47 struct SHIB_EXPORTS IAttributeRule
49 virtual const XMLCh* getName() const=0;
50 virtual const XMLCh* getNamespace() const=0;
51 virtual const char* getAlias() const=0;
52 virtual const char* getHeader() const=0;
53 virtual bool getCaseSensitive() const=0;
54 virtual void apply(saml::SAMLAttribute& attribute, const opensaml::saml2md::RoleDescriptor* role=NULL) const=0;
55 virtual ~IAttributeRule() {}
58 struct SHIB_EXPORTS IAAP : public virtual xmltooling::Lockable, public virtual saml::IPlugIn
60 virtual bool anyAttribute() const=0;
61 virtual const IAttributeRule* lookup(const XMLCh* attrName, const XMLCh* attrNamespace=NULL) const=0;
62 virtual const IAttributeRule* lookup(const char* alias) const=0;
63 virtual saml::Iterator<const IAttributeRule*> getAttributeRules() const=0;
67 struct SHIB_EXPORTS IAttributeFactory : public virtual saml::IPlugIn
69 virtual saml::SAMLAttribute* build(DOMElement* e) const=0;
70 virtual ~IAttributeFactory() {}
73 #ifdef SHIB_INSTANTIATE
74 template class SHIB_EXPORTS saml::Iterator<IAAP*>;
75 template class SHIB_EXPORTS saml::ArrayIterator<IAAP*>;
78 class SHIB_EXPORTS AAP
81 AAP(const saml::Iterator<IAAP*>& aaps, const XMLCh* attrName, const XMLCh* attrNamespace=NULL);
82 AAP(const saml::Iterator<IAAP*>& aaps, const char* alias);
84 bool fail() const {return m_mapper==NULL;}
85 const IAttributeRule* operator->() const {return m_rule;}
86 operator const IAttributeRule*() const {return m_rule;}
89 const saml::Iterator<IAAP*>& aaps, saml::SAMLAssertion& assertion, const opensaml::saml2md::RoleDescriptor* role=NULL
94 void operator=(const AAP&);
96 const IAttributeRule* m_rule;
99 // Subclass around the OpenSAML browser profile interface,
100 // incoporates additional functionality using Shib-defined APIs.
101 class SHIB_EXPORTS ShibBrowserProfile : virtual public saml::SAMLBrowserProfile
104 struct SHIB_EXPORTS ITokenValidator {
105 virtual void validateToken(
106 saml::SAMLAssertion* token,
108 const opensaml::saml2md::RoleDescriptor* role=NULL,
109 const xmltooling::TrustEngine* trustEngine=NULL
111 virtual ~ITokenValidator() {}
115 const ITokenValidator* validator,
116 opensaml::saml2md::MetadataProvider* metadata=NULL,
117 xmltooling::TrustEngine* trust=NULL
119 virtual ~ShibBrowserProfile();
121 virtual saml::SAMLBrowserProfile::BrowserProfileResponse receive(
122 const char* samlResponse,
123 const XMLCh* recipient,
124 saml::IReplayCache* replayCache,
127 virtual saml::SAMLBrowserProfile::BrowserProfileResponse receive(
128 saml::Iterator<const char*> artifacts,
129 const XMLCh* recipient,
130 saml::SAMLBrowserProfile::ArtifactMapper* artifactMapper,
131 saml::IReplayCache* replayCache,
136 void postprocess(saml::SAMLBrowserProfile::BrowserProfileResponse& bpr, int minorVersion=1) const;
138 saml::SAMLBrowserProfile* m_profile;
139 opensaml::saml2md::MetadataProvider* m_metadata;
140 xmltooling::TrustEngine* m_trust;
141 const ITokenValidator* m_validator;
144 class SHIB_EXPORTS ShibConfig
148 virtual ~ShibConfig() {}
150 // global per-process setup and shutdown of Shibboleth runtime
154 // manages specific attribute name to factory mappings
155 void regAttributeMapping(const XMLCh* name, const IAttributeFactory* factory);
156 void unregAttributeMapping(const XMLCh* name);
157 void clearAttributeMappings();
159 // enables runtime and clients to access configuration
160 static ShibConfig& getConfig();