本文整理汇总了Java中org.apache.jackrabbit.api.security.JackrabbitAccessControlList类的典型用法代码示例。如果您正苦于以下问题:Java JackrabbitAccessControlList类的具体用法?Java JackrabbitAccessControlList怎么用?Java JackrabbitAccessControlList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JackrabbitAccessControlList类属于org.apache.jackrabbit.api.security包,在下文中一共展示了JackrabbitAccessControlList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: after
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Override
public void after() throws Exception {
try {
if (testSession != null) {
testSession.close();
}
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
if (acl != null) {
for (AccessControlEntry ace : acl.getAccessControlEntries()) {
if (getTestUser().getPrincipal().equals(ace.getPrincipal())) {
acl.removeAccessControlEntry(ace);
}
}
}
acMgr.setPolicy("/", acl);
root.commit();
} finally {
super.after();
}
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:22,代码来源:PermissionStoreTest.java
示例2: createACL
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@CheckForNull
private JackrabbitAccessControlList createACL(@Nullable String oakPath,
@Nonnull Tree accessControlledTree,
boolean isEffectivePolicy) throws RepositoryException {
JackrabbitAccessControlList acl = null;
String aclName = Util.getAclName(oakPath);
if (accessControlledTree.exists() && Util.isAccessControlled(oakPath, accessControlledTree, ntMgr)) {
Tree aclTree = accessControlledTree.getChild(aclName);
if (aclTree.exists()) {
List<ACE> entries = new ArrayList<ACE>();
for (Tree child : aclTree.getChildren()) {
if (Util.isACE(child, ntMgr)) {
entries.add(createACE(oakPath, child, restrictionProvider));
}
}
if (isEffectivePolicy) {
acl = new ImmutableACL(oakPath, entries, restrictionProvider, getNamePathMapper());
} else {
acl = new NodeACL(oakPath, entries);
}
}
}
return acl;
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:25,代码来源:AccessControlManagerImpl.java
示例3: getACL
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@CheckForNull
private JackrabbitAccessControlList getACL(Tree tree) throws RepositoryException {
String nodeName = tree.getName();
JackrabbitAccessControlList acl = null;
if (!tree.isRoot()) {
Tree parent = tree.getParent();
if (AccessControlConstants.REP_POLICY.equals(nodeName)
&& ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)) {
acl = getACL(parent.getPath());
} else if (AccessControlConstants.REP_REPO_POLICY.equals(nodeName)
&& ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)
&& parent.isRoot()) {
acl = getACL((String) null);
}
}
if (acl != null) {
// clear all existing entries
for (AccessControlEntry ace: acl.getAccessControlEntries()) {
acl.removeAccessControlEntry(ace);
}
}
return acl;
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:27,代码来源:AccessControlImporter.java
示例4: testAclPropagation
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Test
public void testAclPropagation() throws Exception {
Tree node = root1.getTree("/").addChild("testNode");
node.setProperty("jcr:primaryType", "nt:unstructured");
User user1 = userManager1.createUser("testUser", "testUser");
JackrabbitAccessControlList acl1 = AccessControlUtils.getAccessControlList(aclMgr1, "/testNode");
acl1.addEntry(user1.getPrincipal(), AccessControlUtils.privilegesFromNames(aclMgr1, "jcr:all"), true);
aclMgr1.setPolicy("/testNode", acl1);
root1.commit();
syncClusterNodes();
root2.refresh();
JackrabbitAccessControlList acl2 = AccessControlUtils.getAccessControlList(aclMgr2, "/testNode");
AccessControlEntry[] aces = acl2.getAccessControlEntries();
assertEquals(1, aces.length);
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:17,代码来源:ClusterPermissionsTest.java
示例5: testCanReadProperties2
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Test
public void testCanReadProperties2() throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/test");
acl.addEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ), true);
acMgr.setPolicy("/test", acl);
root.commit();
Tree policyTree = root.getTree("/test/rep:policy");
NodeUtil ace = new NodeUtil(policyTree).addChild("ace2", NT_REP_DENY_ACE);
ace.setNames(REP_PRIVILEGES, PrivilegeConstants.REP_READ_PROPERTIES);
ace.setString(REP_PRINCIPAL_NAME, getTestUser().getPrincipal().getName());
root.commit();
TreePermission tp = getTreePermission("/test");
assertFalse(tp.canReadProperties());
assertTrue(tp.canRead());
assertFalse(tp.canReadProperties());
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:21,代码来源:TreePermissionImplTest.java
示例6: before
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Override
@Before
public void before() throws Exception {
super.before();
Principal testPrincipal = getTestPrincipal();
NodeUtil rootNode = new NodeUtil(root.getTree("/"), namePathMapper);
NodeUtil testNode = rootNode.addChild("testPath", JcrConstants.NT_UNSTRUCTURED);
testNode.addChild("childNode", JcrConstants.NT_UNSTRUCTURED);
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testPath);
acl.addAccessControlEntry(testPrincipal, privilegesFromNames(JCR_ADD_CHILD_NODES));
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(JCR_READ));
acMgr.setPolicy(testPath, acl);
root.commit();
testPrincipalName = testPrincipal.getName();
bitsProvider = new PrivilegeBitsProvider(root);
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:21,代码来源:PermissionHookTest.java
示例7: after
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Override
@After
public void after() throws Exception {
try {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
if (acl != null) {
boolean modified = false;
for (AccessControlEntry entry : acl.getAccessControlEntries()) {
if (entry.getPrincipal().equals(getTestUser().getPrincipal())) {
acl.removeAccessControlEntry(entry);
modified = true;
}
}
if (modified) {
acMgr.setPolicy("/", acl);
root.commit();
}
}
} finally {
super.after();
}
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:24,代码来源:Jr2CompatibilityTest.java
示例8: testDuplicateAce
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Test
public void testDuplicateAce() throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils.getAccessControlList(acMgr, testPath);
acl.addAccessControlEntry(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES));
acMgr.setPolicy(testPath, acl);
// add duplicate ac-entry on OAK-API
NodeUtil policy = new NodeUtil(root.getTree(testPath + "/rep:policy"));
NodeUtil ace = policy.addChild("duplicateAce", NT_REP_GRANT_ACE);
ace.setString(REP_PRINCIPAL_NAME, testPrincipal.getName());
ace.setStrings(AccessControlConstants.REP_PRIVILEGES, PrivilegeConstants.JCR_ADD_CHILD_NODES);
try {
root.commit();
fail("Creating duplicate ACE must be detected");
} catch (CommitFailedException e) {
assertTrue(e.isAccessControlViolation());
}
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:21,代码来源:AccessControlValidatorTest.java
示例9: testTestSessionGetEffectivePoliciesByPrincipals
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Test
public void testTestSessionGetEffectivePoliciesByPrincipals() throws Exception {
NodeUtil child = new NodeUtil(root.getTree(testPath)).addChild("child", JcrConstants.NT_UNSTRUCTURED);
String childPath = child.getTree().getPath();
Privilege[] privs = privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL);
setupPolicy(testPath, privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL));
JackrabbitAccessControlList acl = getApplicablePolicy(childPath);
acl.addEntry(EveryonePrincipal.getInstance(), privs, true);
acMgr.setPolicy(childPath, acl);
root.commit();
Root testRoot = getTestRoot();
testRoot.refresh();
JackrabbitAccessControlManager testAcMgr = getTestAccessControlManager();
Set<Principal> principals = ImmutableSet.of(getTestPrincipal(), EveryonePrincipal.getInstance());
AccessControlPolicy[] policies = testAcMgr.getEffectivePolicies(principals);
assertNotNull(policies);
assertEquals(2, policies.length);
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:24,代码来源:AccessControlManagerImplTest.java
示例10: testTestSessionGetEffectivePoliciesByPrincipals2
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
/**
* @since OAK 1.0 : only accessible policies are returned but not exception
* is raised.
*/
@Test
public void testTestSessionGetEffectivePoliciesByPrincipals2() throws Exception {
NodeUtil child = new NodeUtil(root.getTree(testPath)).addChild("child", JcrConstants.NT_UNSTRUCTURED);
String childPath = child.getTree().getPath();
Privilege[] privs = privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL);
// create policy on testPath -> but deny access to test session
JackrabbitAccessControlList acl = getApplicablePolicy(testPath);
acl.addEntry(getTestPrincipal(), privs, false);
acMgr.setPolicy(testPath, acl);
// grant access at childpath
setupPolicy(childPath, privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL));
root.commit();
Root testRoot = getTestRoot();
testRoot.refresh();
JackrabbitAccessControlManager testAcMgr = getTestAccessControlManager();
Set<Principal> principals = ImmutableSet.of(getTestPrincipal(), EveryonePrincipal.getInstance());
AccessControlPolicy[] policies = testAcMgr.getEffectivePolicies(principals);
assertNotNull(policies);
assertEquals(1, policies.length);
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:30,代码来源:AccessControlManagerImplTest.java
示例11: testEquals
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Test
public void testEquals() throws Exception {
RestrictionProvider rp = getRestrictionProvider();
ACE ace1 = createEntry(testPrincipal, false, null, PrivilegeConstants.JCR_VERSION_MANAGEMENT);
ACE ace2 = createEntry(testPrincipal, testPrivileges, true);
ACE ace2b = createEntry(testPrincipal, getAggregatedPrivileges(testPrivileges), true);
JackrabbitAccessControlList acl = createACL(ace1, ace2);
JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);
assertEquals(acl, createACL(ace1, ace2));
assertEquals(acl, createACL(ace1, ace2b));
assertEquals(repoAcl, createACL((String) null, ace1, ace2b));
assertFalse(acl.equals(createACL(ace2, ace1)));
assertFalse(acl.equals(repoAcl));
assertFalse(acl.equals(createEmptyACL()));
assertFalse(acl.equals(createACL("/anotherPath", ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp, ace1, ace2)));
assertFalse(acl.equals(new TestACL("/anotherPath", rp)));
assertFalse(acl.equals(new TestACL(getTestPath(), rp, ace1, ace2)));
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:25,代码来源:ImmutableACLTest.java
示例12: testHashCode
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Test
public void testHashCode() throws Exception {
RestrictionProvider rp = getRestrictionProvider();
ACE ace1 = createEntry(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false);
ACE ace2 = createEntry(testPrincipal, testPrivileges, true);
ACE ace2b = createEntry(testPrincipal, getAggregatedPrivileges(testPrivileges), true);
JackrabbitAccessControlList acl = createACL(ace1, ace2);
JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);
int hc = acl.hashCode();
assertTrue(hc == createACL(ace1, ace2).hashCode());
assertTrue(hc == createACL(ace1, ace2b).hashCode());
assertTrue(repoAcl.hashCode() == createACL((String) null, ace1, ace2b).hashCode());
assertFalse(hc == createACL(ace2, ace1).hashCode());
assertFalse(hc == repoAcl.hashCode());
assertFalse(hc == createEmptyACL().hashCode());
assertFalse(hc == createACL("/anotherPath", ace1, ace2).hashCode());
assertFalse(hc == new TestACL("/anotherPath", rp, ace1, ace2).hashCode());
assertFalse(hc == new TestACL("/anotherPath", rp, ace1, ace2).hashCode());
assertFalse(hc == new TestACL("/anotherPath", rp).hashCode());
assertFalse(hc == new TestACL(getTestPath(), rp, ace1, ace2).hashCode());
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:26,代码来源:ImmutableACLTest.java
示例13: removeAces
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
/**
* Removes all ACEs for the Service User principal (except those that live beneath the System User's rep:User node)
*
* @param resourceResolver the resource resolver to perform the user management
* @param systemUser the System User the Service User represents
* @param serviceUser the Service User
* @throws RepositoryException
*/
private void removeAces(ResourceResolver resourceResolver, User systemUser, ServiceUser serviceUser) throws RepositoryException {
final Session session = resourceResolver.adaptTo(Session.class);
final JackrabbitAccessControlManager accessControlManager = (JackrabbitAccessControlManager) session.getAccessControlManager();
final List<JackrabbitAccessControlList> acls = findAcls(resourceResolver, serviceUser.getPrincipalName(), accessControlManager);
for (final JackrabbitAccessControlList acl : acls) {
final JackrabbitAccessControlEntry[] aces = (JackrabbitAccessControlEntry[]) acl.getAccessControlEntries();
// Check all the existing ACEs in the ACL
for (JackrabbitAccessControlEntry ace : aces) {
if (StringUtils.equals(serviceUser.getPrincipalName(), ace.getPrincipal().getName())) {
if (systemUser != null && StringUtils.startsWith(acl.getPath(), systemUser.getPath())) {
// Skip! Don't ensureRemoval ACE's from the system user itself!
} else {
acl.removeAccessControlEntry(ace);
}
}
}
accessControlManager.setPolicy(acl.getPath(), acl);
log.debug("Removed ACE from ACL at [ {} ] for [ {} ]", acl.getPath(), serviceUser.getPrincipalName());
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:33,代码来源:EnsureServiceUser.java
示例14: getModifiableAcl
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
public static JackrabbitAccessControlList getModifiableAcl(final AccessControlManager accessManager,
final String path) throws RepositoryException {
final JackrabbitAccessControlList acl = getAccessControlList(accessManager, path);
if (null != acl) {
return acl;
}
final JackrabbitAccessControlList applicableAcl = getApplicableAccessControlList(accessManager, path);
if (null != applicableAcl) {
return applicableAcl;
}
throw new AccessControlException("No modifiable ACL at " + path);
}
开发者ID:Cognifide,项目名称:APM,代码行数:15,代码来源:JackrabbitAccessControlListUtil.java
示例15: getApplicableAccessControlList
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
public static JackrabbitAccessControlList getApplicableAccessControlList(
final AccessControlManager accessManager, final String path) throws RepositoryException {
// find policies which may be applied to node indicated by path (may be treated as policy factory)
final AccessControlPolicyIterator applicablePolicies = accessManager.getApplicablePolicies(path);
while (applicablePolicies.hasNext()) {
final AccessControlPolicy policy = applicablePolicies.nextAccessControlPolicy();
if (policy instanceof JackrabbitAccessControlList) {
return (JackrabbitAccessControlList) policy;
}
}
return null;
}
开发者ID:Cognifide,项目名称:APM,代码行数:13,代码来源:JackrabbitAccessControlListUtil.java
示例16: getAccessControlList
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
public static JackrabbitAccessControlList getAccessControlList(final AccessControlManager accessManager,
final String path) throws RepositoryException {
final AccessControlPolicy[] existing = accessManager.getPolicies(path);
for (final AccessControlPolicy policy : existing) {
if (policy instanceof JackrabbitAccessControlList) {
return (JackrabbitAccessControlList) policy;
}
}
return null;
}
开发者ID:Cognifide,项目名称:APM,代码行数:11,代码来源:JackrabbitAccessControlListUtil.java
示例17: updateAccessControlList
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
private void updateAccessControlList(boolean allow, final AccessControlManager accessControlManager,
final List<Privilege> privileges, final Principal principal) throws RepositoryException {
final JackrabbitAccessControlList jackrabbitAcl = JackrabbitAccessControlListUtil
.getModifiableAcl(accessControlManager, path);
if (StringUtils.isBlank(glob)) {
addNormalEntry(allow, privileges, principal, jackrabbitAcl);
} else {
addGlobEntry(allow, privileges, principal, jackrabbitAcl);
}
accessControlManager.setPolicy(path, jackrabbitAcl);
}
开发者ID:Cognifide,项目名称:APM,代码行数:14,代码来源:PermissionActionHelper.java
示例18: addGlobEntry
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
private void addGlobEntry(boolean allow, final List<Privilege> privileges, final Principal principal,
final JackrabbitAccessControlList jackrabbitAcl) throws RepositoryException {
final Map<String, Value> globRestrictions = new HashMap<>();
globRestrictions.put("rep:glob", getGlobValue());
jackrabbitAcl.addEntry(principal, privileges.toArray(new Privilege[privileges.size()]), allow,
globRestrictions);
}
开发者ID:Cognifide,项目名称:APM,代码行数:8,代码来源:PermissionActionHelper.java
示例19: removeAll
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
private void removeAll(final Context context, Authorizable authorizable) throws RepositoryException {
final AccessControlManager accessControlManager = context.getAccessControlManager();
final Principal principal = authorizable.getPrincipal();
final JackrabbitAccessControlList jackrabbitAcl = JackrabbitAccessControlListUtil
.getModifiableAcl(accessControlManager, path);
final AccessControlEntry[] accessControlEntries = jackrabbitAcl.getAccessControlEntries();
for (final AccessControlEntry accessControlEntry : accessControlEntries) {
if (accessControlEntry.getPrincipal().equals(principal)) {
jackrabbitAcl.removeAccessControlEntry(accessControlEntry);
}
}
accessControlManager.setPolicy(path, jackrabbitAcl);
}
开发者ID:Cognifide,项目名称:APM,代码行数:15,代码来源:RemoveAll.java
示例20: createPrincipalACL
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; //导入依赖的package包/类
@Nullable
private JackrabbitAccessControlList createPrincipalACL(@Nullable String oakPath,
@Nonnull Principal principal) throws RepositoryException {
Root root = getRoot();
Result aceResult = searchAces(Collections.<Principal>singleton(principal), root);
RestrictionProvider restrProvider = new PrincipalRestrictionProvider(restrictionProvider);
List<ACE> entries = new ArrayList<ACE>();
for (ResultRow row : aceResult.getRows()) {
Tree aceTree = root.getTree(row.getPath());
if (Util.isACE(aceTree, ntMgr)) {
String aclPath = Text.getRelativeParent(aceTree.getPath(), 1);
String path;
if (aclPath.endsWith(REP_REPO_POLICY)) {
path = null;
} else {
path = Text.getRelativeParent(aclPath, 1);
}
entries.add(createACE(path, aceTree, restrProvider));
}
}
if (entries.isEmpty()) {
// nothing found
return null;
} else {
return new PrincipalACL(oakPath, principal, entries, restrProvider);
}
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:28,代码来源:AccessControlManagerImpl.java
注:本文中的org.apache.jackrabbit.api.security.JackrabbitAccessControlList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论