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 const char* getContactName(const XMLCh* originSite) const=0;
110 virtual const char* getContactEmail(const XMLCh* originSite) const=0;
111 virtual const char* getErrorURL(const XMLCh* originSite) const=0;
112 virtual saml::Iterator<saml::xstring> getHandleServiceNames(const XMLCh* originSite) const=0;
113 virtual XSECCryptoX509* getHandleServiceCert(const XMLCh* handleService) const=0;
114 virtual saml::Iterator<std::pair<saml::xstring,bool> > getSecurityDomains(const XMLCh* originSite) const=0;
115 virtual time_t getTimestamp() const=0;
118 class SHIB_EXPORTS OriginSiteMapper : public IOriginSiteMapper
123 virtual const char* getContactName(const XMLCh* originSite) const;
124 virtual const char* getContactEmail(const XMLCh* originSite) const;
125 virtual const char* getErrorURL(const XMLCh* originSite) const;
126 virtual saml::Iterator<saml::xstring> getHandleServiceNames(const XMLCh* originSite) const;
127 virtual XSECCryptoX509* getHandleServiceCert(const XMLCh* handleService) const;
128 virtual saml::Iterator<std::pair<saml::xstring,bool> > getSecurityDomains(const XMLCh* originSite) const;
129 virtual time_t getTimestamp() const;
132 OriginSiteMapper(const OriginSiteMapper&);
133 void operator=(const OriginSiteMapper&);
134 IOriginSiteMapper* m_mapper;
137 class SHIB_EXPORTS SimpleAttribute : public saml::SAMLAttribute
140 SimpleAttribute(const XMLCh* name, const XMLCh* ns, long lifetime=0,
141 const saml::Iterator<const XMLCh*>& values=saml::Iterator<const XMLCh*>());
142 SimpleAttribute(DOMElement* e);
143 virtual saml::SAMLObject* clone() const;
144 virtual ~SimpleAttribute();
147 virtual bool accept(DOMElement* e) const;
149 saml::xstring m_originSite;
152 class SHIB_EXPORTS ScopedAttribute : public SimpleAttribute
155 ScopedAttribute(const XMLCh* name, const XMLCh* ns, long lifetime=0,
156 const saml::Iterator<const XMLCh*>& scopes=saml::Iterator<const XMLCh*>(),
157 const saml::Iterator<const XMLCh*>& values=saml::Iterator<const XMLCh*>());
158 ScopedAttribute(DOMElement* e);
159 virtual ~ScopedAttribute();
161 virtual DOMNode* toDOM(DOMDocument* doc=NULL, bool xmlns=true) const;
162 virtual saml::SAMLObject* clone() const;
164 virtual saml::Iterator<saml::xstring> getValues() const;
165 virtual saml::Iterator<std::string> getSingleByteValues() const;
167 static const XMLCh Scope[];
170 virtual bool accept(DOMElement* e) const;
171 virtual bool addValue(DOMElement* e);
173 std::vector<saml::xstring> m_scopes;
174 mutable std::vector<saml::xstring> m_scopedValues;
177 class SHIB_EXPORTS ShibPOSTProfile
180 ShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* receiver, int ttlSeconds);
181 ShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* issuer);
182 virtual ~ShibPOSTProfile();
184 virtual saml::SAMLAssertion* getSSOAssertion(const saml::SAMLResponse& r);
185 virtual saml::SAMLAuthenticationStatement* getSSOStatement(const saml::SAMLAssertion& a);
186 virtual saml::SAMLResponse* accept(const XMLByte* buf);
187 virtual saml::SAMLResponse* prepare(
188 const XMLCh* recipient,
190 const XMLCh* nameQualifier,
191 const XMLCh* subjectIP,
192 const XMLCh* authMethod,
194 const saml::Iterator<saml::SAMLAuthorityBinding*>& bindings,
195 XSECCryptoKey* responseKey,
196 const saml::Iterator<XSECCryptoX509*>& responseCerts=saml::Iterator<XSECCryptoX509*>(),
197 XSECCryptoKey* assertionKey=NULL,
198 const saml::Iterator<XSECCryptoX509*>& assertionCerts=saml::Iterator<XSECCryptoX509*>()
200 virtual bool checkReplayCache(const saml::SAMLAssertion& a);
203 virtual void verifySignature(const saml::SAMLSignedObject& obj, const XMLCh* signerName, XSECCryptoKey* knownKey);
205 signatureMethod m_algorithm;
206 std::vector<const XMLCh*> m_policies;
212 ShibPOSTProfile(const ShibPOSTProfile&) {}
213 ShibPOSTProfile& operator=(const ShibPOSTProfile&) {return *this;}
216 class SHIB_EXPORTS ClubShibPOSTProfile : public ShibPOSTProfile
219 ClubShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* receiver, int ttlSeconds);
220 ClubShibPOSTProfile(const saml::Iterator<const XMLCh*>& policies, const XMLCh* issuer);
221 virtual ~ClubShibPOSTProfile();
223 virtual saml::SAMLResponse* prepare(
224 const XMLCh* recipient,
226 const XMLCh* nameQualifier,
227 const XMLCh* subjectIP,
228 const XMLCh* authMethod,
230 const saml::Iterator<saml::SAMLAuthorityBinding*>& bindings,
231 XSECCryptoKey* responseKey,
232 const saml::Iterator<XSECCryptoX509*>& responseCerts=saml::Iterator<XSECCryptoX509*>(),
233 XSECCryptoKey* assertionKey=NULL,
234 const saml::Iterator<XSECCryptoX509*>& assertionCerts=saml::Iterator<XSECCryptoX509*>()
238 virtual void verifySignature(const saml::SAMLSignedObject& obj, const XMLCh* signerName, XSECCryptoKey* knownKey);
241 class SHIB_EXPORTS ShibPOSTProfileFactory
244 static ShibPOSTProfile* getInstance(const saml::Iterator<const XMLCh*>& policies, const XMLCh* receiver, int ttlSeconds);
245 static ShibPOSTProfile* getInstance(const saml::Iterator<const XMLCh*>& policies, const XMLCh* issuer);
248 class SHIB_EXPORTS ShibConfig
252 virtual ~ShibConfig();
254 // global per-process setup and shutdown of Shibboleth runtime
255 virtual bool init()=0;
256 virtual void term()=0;
258 // enables runtime and clients to access configuration
259 static ShibConfig& getConfig();
261 virtual IOriginSiteMapper* getMapper()=0;
262 virtual void releaseMapper(IOriginSiteMapper* mapper)=0;
264 /* start of external configuration */
266 std::string mapperFile;
267 /* end of external configuration */
270 struct SHIB_EXPORTS Constants
272 static const XMLCh POLICY_INCOMMON[];
273 static const XMLCh SHIB_ATTRIBUTE_NAMESPACE_URI[];
274 static const XMLCh SHIB_NAMEID_FORMAT_URI[];
275 static saml::QName SHIB_ATTRIBUTE_VALUE_TYPE;
278 class SHIB_EXPORTS XML
282 static const XMLCh SHIB_NS[];
283 static const XMLCh SHIB_SCHEMA_ID[];
285 struct SHIB_EXPORTS Literals
287 // Shibboleth vocabulary
288 static const XMLCh AttributeValueType[];
290 static const XMLCh ContactEmail[];
291 static const XMLCh ContactName[];
292 static const XMLCh Domain[];
293 static const XMLCh ErrorURL[];
294 static const XMLCh HandleService[];
295 static const XMLCh InvalidHandle[];
296 static const XMLCh Name[];
297 static const XMLCh OriginSite[];
298 static const XMLCh Sites[];
300 static const XMLCh AnySite[];
301 static const XMLCh AttributeAcceptancePolicy[];
302 static const XMLCh AttributeRule[];
303 static const XMLCh SiteRule[];
304 static const XMLCh Type[];
305 static const XMLCh Value[];
307 static const XMLCh literal[];
308 static const XMLCh regexp[];
309 static const XMLCh xpath[];
312 static const XMLCh xmlns_shib[];
317 class SHIB_EXPORTS SAMLBindingFactory
320 static saml::SAMLBinding* getInstance(const XMLCh* protocol=saml::SAMLBinding::SAML_SOAP_HTTPS);