javax.jcr.security.Privilege.isAggregate()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中javax.jcr.security.Privilege.isAggregate()方法的一些代码示例,展示了Privilege.isAggregate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Privilege.isAggregate()方法的具体详情如下:
包路径:javax.jcr.security.Privilege
类名称:Privilege
方法名:isAggregate

Privilege.isAggregate介绍

[英]Returns whether this privilege is an aggregate privilege.
[中]返回此权限是否为聚合权限。

代码示例

代码示例来源:origin: apache/jackrabbit

public boolean isAggregate() {
  return privilege.isAggregate();
}

代码示例来源: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: 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: 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: 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 boolean apply(@Nullable Privilege input) {
    return input != null && input.isAggregate();
  }
});

代码示例来源: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: 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: apache/jackrabbit-oak

@Test
public void testIsAggregate() {
  assertFalse(privilege.isAggregate());
  assertTrue(allPrivilege.isAggregate());
  assertTrue(aggrPrivilege.isAggregate());
  assertFalse(abstractPrivilege.isAggregate());
}

代码示例来源:origin: apache/jackrabbit

private SupportedPrivilege createSupportedPrivilege(Privilege privilege) throws RepositoryException {
  String privilegeName = privilege.getName();
  String localName = Text.getLocalName(privilegeName);
  String prefix = Text.getNamespacePrefix(privilegeName);
  Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
  org.apache.jackrabbit.webdav.security.Privilege davPrivilege = org.apache.jackrabbit.webdav.security.Privilege.getPrivilege(localName, ns);
  SupportedPrivilege[] aggregates = (privilege.isAggregate()) ? getDeclaredAggregates(privilege) : null;
  SupportedPrivilege sp = new SupportedPrivilege(davPrivilege, null, null, privilege.isAbstract(), aggregates);
  if (!aggregated.contains(privilegeName)) {
    supportedPrivileges.put(privilegeName, sp);
  }
  return sp;
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test the jcr:write privilege.
 *
 * @throws RepositoryException If an error occurs.
 * @throws NotExecutableException If the test cannot be executed.
 */
public void testWritePrivilege() throws RepositoryException, NotExecutableException {
  Privilege w = acMgr.privilegeFromName(Privilege.JCR_WRITE);
  assertTrue("Write privilege must be an aggregate privilege.", w.isAggregate());
  String expected = getJCRName(Privilege.JCR_WRITE, superuser);
  assertEquals("The name of the write privilege must be " + expected, expected, w.getName());
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test the jcr:all privilege.
 * 
 * @throws RepositoryException
 * @throws NotExecutableException
 */
public void testAllPrivilege() throws RepositoryException, NotExecutableException {
  Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
  assertFalse("All privilege must be not be abstract.", all.isAbstract());
  assertTrue("All privilege must be an aggregate privilege.", all.isAggregate());
  String expected = getJCRName(Privilege.JCR_ALL, superuser);
  assertEquals("The name of the all privilege must be " + expected, expected, all.getName());
}

代码示例来源:origin: apache/jackrabbit

public void testGetPrivilegeFromName() throws AccessControlException, RepositoryException {
  Privilege p = privilegeRegistry.getPrivilege(Privilege.JCR_READ);
  assertTrue(p != null);
  assertSamePrivilegeName(Privilege.JCR_READ, p.getName());
  assertFalse(p.isAggregate());
  p = privilegeRegistry.getPrivilege(Privilege.JCR_WRITE);
  assertTrue(p != null);
  assertSamePrivilegeName(p.getName(), Privilege.JCR_WRITE);
  assertTrue(p.isAggregate());
}

代码示例来源:origin: apache/jackrabbit

public void testGetPrivilegeFromName() throws AccessControlException, RepositoryException {
  Privilege p = privilegeMgr.getPrivilege(Privilege.JCR_READ);
  assertTrue(p != null);
  assertSamePrivilegeName(Privilege.JCR_READ, p.getName());
  assertFalse(p.isAggregate());
  p = privilegeMgr.getPrivilege(Privilege.JCR_WRITE);
  assertTrue(p != null);
  assertSamePrivilegeName(p.getName(), Privilege.JCR_WRITE);
  assertTrue(p.isAggregate());
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testGetPrivilegeFromName() throws AccessControlException, RepositoryException {
  Privilege p = privilegeManager.getPrivilege(Privilege.JCR_VERSION_MANAGEMENT);
  assertTrue(p != null);
  assertEquals(PrivilegeConstants.JCR_VERSION_MANAGEMENT, p.getName());
  assertFalse(p.isAggregate());
  p = privilegeManager.getPrivilege(Privilege.JCR_WRITE);
  assertTrue(p != null);
  assertEquals(PrivilegeConstants.JCR_WRITE, p.getName());
  assertTrue(p.isAggregate());
}

代码示例来源:origin: apache/jackrabbit

private void assertPrivilege(Privilege priv, String name, boolean isAggregate, boolean isAbstract) throws NamespaceException, IllegalNameException {
  assertNotNull(priv);
  assertPrivilegeName(name, priv.getName());
  assertEquals(isAggregate, priv.isAggregate());
  assertEquals(isAbstract, priv.isAbstract());
}

代码示例来源:origin: apache/jackrabbit-oak

void assertPrivilege(Privilege priv, String name, boolean isAggregate, boolean isAbstract) {
    assertNotNull(priv);
    String privName = priv.getName();
    assertEquals(privName, privName, name);
    assertEquals(privName, isAggregate, priv.isAggregate());
    assertEquals(privName,isAbstract, priv.isAbstract());
  }
}

代码示例来源: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

public void testCustomPrivilege() throws RepositoryException, FileSystemException {
  boolean isAbstract = false;
  Name name = ((SessionImpl) superuser).getQName("test");
  privilegeRegistry.registerDefinition(name, isAbstract, Collections.<Name>emptySet());
  PrivilegeManagerImpl pm = new PrivilegeManagerImpl(privilegeRegistry, resolver);
  String privName = resolver.getJCRName(name);
  Privilege priv = pm.getPrivilege(privName);
  assertEquals(privName, priv.getName());
  assertEquals(isAbstract, priv.isAbstract());
  assertFalse(priv.isAggregate());
  assertFalse(pm.getBits(priv).isEmpty());
  Privilege jcrWrite = pm.getPrivilege(Privilege.JCR_WRITE);
  assertFalse(pm.getBits(jcrWrite).equals(pm.getBits(priv, jcrWrite)));
}

相关文章