2 * The Shibboleth License, Version 1.
4 * University Corporation for Advanced Internet Development, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice, this
12 * list of conditions and the following disclaimer.
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.
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
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.
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.
51 /* shib.h - Shibboleth header file
63 #include <saml/saml.h>
67 # define SHIB_EXPORTS __declspec(dllimport)
76 extern SHIB_EXPORTS const unsigned short RTTI_UnsupportedProtocolException;
77 extern SHIB_EXPORTS const unsigned short RTTI_OriginSiteMapperException;
80 #define DECLARE_SHIB_EXCEPTION(name,base) \
81 class SHIB_EXPORTS name : public saml::base \
84 name(const char* msg) : saml::base(msg) {RTTI(name); m_typename=#name;} \
85 name(const std::string& msg) : saml::base(msg) {RTTI(name); m_typename=#name;} \
86 name(const saml::Iterator<saml::QName>& codes, const char* msg) : saml::base(codes,msg) {RTTI(name); m_typename=#name;} \
87 name(const saml::Iterator<saml::QName>& codes, const std::string& msg) : saml::base(codes, msg) {RTTI(name); m_typename=#name;} \
88 name(const saml::QName& code, const char* msg) : saml::base(code,msg) {RTTI(name); m_typename=#name;} \
89 name(const saml::QName& code, const std::string& msg) : saml::base(code, msg) {RTTI(name); m_typename=#name;} \
90 name(DOMElement* e) : saml::base(e) {RTTI(name); m_typename=#name;} \
91 name(std::istream& in) : saml::base(in) {RTTI(name); m_typename=#name;} \
92 virtual ~name() throw () {} \
95 DECLARE_SHIB_EXCEPTION(UnsupportedProtocolException,SAMLException);
96 DECLARE_SHIB_EXCEPTION(OriginSiteMapperException,SAMLException);
98 #ifdef SHIB_INSTANTIATE
100 const unsigned short RTTI_UnsupportedProtocolException= RTTI_EXTENSION_BASE;
101 const unsigned short RTTI_OriginSiteMapperException= RTTI_EXTENSION_BASE+1;
103 template class SHIB_EXPORTS saml::Iterator<std::pair<saml::xstring,bool> >;
104 template class SHIB_EXPORTS saml::ArrayIterator<std::pair<saml::xstring,bool> >;
107 struct SHIB_EXPORTS IOriginSiteMapper
109 virtual saml::Iterator<saml::xstring> getHandleServiceNames(const XMLCh* originSite)=0;
110 virtual const saml::X509Certificate* getHandleServiceCert(const XMLCh* handleService)=0;
111 virtual saml::Iterator<std::pair<saml::xstring,bool> > getSecurityDomains(const XMLCh* originSite)=0;
112 virtual const char* getTrustedRoots()=0;
115 class SHIB_EXPORTS OriginSiteMapper : public IOriginSiteMapper
120 virtual saml::Iterator<saml::xstring> getHandleServiceNames(const XMLCh* originSite);
121 virtual const saml::X509Certificate* getHandleServiceCert(const XMLCh* handleService);
122 virtual saml::Iterator<std::pair<saml::xstring,bool> > getSecurityDomains(const XMLCh* originSite);
123 virtual const char* getTrustedRoots();
126 OriginSiteMapper(const OriginSiteMapper&);
127 void operator=(const OriginSiteMapper&);
128 IOriginSiteMapper* m_mapper;
131 class SHIB_EXPORTS ShibPOSTProfile
134 ShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* receiver, int ttlSeconds);
135 ShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* issuer);
136 virtual ~ShibPOSTProfile();
138 virtual saml::SAMLAssertion* getSSOAssertion(const saml::SAMLResponse& r);
139 virtual saml::SAMLAuthenticationStatement* getSSOStatement(const saml::SAMLAssertion& a);
140 virtual saml::SAMLResponse* accept(const XMLByte* buf);
141 virtual saml::SAMLResponse* prepare(const XMLCh* recipient,
143 const XMLCh* nameQualifier,
144 const XMLCh* subjectIP,
145 const XMLCh* authMethod,
147 const saml::Iterator<saml::SAMLAuthorityBinding*>& bindings,
148 const saml::Key& responseKey, const saml::X509Certificate* responseCert=NULL,
149 const saml::Key* assertionKey=NULL, const saml::X509Certificate* assertionCert=NULL);
150 virtual bool checkReplayCache(const saml::SAMLAssertion& a);
153 virtual void verifySignature(const saml::SAMLSignedObject& obj, const XMLCh* signerName, const saml::X509Certificate* knownKey);
155 saml::SAMLSignedObject::sigs_t m_algorithm;
156 std::vector<const XMLCh*> m_policies;
162 ShibPOSTProfile(const ShibPOSTProfile&) {}
163 ShibPOSTProfile& operator=(const ShibPOSTProfile&) {return *this;}
166 class SHIB_EXPORTS ClubShibPOSTProfile : public ShibPOSTProfile
169 ClubShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* receiver, int ttlSeconds);
170 ClubShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* issuer);
171 virtual ~ClubShibPOSTProfile();
173 virtual saml::SAMLResponse* prepare(const XMLCh* recipient,
175 const XMLCh* nameQualifier,
176 const XMLCh* subjectIP,
177 const XMLCh* authMethod,
179 const saml::Iterator<saml::SAMLAuthorityBinding*>& bindings,
180 const saml::Key& responseKey, const saml::X509Certificate* responseCert=NULL,
181 const saml::Key* assertionKey=NULL, const saml::X509Certificate* assertionCert=NULL);
184 virtual void verifySignature(const saml::SAMLSignedObject& obj, const XMLCh* signerName, const saml::X509Certificate* knownKey);
187 class SHIB_EXPORTS ShibPOSTProfileFactory
190 static ShibPOSTProfile* getInstance(const saml::Iterator<const XMLCh*>& policies, const XMLCh* receiver, int ttlSeconds);
191 static ShibPOSTProfile* getInstance(const saml::Iterator<const XMLCh*>& policies, const XMLCh* issuer);
194 class SHIB_EXPORTS ShibConfig
197 ShibConfig() : mapperCert(NULL), mapperRefreshInterval(0) {}
198 virtual ~ShibConfig();
200 // global per-process setup and shutdown of Shibboleth runtime
201 virtual bool init()=0;
202 virtual void term()=0;
204 // enables runtime and clients to access configuration
205 static ShibConfig& getConfig();
207 virtual IOriginSiteMapper* getMapper()=0;
208 virtual void releaseMapper(IOriginSiteMapper* mapper)=0;
210 /* start of external configuration */
211 std::string mapperURL;
212 saml::X509Certificate* mapperCert;
213 time_t mapperRefreshInterval;
214 /* end of external configuration */
217 struct SHIB_EXPORTS Constants
219 static const XMLCh POLICY_INCOMMON[];
220 static const XMLCh SHIB_ATTRIBUTE_NAMESPACE_URI[];
223 class SHIB_EXPORTS XML
227 static const XMLCh SHIB_NS[];
228 static const XMLCh SHIB_SCHEMA_ID[];
230 struct SHIB_EXPORTS Literals
232 // Shibboleth vocabulary
233 static const XMLCh Domain[];
234 static const XMLCh HandleService[];
235 static const XMLCh InvalidHandle[];
236 static const XMLCh Name[];
237 static const XMLCh OriginSite[];
238 static const XMLCh regexp[];
239 static const XMLCh Sites[];
242 static const XMLCh xmlns_shib[];
247 class SHIB_EXPORTS SAMLBindingFactory
250 static saml::SAMLBinding* getInstance(const XMLCh* protocol=saml::SAMLBinding::SAML_SOAP_HTTPS);