1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package edu.internet2.middleware.shibboleth.common.attribute.filtering.provider;
19
20 import java.util.Collection;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 import org.opensaml.xml.util.LazyList;
26
27 import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
28 import edu.internet2.middleware.shibboleth.common.profile.provider.SAMLProfileRequestContext;
29
30
31
32
33 public class ShibbolethFilteringContext {
34
35
36 private SAMLProfileRequestContext attributeRequestContext;
37
38
39 private Map<String, BaseAttribute> unfilteredAttributes;
40
41
42 private Map<String, Collection> retainedValues;
43
44
45 private Map<String, List<MatchFunctor>> denyValueRules;
46
47
48
49
50
51
52
53 public ShibbolethFilteringContext(Map<String, BaseAttribute> attributes, SAMLProfileRequestContext context) {
54 attributeRequestContext = context;
55 unfilteredAttributes = attributes;
56 retainedValues = new HashMap<String, Collection>();
57 denyValueRules = new HashMap<String, List<MatchFunctor>>();
58 }
59
60
61
62
63
64
65 public SAMLProfileRequestContext getAttributeRequestContext() {
66 return attributeRequestContext;
67 }
68
69
70
71
72
73
74 public Map<String, BaseAttribute> getUnfilteredAttributes() {
75 return unfilteredAttributes;
76 }
77
78
79
80
81
82
83
84
85
86
87 public Collection getRetainedValues(String attributeId, boolean prepopulate) {
88 Collection attributeValues;
89 if (!retainedValues.containsKey(attributeId)) {
90 attributeValues = new LazyList();
91 retainedValues.put(attributeId, attributeValues);
92
93 if (prepopulate) {
94 BaseAttribute attribute = unfilteredAttributes.get(attributeId);
95 if (attribute != null) {
96 attributeValues.addAll(attribute.getValues());
97 }
98 }
99 } else {
100 attributeValues = retainedValues.get(attributeId);
101 }
102
103 return attributeValues;
104 }
105
106
107
108
109
110
111
112 public Map<String, List<MatchFunctor>> getDenyValueRules() {
113 return denyValueRules;
114 }
115 }