1 /**
2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
6 *
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
10 * License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
19 */
20
21 /**
22 * BasicFilteringContext.cpp
23 *
24 * A trivial FilteringContext implementation.
25 */
26
27 #include "internal.h"
28 #include "Application.h"
29 #include "attribute/Attribute.h"
30 #include "attribute/filtering/BasicFilteringContext.h"
31
32 #include <saml/saml2/metadata/Metadata.h>
33
34 using namespace shibsp;
35 using namespace opensaml::saml2md;
36 using namespace std;
37
FilteringContext()38 FilteringContext::FilteringContext()
39 {
40 }
41
~FilteringContext()42 FilteringContext::~FilteringContext()
43 {
44 }
45
BasicFilteringContext(const Application & app,const vector<Attribute * > & attributes,const RoleDescriptor * role,const XMLCh * authncontext_class,const XMLCh * authncontext_decl)46 BasicFilteringContext::BasicFilteringContext(
47 const Application& app,
48 const vector<Attribute*>& attributes,
49 const RoleDescriptor* role,
50 const XMLCh* authncontext_class,
51 const XMLCh* authncontext_decl
52 ) : m_app(app), m_role(role), m_issuer(nullptr), m_class(authncontext_class), m_decl(authncontext_decl)
53 {
54 if (role)
55 m_issuer = dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID();
56 for (vector<Attribute*>::const_iterator a = attributes.begin(); a != attributes.end(); ++a)
57 m_attributes.insert(multimap<string,Attribute*>::value_type((*a)->getId(), *a));
58 }
59
~BasicFilteringContext()60 BasicFilteringContext::~BasicFilteringContext()
61 {
62 }
63
getApplication() const64 const Application& BasicFilteringContext::getApplication() const
65 {
66 return m_app;
67 }
68
getAuthnContextClassRef() const69 const XMLCh* BasicFilteringContext::getAuthnContextClassRef() const
70 {
71 return m_class;
72 }
73
getAuthnContextDeclRef() const74 const XMLCh* BasicFilteringContext::getAuthnContextDeclRef() const
75 {
76 return m_decl;
77 }
78
getAttributeRequester() const79 const XMLCh* BasicFilteringContext::getAttributeRequester() const
80 {
81 if (getAttributeIssuerMetadata()) {
82 return getApplication().getRelyingParty(
83 dynamic_cast<const EntityDescriptor*>(getAttributeIssuerMetadata()->getParent())
84 )->getXMLString("entityID").second;
85 }
86 return getApplication().getRelyingParty(getAttributeIssuer())->getXMLString("entityID").second;
87 }
88
getAttributeIssuer() const89 const XMLCh* BasicFilteringContext::getAttributeIssuer() const
90 {
91 return m_issuer;
92 }
93
getAttributeRequesterMetadata() const94 const RoleDescriptor* BasicFilteringContext::getAttributeRequesterMetadata() const
95 {
96 return nullptr;
97 }
98
getAttributeIssuerMetadata() const99 const RoleDescriptor* BasicFilteringContext::getAttributeIssuerMetadata() const
100 {
101 return m_role;
102 }
103
getAttributes() const104 const multimap<string,Attribute*>& BasicFilteringContext::getAttributes() const
105 {
106 return m_attributes;
107 }
108