本文整理了Java中javax.jcr.security.Privilege.getDeclaredAggregatePrivileges()
方法的一些代码示例,展示了Privilege.getDeclaredAggregatePrivileges()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Privilege.getDeclaredAggregatePrivileges()
方法的具体详情如下:
包路径:javax.jcr.security.Privilege
类名称:Privilege
方法名:getDeclaredAggregatePrivileges
[英]If this privilege is an aggregate privilege, returns the privileges directly contained by the aggregate privilege. Otherwise returns an empty array.
[中]如果此权限是聚合权限,则返回聚合权限直接包含的权限。否则返回一个空数组。
代码示例来源:origin: apache/jackrabbit
private SupportedPrivilege[] getDeclaredAggregates(Privilege privilege) throws RepositoryException {
List<SupportedPrivilege> declAggr = new ArrayList<SupportedPrivilege>();
for (Privilege decl : privilege.getDeclaredAggregatePrivileges()) {
String name = decl.getName();
if (aggregated.add(name)) {
if (supportedPrivileges.containsKey(name)) {
declAggr.add(supportedPrivileges.remove(name));
} else {
declAggr.add(createSupportedPrivilege(decl));
}
}
}
return declAggr.toArray(new SupportedPrivilege[declAggr.size()]);
}
}
代码示例来源:origin: ModeShape/modeshape
/**
* Recursively aggregates privileges for the given privilege.
*
* @param list list which holds all aggregate privileges.
* @param p the given privilege
*/
private void aggregate(ArrayList<Privilege> list, Privilege p) {
list.add(p);
if (p.isAggregate()) {
for (Privilege ap : p.getDeclaredAggregatePrivileges()) {
aggregate(list, ap);
}
}
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Recursively aggregates privileges for the given privilege.
*
* @param list list which holds all aggregate privileges.
* @param p the given privilege
*/
private void aggregate(ArrayList<Privilege> list, Privilege p) {
list.add(p);
if (p.isAggregate()) {
for (Privilege ap : p.getDeclaredAggregatePrivileges()) {
aggregate(list, ap);
}
}
}
代码示例来源:origin: apache/jackrabbit
public RemotePrivilege[] getDeclaredAggregatePrivileges()
throws RemoteException {
return getFactory().getRemotePrivilege(
privilege.getDeclaredAggregatePrivileges());
}
代码示例来源: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 testGetDeclaredAggregatedPrivilegesSimple() {
assertAggregation(privilege.getDeclaredAggregatePrivileges());
assertAggregation(aggrPrivilege.getDeclaredAggregatePrivileges(), JCR_NODE_TYPE_MANAGEMENT, JCR_WRITE);
}
代码示例来源:origin: apache/jackrabbit-oak
static void assertContainsDeclared(Privilege privilege, String aggrName) {
boolean found = false;
for (Privilege p : privilege.getDeclaredAggregatePrivileges()) {
if (aggrName.equals(p.getName())) {
found = true;
break;
}
}
assertTrue(found);
}
代码示例来源:origin: apache/jackrabbit
/**
* Test some simple characteristics of the known aggregate privileges (jcr:write and jcr:all).
*
* @throws RepositoryException
*/
public void testAggregregatePrivileges() throws RepositoryException {
List<String> l = new ArrayList<String>();
l.add(getJCRName(Privilege.JCR_WRITE, superuser));
l.add(getJCRName(Privilege.JCR_ALL, superuser));
for (Iterator<String> it = l.iterator(); it.hasNext();) {
String privName = it.next();
Privilege p = acMgr.privilegeFromName(privName);
assertTrue("write and all must always be aggregate privileges.", p.isAggregate());
Privilege[] aggregatedPrvs = p.getAggregatePrivileges();
Privilege[] declaredPrvs = p.getDeclaredAggregatePrivileges();
assertNotNull("An aggregate privilege must return the aggregated privileges", aggregatedPrvs);
assertTrue("An aggregate privilege must return the aggregated privileges", aggregatedPrvs.length > 0);
assertNotNull("An aggregate privilege must return the declared aggregated privileges", declaredPrvs);
assertTrue("An aggregate privilege must return the declared aggregated privileges", declaredPrvs.length > 0);
assertTrue("The may be at least the same amount of declared aggregated privileges.", aggregatedPrvs.length >= declaredPrvs.length);
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testJcrAll() throws Exception {
Privilege all = privilegeManager.getPrivilege(PrivilegeConstants.JCR_ALL);
Set<Privilege> aggregates = Sets.newHashSet(all.getDeclaredAggregatePrivileges());
assertTrue(aggregates.contains(newPrivilege));
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testAggregation() throws RepositoryException {
PrivilegeManager privilegeManager = getPrivilegeManager(root);
// EXERCISE: for all aggregated privileges define the mapping of the privilege name to declaredAggregates
Map<String, Set<Privilege>> expectedResults = ImmutableMap.of(
/* EXERCISE */
);
Iterable<Privilege> aggregated = Iterables.<Privilege>filter(
ImmutableList.<Privilege>copyOf(privilegeManager.getRegisteredPrivileges()),
new Predicate<Privilege>() {
@Override
public boolean apply(@Nullable Privilege input) {
return input != null && input.isAggregate();
}
});
for (Privilege aggrPrivilege : aggregated) {
Set<Privilege> expected = expectedResults.get(aggrPrivilege.getName());
assertEquals(expected, ImmutableSet.copyOf(aggrPrivilege.getDeclaredAggregatePrivileges()));
}
}
代码示例来源:origin: apache/jackrabbit
public void testEquals() throws RepositoryException, NotExecutableException {
Map<AccessControlEntry, AccessControlEntry> equalAces = new HashMap<AccessControlEntry, AccessControlEntry>();
JackrabbitAccessControlEntry ace = createEntry(new String[] {Privilege.JCR_ALL}, true);
// create same entry again
equalAces.put(ace, createEntry(new String[] {Privilege.JCR_ALL}, true));
// create entry with declared aggregate privileges
Privilege[] declaredAllPrivs = acMgr.privilegeFromName(Privilege.JCR_ALL).getDeclaredAggregatePrivileges();
equalAces.put(ace, createEntry(testPrincipal, declaredAllPrivs, true));
// create entry with aggregate privileges
Privilege[] aggregateAllPrivs = acMgr.privilegeFromName(Privilege.JCR_ALL).getAggregatePrivileges();
equalAces.put(ace, createEntry(testPrincipal, aggregateAllPrivs, true));
// create entry with different privilege order
List<Privilege> reordered = new ArrayList<Privilege>(Arrays.asList(aggregateAllPrivs));
reordered.add(reordered.remove(0));
equalAces.put(createEntry(testPrincipal, reordered.toArray(new Privilege[reordered.size()]), true),
createEntry(testPrincipal, aggregateAllPrivs, true));
// even if entries are build with aggregated or declared aggregate privileges
equalAces.put(createEntry(testPrincipal, declaredAllPrivs, true),
createEntry(testPrincipal, aggregateAllPrivs, true));
for (AccessControlEntry entry : equalAces.keySet()) {
assertEquals(entry, equalAces.get(entry));
}
}
代码示例来源:origin: apache/jackrabbit
public PrivilegeDefinition[] getSupportedPrivileges(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
String path = (nodeId == null) ? null : pathForId(nodeId, sInfo);
Privilege[] privs = sInfo.getSession().getAccessControlManager().getSupportedPrivileges(path);
PrivilegeDefinition[] pDefs = new PrivilegeDefinition[privs.length];
NamePathResolver npResolver = sInfo.getNamePathResolver();
for (int i = 0; i < privs.length; i++) {
Set<Name> aggrnames = null;
if (privs[i].isAggregate()) {
aggrnames = new HashSet<Name>();
for (Privilege dap : privs[i].getDeclaredAggregatePrivileges()) {
aggrnames.add(npResolver.getQName(dap.getName()));
}
}
PrivilegeDefinition def = new PrivilegeDefinitionImpl(npResolver.getQName(privs[i].getName()), privs[i].isAbstract(), aggrnames);
pDefs[i] = def;
}
return pDefs;
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr
public PrivilegeDefinition[] getSupportedPrivileges(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
String path = (nodeId == null) ? null : pathForId(nodeId, sInfo);
Privilege[] privs = sInfo.getSession().getAccessControlManager().getSupportedPrivileges(path);
PrivilegeDefinition[] pDefs = new PrivilegeDefinition[privs.length];
NamePathResolver npResolver = sInfo.getNamePathResolver();
for (int i = 0; i < privs.length; i++) {
Set<Name> aggrnames = null;
if (privs[i].isAggregate()) {
aggrnames = new HashSet<Name>();
for (Privilege dap : privs[i].getDeclaredAggregatePrivileges()) {
aggrnames.add(npResolver.getQName(dap.getName()));
}
}
PrivilegeDefinition def = new PrivilegeDefinitionImpl(npResolver.getQName(privs[i].getName()), privs[i].isAbstract(), aggrnames);
pDefs[i] = def;
}
return pDefs;
}
代码示例来源: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
public void testGetPrivilegesFromBits2() throws RepositoryException {
String[] names = new String[] {
Privilege.JCR_ADD_CHILD_NODES,
Privilege.JCR_REMOVE_CHILD_NODES,
Privilege.JCR_REMOVE_NODE,
Privilege.JCR_MODIFY_PROPERTIES
};
PrivilegeBits writeBits = getPrivilegeManagerImpl().getBits(privilegesFromNames(names));
Set<Privilege> pvs = getPrivilegeManagerImpl().getPrivileges(writeBits);
assertTrue(pvs != null);
assertTrue(pvs.size() == 1);
Privilege p = pvs.iterator().next();
assertSamePrivilegeName(p.getName(), Privilege.JCR_WRITE);
assertTrue(p.isAggregate());
assertTrue(p.getDeclaredAggregatePrivileges().length == names.length);
}
代码示例来源:origin: apache/jackrabbit
private static void assertPrivilege(PrivilegeRegistry registry, NameResolver resolver, PrivilegeDefinition def) throws RepositoryException {
PrivilegeManagerImpl pmgr = new PrivilegeManagerImpl(registry, resolver);
Privilege p = pmgr.getPrivilege(resolver.getJCRName(def.getName()));
assertNotNull(p);
assertEquals(def.isAbstract(), p.isAbstract());
Set<Name> danames = def.getDeclaredAggregateNames();
assertEquals(danames.size() > 0, p.isAggregate());
assertEquals(danames.size(), p.getDeclaredAggregatePrivileges().length);
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testInvalidDeclaredAggregate() throws Exception {
NodeUtil privilegeDefs = new NodeUtil(root.getTree(PRIVILEGES_PATH));
NodeUtil privDef = privilegeDefs.addChild("test", NT_REP_PRIVILEGE);
privDef.setNames(REP_AGGREGATES, JCR_READ, "invalid");
Privilege p = getPrivilegeManager(root).getPrivilege("test");
assertAggregation(p.getDeclaredAggregatePrivileges(), JCR_READ);
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testCyclicDeclaredAggregate() throws Exception {
NodeUtil privilegeDefs = new NodeUtil(root.getTree(PRIVILEGES_PATH));
NodeUtil privDef = privilegeDefs.addChild("test", NT_REP_PRIVILEGE);
privDef.setNames(REP_AGGREGATES, JCR_READ, "test");
Privilege p = getPrivilegeManager(root).getPrivilege("test");
assertAggregation(p.getDeclaredAggregatePrivileges(), JCR_READ);
}
}
代码示例来源:origin: apache/jackrabbit
public void testGetPrivilegesFromBits2() throws RepositoryException {
String[] names = new String[] {
Privilege.JCR_ADD_CHILD_NODES,
Privilege.JCR_REMOVE_CHILD_NODES,
Privilege.JCR_REMOVE_NODE,
Privilege.JCR_MODIFY_PROPERTIES
};
int writeBits = PrivilegeRegistry.getBits(privilegesFromNames(names));
Privilege[] pvs = privilegeRegistry.getPrivileges(writeBits);
assertTrue(pvs != null);
assertTrue(pvs.length == 1);
assertSamePrivilegeName(pvs[0].getName(), Privilege.JCR_WRITE);
assertTrue(pvs[0].isAggregate());
assertTrue(pvs[0].getDeclaredAggregatePrivileges().length == names.length);
}
代码示例来源:origin: apache/jackrabbit
public void testGetPrivilegesFromBits3() throws RepositoryException {
String[] names = new String[] {
PrivilegeRegistry.REP_WRITE
};
int writeBits = PrivilegeRegistry.getBits(privilegesFromNames(names));
Privilege[] pvs = privilegeRegistry.getPrivileges(writeBits);
assertTrue(pvs != null);
assertTrue(pvs.length == 1);
assertSamePrivilegeName(pvs[0].getName(), PrivilegeRegistry.REP_WRITE);
assertTrue(pvs[0].isAggregate());
names = new String[] {
PrivilegeRegistry.REP_WRITE,
Privilege.JCR_WRITE
};
writeBits = PrivilegeRegistry.getBits(privilegesFromNames(names));
pvs = privilegeRegistry.getPrivileges(writeBits);
assertTrue(pvs != null);
assertTrue(pvs.length == 1);
assertSamePrivilegeName(pvs[0].getName(), PrivilegeRegistry.REP_WRITE);
assertTrue(pvs[0].isAggregate());
assertTrue(pvs[0].getDeclaredAggregatePrivileges().length == names.length);
}
内容来源于网络,如有侵权,请联系作者删除!