CugRoot.java
2.68 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
83
84
85
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.Property
* javax.jcr.RepositoryException
* javax.jcr.Value
* javax.jcr.nodetype.PropertyDefinition
*/
package com.day.cq.auth.impl.cug;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.PropertyDefinition;
class CugRoot {
private static final String PROP_CUG_ENABLED = "jcr:content/cq:cugEnabled";
private static final String PROP_CUG_REALM = "jcr:content/cq:cugRealm";
private static final String PROP_CUG_LOGIN_PAGE = "jcr:content/cq:cugLoginPage";
private static final String PROP_CUG_PRINCIPALS = "jcr:content/cq:cugPrincipals";
private final String root;
private final String realm;
private final String loginPage;
private final String[] principals;
private final String registrationPath;
static boolean isEnabled(Node node) throws RepositoryException {
return node.hasProperty("jcr:content/cq:cugEnabled") && node.getProperty("jcr:content/cq:cugEnabled").getBoolean();
}
CugRoot(String registrationPath, Node node) throws RepositoryException {
this.root = node.getPath();
this.realm = CugRoot.getProperty(node, "jcr:content/cq:cugRealm");
this.loginPage = CugRoot.getProperty(node, "jcr:content/cq:cugLoginPage");
this.principals = CugRoot.getProperties(node, "jcr:content/cq:cugPrincipals");
this.registrationPath = registrationPath;
}
String getRoot() {
return this.root;
}
String getRealm() {
return this.realm;
}
String getLoginPath() {
return this.loginPage;
}
String[] getPrincipals() {
return this.principals;
}
String getRegistrationPath() {
return this.registrationPath;
}
private static String getProperty(Node node, String relPath) throws RepositoryException {
if (node.hasProperty(relPath)) {
return node.getProperty(relPath).getString();
}
return null;
}
private static String[] getProperties(Node node, String relPath) throws RepositoryException {
if (node.hasProperty(relPath)) {
Property prop = node.getProperty(relPath);
if (prop.getDefinition().isMultiple()) {
Value[] values = prop.getValues();
String[] result = new String[values.length];
for (int i = 0; i < result.length; ++i) {
result[i] = values[i].getString();
}
return result;
}
return new String[]{prop.getString()};
}
return null;
}
}