UserPropertiesCompositeImpl.java
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.RepositoryException
*/
package com.adobe.granite.security.user.internal;
import com.adobe.granite.security.user.UserProperties;
import com.adobe.granite.security.user.UserPropertiesComposite;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
public class UserPropertiesCompositeImpl
implements UserPropertiesComposite {
private final List<UserProperties> userPropertiesList;
private final String authorizableId;
public UserPropertiesCompositeImpl(String authorizableId, Collection<UserProperties> userPropertiesCollection) {
this.authorizableId = authorizableId;
this.userPropertiesList = new ArrayList<UserProperties>(userPropertiesCollection);
}
@Override
public Collection<String> getPropertyNames() throws RepositoryException {
return this.getPropertyNames(null);
}
@Override
public Collection<String> getPropertyNames(String relPath) throws RepositoryException {
HashSet<String> propertyNames = new HashSet<String>();
for (UserProperties properties : this.userPropertiesList) {
propertyNames.addAll(Arrays.asList(properties.getPropertyNames(relPath)));
}
return propertyNames;
}
@Override
public String getProperty(String relativePath) throws RepositoryException {
return this.getProperty(relativePath, null, String.class);
}
@Override
public <T> T getProperty(String relativePath, T defaultValue, Class<T> type) throws RepositoryException {
ListIterator<UserProperties> iterator = this.userPropertiesList.listIterator(this.userPropertiesList.size());
while (iterator.hasPrevious()) {
UserProperties properties = iterator.previous();
T value = properties.getProperty(relativePath, defaultValue, type);
if (null == value) continue;
return value;
}
return null;
}
@Override
public Collection<UserProperties> getUserProperties() {
return Collections.unmodifiableCollection(this.userPropertiesList);
}
@Override
public String getAuthorizableId() {
return this.authorizableId;
}
@Override
public Collection<String> getUserPropertiesPaths() throws RepositoryException {
ArrayList<String> paths = new ArrayList<String>(this.userPropertiesList.size());
for (UserProperties up : this.userPropertiesList) {
paths.add(up.getNode().getPath());
}
return paths;
}
}