本文整理了Java中javax.jcr.security.Privilege.getAggregatePrivileges()
方法的一些代码示例,展示了Privilege.getAggregatePrivileges()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Privilege.getAggregatePrivileges()
方法的具体详情如下:
包路径:javax.jcr.security.Privilege
类名称:Privilege
方法名:getAggregatePrivileges
[英]If this privilege is an aggregate privilege, returns the privileges it contains, the privileges contained by any aggregate privileges among those, and so on (the transitive closure of privileges contained by this privilege). Otherwise returns an empty array.
[中]如果此特权是聚合特权,则返回它包含的特权、这些特权中任何聚合特权包含的特权,依此类推(此特权包含的特权的传递闭包)。否则返回一个空数组。
代码示例来源:origin: apache/jackrabbit
private int getPrivilegesHashCode() {
if (privsHashCode == -1) {
Set<Privilege> prvs = new HashSet<Privilege>(Arrays.asList(privileges));
for (Privilege p : privileges) {
if (p.isAggregate()) {
prvs.addAll(Arrays.asList(p.getAggregatePrivileges()));
}
}
privsHashCode = prvs.hashCode();
}
return privsHashCode;
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi
private int getPrivilegesHashCode() {
if (privsHashCode == -1) {
Set<Privilege> prvs = new HashSet<Privilege>(Arrays.asList(privileges));
for (Privilege p : privileges) {
if (p.isAggregate()) {
prvs.addAll(Arrays.asList(p.getAggregatePrivileges()));
}
}
privsHashCode = prvs.hashCode();
}
return privsHashCode;
}
代码示例来源:origin: apache/jackrabbit
public Privilege[] getAggregatePrivileges() {
return (declaredAggr == null) ? new Privilege[0] : declaredAggr.getAggregatePrivileges();
}
};
代码示例来源:origin: apache/jackrabbit
public Privilege[] getAggregatePrivileges() {
return (declaredAggr == null) ? new Privilege[0] : declaredAggr.getAggregatePrivileges();
}
};
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override
public Privilege[] getAggregatePrivileges() {
Set<Privilege> aggr = new HashSet();
for (Privilege decl : getDeclaredAggregatePrivileges()) {
aggr.add(decl);
if (decl.isAggregate()) {
aggr.addAll(Arrays.asList(decl.getAggregatePrivileges()));
}
}
return aggr.toArray(new Privilege[aggr.size()]);
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
@Override
public Privilege[] getAggregatePrivileges() {
Set<Privilege> aggr = new HashSet<>();
for (Privilege decl : getDeclaredAggregatePrivileges()) {
aggr.add(decl);
if (decl.isAggregate()) {
aggr.addAll(Arrays.asList(decl.getAggregatePrivileges()));
}
}
return aggr.toArray(new Privilege[0]);
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public Privilege[] getAggregatePrivileges() {
Set<Privilege> aggr = new HashSet<>();
for (Privilege decl : getDeclaredAggregatePrivileges()) {
aggr.add(decl);
if (decl.isAggregate()) {
aggr.addAll(Arrays.asList(decl.getAggregatePrivileges()));
}
}
return aggr.toArray(new Privilege[0]);
}
代码示例来源:origin: apache/jackrabbit
public RemotePrivilege[] getAggregatePrivileges() throws RemoteException {
return getFactory().getRemotePrivilege(
privilege.getAggregatePrivileges());
}
代码示例来源:origin: apache/jackrabbit
public void testAllPrivilegeContainsAll() throws RepositoryException, NotExecutableException {
Privilege[] supported = acMgr.getSupportedPrivileges(testRootNode.getPath());
Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
Set<Privilege> allSet = new HashSet<Privilege>();
allSet.addAll(Arrays.asList(all.getAggregatePrivileges()));
String msg = "The all privilege must also contain ";
for (int i=0; i < supported.length; i++) {
Privilege sp = supported[i];
if (sp.isAggregate()) {
Collection<Privilege> col = Arrays.asList(sp.getAggregatePrivileges());
assertTrue(msg + sp.getName(), allSet.containsAll(col));
} else {
assertTrue(msg + sp.getName(), allSet.contains(sp));
}
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi
public boolean hasPrivileges(String absPath, Privilege[] privileges) throws PathNotFoundException, RepositoryException {
Set<Privilege> privs = acProvider.getPrivileges(sessionInfo, getNodeState(npResolver.getQPath(absPath)).getNodeId(), npResolver);
List<Privilege> toTest = Arrays.asList(privileges);
if (privs.containsAll(toTest)) {
return true;
} else {
Set<Privilege> agg = new HashSet<Privilege>(privs);
for (Privilege p : privs) {
if (p.isAggregate()) {
agg.addAll(Arrays.asList(p.getAggregatePrivileges()));
}
}
return agg.containsAll(toTest);
}
}
代码示例来源:origin: apache/jackrabbit
public boolean hasPrivileges(String absPath, Privilege[] privileges) throws PathNotFoundException, RepositoryException {
Set<Privilege> privs = acProvider.getPrivileges(sessionInfo, getNodeState(npResolver.getQPath(absPath)).getNodeId(), npResolver);
List<Privilege> toTest = Arrays.asList(privileges);
if (privs.containsAll(toTest)) {
return true;
} else {
Set<Privilege> agg = new HashSet<Privilege>(privs);
for (Privilege p : privs) {
if (p.isAggregate()) {
agg.addAll(Arrays.asList(p.getAggregatePrivileges()));
}
}
return agg.containsAll(toTest);
}
}
代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape
/**
* Tests if the specified privilege implies, either directly or as an aggregate, the named privilege.
* @param checked the privilege being checked
* @param implied the name of the privilege to be implied
* @return true if the check privilege implies the given privilege name
*/
private static boolean implies(Privilege checked, String implied) {
if (checked.getName().equals(implied)) {
return true;
} else if (checked.isAggregate()) {
return impliesAny(checked.getAggregatePrivileges(), implied);
} else {
return false;
}
}
代码示例来源:origin: com.github.livesense/org.liveSense.service.securityManager
public SerializablePrivilege(Privilege privilege) {
this.name = privilege.getName();
this.abstract_ = privilege.isAbstract();
Privilege[] privs = privilege.getDeclaredAggregatePrivileges();
for (int i = 0; i < privs.length; i++) {
declaredAggregatePrivileges.add(new SerializablePrivilege(privs[i]));
}
privs = privilege.getAggregatePrivileges();
for (int i = 0; i < privs.length; i++) {
aggregatePrivileges.add(new SerializablePrivilege(privs[i]));
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testGetAggregatedPrivileges() {
assertAggregation(privilege.getAggregatePrivileges());
assertAggregation(aggrPrivilege.getAggregatePrivileges(),
JCR_NODE_TYPE_MANAGEMENT,
JCR_WRITE, JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES, JCR_REMOVE_NODE,
JCR_MODIFY_PROPERTIES, REP_ADD_PROPERTIES, REP_ALTER_PROPERTIES, REP_REMOVE_PROPERTIES);
}
代码示例来源:origin: apache/jackrabbit
public void testGetRegisteredPrivileges() throws RepositoryException {
Privilege[] registered = privilegeMgr.getRegisteredPrivileges();
Set<Privilege> set = new HashSet<Privilege>();
Privilege all = privilegeMgr.getPrivilege(Privilege.JCR_ALL);
set.add(all);
set.addAll(Arrays.asList(all.getAggregatePrivileges()));
for (Privilege p : registered) {
assertTrue(set.remove(p));
}
assertTrue(set.isEmpty());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testGetRegisteredPrivileges() throws RepositoryException {
Privilege[] registered = privilegeManager.getRegisteredPrivileges();
Set<Privilege> set = new HashSet<Privilege>();
Privilege all = privilegeManager.getPrivilege(Privilege.JCR_ALL);
set.add(all);
set.addAll(Arrays.asList(all.getAggregatePrivileges()));
for (Privilege p : registered) {
assertTrue(p.getName(), set.remove(p));
}
assertTrue(set.isEmpty());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testCustomPrivilege() {
Set<String> expected = null; //EXERCISE
assertEqualPrivileges(expected, customAggrPriv.getDeclaredAggregatePrivileges());
expected = null; // EXERCISE
assertEqualPrivileges(expected, customAggrPriv.getAggregatePrivileges());
Boolean expectedIsAbstract = null; // EXERCISE
assertEquals(expectedIsAbstract.booleanValue(), customAggrPriv.isAbstract());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testSingleDenyAfterAllAllowed() throws Exception {
/* add 'all' privilege for testSession at path. */
Privilege[] allPrivileges = privilegesFromName(Privilege.JCR_ALL);
allow(path, allPrivileges);
/* deny a single privilege */
Privilege[] lockPrivileges = privilegesFromName(Privilege.JCR_LOCK_MANAGEMENT);
deny(path, lockPrivileges);
/* test permissions. expected result:
- testSession cannot lock at 'path'
- testSession doesn't have ALL privilege at path
*/
assertFalse(testAcMgr.hasPrivileges(path, allPrivileges));
assertFalse(testAcMgr.hasPrivileges(path, lockPrivileges));
List<Privilege> remainingprivs = new ArrayList<Privilege>(Arrays.asList(allPrivileges[0].getAggregatePrivileges()));
remainingprivs.remove(lockPrivileges[0]);
assertTrue(testAcMgr.hasPrivileges(path, remainingprivs.toArray(new Privilege[remainingprivs.size()])));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testMapItems() throws Exception {
Privilege jcrAll = acMgr.privilegeFromName(PrivilegeConstants.JCR_ALL);
for (Privilege privilege : jcrAll.getAggregatePrivileges()) {
try {
// EXERCISE : modify item(s) affected by the given privilege and verify that it fails
setupAcl(privilege, acMgr);
testRoot.refresh();
// EXERCISE : modify the same item(s) again and verify that it succeeds
} finally {
clearAcl(acMgr);
testRoot.refresh();
}
}
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* @see <a href="https://issues.apache.org/jira/browse/OAK-1026">OAK-1026</a>
*/
@Test
public void testEntryWithAggregatePrivileges() throws Exception {
Privilege write = acMgr.privilegeFromName(Privilege.JCR_WRITE);
acl.addEntry(testPrincipal, write.getAggregatePrivileges(), true);
AccessControlEntry[] entries = acl.getAccessControlEntries();
assertEquals(1, entries.length);
assertArrayEquals(new Privilege[]{write}, entries[0].getPrivileges());
acMgr.setPolicy(acl.getPath(), acl);
AccessControlPolicy policy = AccessControlUtils.getAccessControlList(acMgr, acl.getPath());
assertNotNull(policy);
entries = acl.getAccessControlEntries();
assertEquals(1, entries.length);
assertArrayEquals(new Privilege[]{write}, entries[0].getPrivileges());
}
内容来源于网络,如有侵权,请联系作者删除!