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.
50 /* Metadata.h - glue classes that interface to metadata providers
59 #include <log4cpp/Category.hh>
61 using namespace shibboleth;
65 OriginMetadata::OriginMetadata(const Iterator<IMetadata*>& metadatas, const XMLCh* site) : m_mapper(NULL), m_site(NULL)
68 while (metadatas.hasNext())
70 IMetadata* i=metadatas.next();
72 if (m_site=dynamic_cast<const IOriginSite*>(i->lookup(site)))
81 OriginMetadata::~OriginMetadata()
87 Iterator<XSECCryptoX509*> Trust::getCertificates(const XMLCh* subject)
96 while (m_trusts.hasNext())
98 ITrust* i=m_trusts.next();
100 Iterator<XSECCryptoX509*> iter=i->getCertificates(subject);
108 return EMPTY(XSECCryptoX509*);
111 bool Trust::validate(const ISite* site, Iterator<XSECCryptoX509*> certs) const
115 while (!ret && m_trusts.hasNext())
117 ITrust* i=m_trusts.next();
119 ret=i->validate(site,certs);
125 bool Trust::validate(const ISite* site, Iterator<const XMLCh*> certs) const
129 while (!ret && m_trusts.hasNext())
131 ITrust* i=m_trusts.next();
133 ret=i->validate(site,certs);
139 bool Trust::attach(const ISite* site, SSL_CTX* ctx) const
143 while (!ret && m_trusts.hasNext())
145 ITrust* i=m_trusts.next();
147 ret=i->attach(site,ctx);
159 bool Credentials::attach(const saml::Iterator<ICredentials*>& creds, const XMLCh* subject, const ISite* relyingParty, SSL_CTX* ctx)
163 while (!ret && creds.hasNext())
165 ICredentials* i=creds.next();
167 ret=i->attach(subject,relyingParty,ctx);
174 AAP::AAP(const saml::Iterator<IAAP*>& aaps, const XMLCh* attrName, const XMLCh* attrNamespace) : m_mapper(NULL), m_rule(NULL)
177 while (aaps.hasNext())
181 if (m_rule=i->lookup(attrName,attrNamespace))
190 AAP::AAP(const saml::Iterator<IAAP*>& aaps, const char* alias) : m_mapper(NULL), m_rule(NULL)
193 while (aaps.hasNext())
197 if (m_rule=i->lookup(alias))
212 void AAP::apply(const saml::Iterator<IAAP*>& aaps, const IOriginSite* originSite, saml::SAMLAssertion& assertion)
215 log4cpp::Category& log=log4cpp::Category::getInstance(SHIB_LOGCAT".AAP");
217 // Check each statement.
218 Iterator<SAMLStatement*> statements=assertion.getStatements();
219 for (unsigned int scount=0; scount < statements.size();) {
220 SAMLAttributeStatement* s=dynamic_cast<SAMLAttributeStatement*>(statements[scount]);
224 // Check each attribute.
225 Iterator<SAMLAttribute*> attrs=s->getAttributes();
226 for (unsigned int acount=0; acount < attrs.size();) {
227 SAMLAttribute* a=attrs[acount];
229 AAP rule(aaps,a->getName(),a->getNamespace());
231 if (log.isWarnEnabled()) {
232 auto_ptr_char temp(a->getName());
233 log.warn("no rule found for attribute (%s), filtering it out",temp.get());
235 s->removeAttribute(acount);
240 rule->apply(originSite,*a);
243 catch (SAMLException&) {
244 // The attribute is now defunct.
245 log.info("no values remain, removing attribute");
246 s->removeAttribute(acount);
254 catch (SAMLException&) {
255 // The statement is now defunct.
256 log.info("no attributes remain, removing statement");
257 assertion.removeStatement(scount);
261 // Now see if we trashed it irrevocably.
262 assertion.checkValidity();