use of org.apache.jackrabbit.core.security.authorization.CompiledPermissions in project jackrabbit by apache.
the class UserAccessControlProviderTest method testAnonymousDefaultAccess.
public void testAnonymousDefaultAccess() throws Exception {
Set<Principal> anonymousPrincipals = getAnonymousPrincipals();
assertTrue(provider.canAccessRoot(anonymousPrincipals));
CompiledPermissions cp = provider.compilePermissions(anonymousPrincipals);
assertTrue(cp.canReadAll());
assertFalse(CompiledPermissions.NO_PERMISSION.equals(cp));
}
use of org.apache.jackrabbit.core.security.authorization.CompiledPermissions in project jackrabbit by apache.
the class UserAccessControlProviderTest method testAnonymousAccessDenied2.
public void testAnonymousAccessDenied2() throws Exception {
Map<String, String> config = new HashMap<String, String>();
config.put(UserAccessControlProvider.PARAM_ANONYMOUS_ACCESS, "false");
config.put(UserAccessControlProvider.PARAM_ANONYMOUS_ID, "abc");
AccessControlProvider p2 = new UserAccessControlProvider();
try {
p2.init(s, config);
Principal princ = new Principal() {
public String getName() {
return "abc";
}
};
Set<Principal> anonymousPrincipals = Collections.singleton(princ);
assertFalse(p2.canAccessRoot(anonymousPrincipals));
CompiledPermissions cp = p2.compilePermissions(anonymousPrincipals);
try {
assertEquals(CompiledPermissions.NO_PERMISSION, cp);
assertFalse(cp.canReadAll());
assertFalse(cp.grants(((NodeImpl) s.getRootNode()).getPrimaryPath(), Permission.READ));
} finally {
cp.close();
}
} finally {
p2.close();
}
}
use of org.apache.jackrabbit.core.security.authorization.CompiledPermissions in project jackrabbit by apache.
the class UserAccessControlProviderTest method testNoNodeForPrincipal.
/**
* @see <a href="https://issues.apache.org/jira/browse/JCR-2630">JCR-2630</a>
*/
public void testNoNodeForPrincipal() throws RepositoryException {
final Principal testPrincipal = getTestPrincipal();
String path = "/home/users/t/" + testPrincipal.getName();
while (s.nodeExists(path)) {
path += "_";
}
final String principalPath = path;
List<Set<Principal>> principalSets = new ArrayList<Set<Principal>>();
principalSets.add(Collections.<Principal>singleton(testPrincipal));
principalSets.add(Collections.<Principal>singleton(new ItemBasedPrincipal() {
public String getPath() {
return principalPath;
}
public String getName() {
return testPrincipal.getName();
}
}));
Path rootPath = ((SessionImpl) s).getQPath("/");
for (Set<Principal> principals : principalSets) {
CompiledPermissions cp = provider.compilePermissions(principals);
assertFalse(cp.canReadAll());
assertFalse(cp.grants(rootPath, Permission.READ));
assertTrue(cp.getPrivilegeSet(rootPath).isEmpty());
assertSame(CompiledPermissions.NO_PERMISSION, cp);
}
}
use of org.apache.jackrabbit.core.security.authorization.CompiledPermissions in project jackrabbit by apache.
the class UserAccessControlProviderTest method testAnonymousAccessDenied.
public void testAnonymousAccessDenied() throws Exception {
Map<String, String> config = new HashMap<String, String>();
config.put(UserAccessControlProvider.PARAM_ANONYMOUS_ACCESS, "false");
AccessControlProvider p2 = new UserAccessControlProvider();
try {
p2.init(s, config);
Set<Principal> anonymousPrincipals = getAnonymousPrincipals();
assertFalse(p2.canAccessRoot(anonymousPrincipals));
CompiledPermissions cp = p2.compilePermissions(anonymousPrincipals);
try {
assertEquals(CompiledPermissions.NO_PERMISSION, cp);
assertFalse(cp.canReadAll());
assertFalse(cp.grants(((NodeImpl) s.getRootNode()).getPrimaryPath(), Permission.READ));
} finally {
cp.close();
}
} finally {
p2.close();
}
}
use of org.apache.jackrabbit.core.security.authorization.CompiledPermissions in project jackrabbit by apache.
the class DefaultAccessManager method getPrivileges.
/**
* @see org.apache.jackrabbit.api.security.JackrabbitAccessControlManager#getPrivileges(String, Set)
*/
public Privilege[] getPrivileges(String absPath, Set<Principal> principals) throws PathNotFoundException, RepositoryException {
checkInitialized();
checkValidNodePath(absPath);
checkPermission(absPath, Permission.READ_AC);
CompiledPermissions perms = acProvider.compilePermissions(principals);
try {
Set<Privilege> privs = perms.getPrivilegeSet(getPath(absPath));
return privs.toArray(new Privilege[privs.size()]);
} finally {
perms.close();
}
}
Aggregations