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

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

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

Privilege.getName介绍

[英]Returns the name of this privilege.

Since the privilege name is a JCR name, it must be returned in qualified form, according to the prevailing namespace-to-prefix mapping in the current Session (see the specification for details on JCR names).
[中]返回此特权的名称。
由于特权名称是一个JCR名称,因此必须根据当前Session中流行的名称空间到前缀的映射,以限定形式返回它(有关JCR名称的详细信息,请参阅规范)。

代码示例

代码示例来源:origin: stackoverflow.com

roles.add(new GrantedAuthorityImpl(p.getName()));

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

@Nullable
  @Override
  public String apply(@Nullable Privilege input) {
    return (input == null) ? null : input.getName();
  }
});

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

private static String[] getNames(Privilege[] privileges) {
  String[] names = new String[privileges.length];
  for (int i = 0; i < privileges.length; i++) {
    names[i] = privileges[i].getName();
  }
  return names;
}

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

private boolean hasPrivilege(PrivilegeManager pMgr, String privilegeName) throws RepositoryException {
  final Privilege[] registeredPrivileges = pMgr.getRegisteredPrivileges();
  for (Privilege registeredPrivilege : registeredPrivileges) {
    if (registeredPrivilege.getName().equals(privilegeName)) {
      return true;
    }
  }
  return false;
}

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

public void testPrivilegeFromName() throws RepositoryException {
  Privilege[] privileges = acMgr.getSupportedPrivileges(testRootNode.getPath());
  for (int i = 0; i < privileges.length; i++) {
    Privilege p = acMgr.privilegeFromName(privileges[i].getName());
    assertEquals("Expected equal privilege name.", privileges[i].getName(), p.getName());
    assertEquals("Expected equal privilege.", privileges[i], p);
  }
}

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

private static Privilege[] privilegesFromNames(String... privNames) {
  Privilege[] p = new Privilege[privNames.length];
  for (int i = 0; i < privNames.length; i++) {
    Privilege privilege = Mockito.mock(Privilege.class);
    when(privilege.getName()).thenReturn(privNames[i]);
    p[i] = privilege;
  }
  return p;
}

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

private static Privilege mockPrivilege(@NotNull String name) {
  Privilege p = Mockito.mock(Privilege.class);
  when(p.getName()).thenReturn(name);
  return p;
}

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

@Override
public Name[] getPrivilegeNames(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
  SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
  String path = (nodeId == null) ? null : pathForId(nodeId, sInfo);
  NamePathResolver npResolver = sInfo.getNamePathResolver();
  
  Privilege[] privs = sInfo.getSession().getAccessControlManager().getPrivileges(path);
  List<Name> names = new ArrayList<Name>(privs.length);
  for (Privilege priv : privs) {
    names.add(npResolver.getQName(priv.getName()));
  }
  return names.toArray(new Name[names.size()]);
}

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

@Test
public void testPrivilegeFromName() throws Exception {
  List<Privilege> allPrivileges = Arrays.asList(privilegeManager.getRegisteredPrivileges());
  for (Privilege privilege : allPrivileges) {
    Privilege p = acMgr.privilegeFromName(privilege.getName());
    assertEquals(privilege, p);
  }
}

代码示例来源:origin: ModeShape/modeshape

@Test
public void shouldHaveReadPrivilege() throws Exception {
  Privilege[] privileges = acm.getPrivileges("/Cars/Luxury");
  assertEquals("jcr:read", privileges[0].getName());
}

代码示例来源:origin: ModeShape/modeshape

@Test
public void shoudlDeriveAccessList() throws Exception {
  Privilege[] privileges = acm.getPrivileges("/Cars/Luxury/Lexus IS350");
  assertEquals("jcr:read", privileges[0].getName());
}

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

@Test
public void testToString() {
  PrivilegeDefinition def = new PrivilegeDefinitionReader(root).readDefinition(privilege.getName());
  assertEquals(def.getName(), privilege.toString());
}

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

@Test(expected = AccessControlException.class)
public void testGetPrivilegeExpandedNameMissingMapper() throws Exception {
  Privilege p = privilegeManager.getPrivilege(Privilege.JCR_VERSION_MANAGEMENT);
  assertNotNull(p);
  assertEquals(PrivilegeConstants.JCR_VERSION_MANAGEMENT, p.getName());
}

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

@Test
public void testGetPrivilegeExpandedName() throws Exception {
  Privilege p = create(root, new NamePathMapperImpl(new GlobalNameMapper(root))).getPrivilege(Privilege.JCR_VERSION_MANAGEMENT);
  assertNotNull(p);
  assertNotEquals(Privilege.JCR_VERSION_MANAGEMENT, p.getName());
  assertEquals(PrivilegeConstants.JCR_VERSION_MANAGEMENT, p.getName());
}

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

@Test
public void testEquals() throws Exception {
  assertEquals(privilege, privilege);
  assertEquals(privilege, getPrivilegeManager(root).getPrivilege(privilege.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-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

public void testGetPrivilegesFromBits() throws RepositoryException {
  int bits = PrivilegeRegistry.getBits(privilegesFromNames(new String[] {Privilege.JCR_READ_ACCESS_CONTROL}));
  Privilege[] pvs = privilegeRegistry.getPrivileges(bits);
  assertTrue(pvs != null);
  assertTrue(pvs.length == 1);
  assertSamePrivilegeName(pvs[0].getName(), Privilege.JCR_READ_ACCESS_CONTROL);
}

相关文章