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.resolver.provider.attributeDefinition;
19
20 import java.util.Collection;
21
22 import org.opensaml.xml.util.DatatypeHelper;
23
24 import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
25 import edu.internet2.middleware.shibboleth.common.attribute.provider.BasicAttribute;
26 import edu.internet2.middleware.shibboleth.common.attribute.provider.ScopedAttributeValue;
27 import edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolutionException;
28 import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ShibbolethResolutionContext;
29
30
31
32
33
34 public class ScopedAttributeDefinition extends BaseAttributeDefinition {
35
36
37 private String scope;
38
39
40
41
42
43
44 public ScopedAttributeDefinition(String newScope) {
45 this.scope = newScope;
46 }
47
48
49 public BaseAttribute<ScopedAttributeValue> doResolve(ShibbolethResolutionContext resolutionContext)
50 throws AttributeResolutionException {
51 BasicAttribute<ScopedAttributeValue> attribute = new BasicAttribute<ScopedAttributeValue>();
52 attribute.setId(getId());
53
54 Collection<?> values = getValuesFromAllDependencies(resolutionContext);
55 if (values != null && !values.isEmpty()) {
56 for (Object value : values) {
57 if (value != null) {
58 String strValue = DatatypeHelper.safeTrimOrNullString(value.toString());
59 if (strValue != null) {
60 attribute.getValues().add(new ScopedAttributeValue(strValue.toString(), scope));
61 }
62 }
63 }
64 }
65
66 return attribute;
67 }
68
69
70
71
72
73
74 public String getScope() {
75 return scope;
76 }
77
78
79 public void validate() throws AttributeResolutionException {
80
81 }
82 }