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