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
60 using namespace shibboleth;
64 const IProvider* Metadata::lookup(const XMLCh* providerId)
70 const IProvider* ret=NULL;
72 while (m_metadatas.hasNext()) {
73 IMetadata* i=m_metadatas.next();
75 if (ret=i->lookup(providerId)) {
90 Iterator<void*> Revocation::getRevocationLists(const IProvider* provider, const IProviderRole* role)
96 m_revocations.reset();
97 while (m_revocations.hasNext()) {
98 IRevocation* i=m_revocations.next();
100 Iterator<void*> ret=i->getRevocationLists(provider,role);
110 Revocation::~Revocation()
116 bool Trust::validate(
117 const Iterator<IRevocation*>& revocations,
118 const IProviderRole* role, const SAMLSignedObject& token,
119 const Iterator<IMetadata*>& metadatas) const
122 while (m_trusts.hasNext()) {
123 if (m_trusts.next()->validate(revocations,role,token,metadatas))
129 bool Trust::attach(const Iterator<IRevocation*>& revocations, const IProviderRole* role, void* ctx) const
132 while (m_trusts.hasNext()) {
133 if (m_trusts.next()->attach(revocations,role,ctx))
139 const ICredResolver* Credentials::lookup(const char* id)
145 const ICredResolver* ret=NULL;
147 while (m_creds.hasNext()) {
148 ICredentials* i=m_creds.next();
150 if (ret=i->lookup(id)) {
159 Credentials::~Credentials()
165 AAP::AAP(const saml::Iterator<IAAP*>& aaps, const XMLCh* attrName, const XMLCh* attrNamespace) : m_mapper(NULL), m_rule(NULL)
168 while (aaps.hasNext()) {
171 if (m_rule=i->lookup(attrName,attrNamespace)) {
179 AAP::AAP(const saml::Iterator<IAAP*>& aaps, const char* alias) : m_mapper(NULL), m_rule(NULL)
182 while (aaps.hasNext()) {
185 if (m_rule=i->lookup(alias)) {
199 void AAP::apply(const saml::Iterator<IAAP*>& aaps, const IProvider* originSite, saml::SAMLAssertion& assertion)
202 log4cpp::Category& log=log4cpp::Category::getInstance(SHIB_LOGCAT".AAP");
204 // First check for no providers or AnyAttribute.
205 if (aaps.size()==0) {
206 log.debug("no filters specified, accepting entire assertion");
210 while (aaps.hasNext()) {
211 if (aaps.next()->anyAttribute()) {
212 log.debug("any attribute enabled, accepting entire assertion");
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();