PrivilegeRenderCondition.java
1.66 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.RepositoryException
* javax.jcr.security.AccessControlManager
* javax.jcr.security.Privilege
* javax.servlet.ServletException
*/
package com.adobe.granite.ui.components.rendercondition;
import com.adobe.granite.ui.components.rendercondition.RenderCondition;
import javax.jcr.RepositoryException;
import javax.jcr.security.AccessControlManager;
import javax.jcr.security.Privilege;
import javax.servlet.ServletException;
public class PrivilegeRenderCondition
implements RenderCondition {
private AccessControlManager acm;
private String path;
private Privilege[] privileges;
public PrivilegeRenderCondition(AccessControlManager acm, String path, String[] privilegeNames) throws RepositoryException {
this.acm = acm;
this.path = path;
this.privileges = this.converts(privilegeNames);
}
public PrivilegeRenderCondition(AccessControlManager acm, String path, Privilege[] privileges) {
this.acm = acm;
this.path = path;
this.privileges = privileges;
}
private Privilege[] converts(String[] privilegeNames) throws RepositoryException {
Privilege[] privileges = new Privilege[privilegeNames.length];
for (int i = 0; i < privilegeNames.length; ++i) {
privileges[i] = this.acm.privilegeFromName(privilegeNames[i]);
}
return privileges;
}
public boolean check() throws ServletException {
try {
return this.acm.hasPrivileges(this.path, this.privileges);
}
catch (RepositoryException e) {
return false;
}
}
}