use of javax.jcr.Session in project jackrabbit-oak by apache.
the class ConcurrentEveryoneACLTest method runTest.
@Override
public void runTest() throws Exception {
Session session = null;
try {
session = runAsAdmin ? loginWriter() : loginAnonymous();
for (int i = 0; i < itemsToRead; i++) {
session.refresh(false);
int a = random.nextInt(NODE_COUNT);
int b = random.nextInt(NODE_COUNT);
String path = "/" + ROOT_NODE_NAME + "/node" + a + "/node" + b + "/jcr:primaryType";
session.getProperty(path).getString();
}
} finally {
if (session != null) {
session.logout();
}
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class ConcurrentEveryoneACLTest method beforeSuite.
@Override
public void beforeSuite() throws Exception {
Session session = loginWriter();
AccessControlManager acMgr = session.getAccessControlManager();
Privilege[] privileges = new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_READ), acMgr.privilegeFromName(Privilege.JCR_READ_ACCESS_CONTROL) };
final Node root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
for (int i = 0; i < NODE_COUNT; i++) {
Node node = root.addNode("node" + i, "nt:unstructured");
for (int j = 0; j < NODE_COUNT; j++) {
Node newNode = node.addNode("node" + j, "nt:unstructured");
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(session, newNode.getPath());
acl.addEntry(EveryonePrincipal.getInstance(), privileges, true);
acMgr.setPolicy(newNode.getPath(), acl);
}
session.save();
}
// deny everyone on root node
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(session, root.getPath());
acl.addEntry(EveryonePrincipal.getInstance(), privileges, false);
acMgr.setPolicy(root.getPath(), acl);
session.save();
final int[] numACEs = new int[1];
ItemVisitor v = new TraversingItemVisitor.Default() {
@Override
protected void entering(Node node, int i) throws RepositoryException {
if (node.isNodeType(AccessControlConstants.NT_REP_ACE)) {
numACEs[0]++;
}
super.entering(node, i);
}
@Override
protected void entering(Property prop, int i) throws RepositoryException {
super.entering(prop, i);
}
};
v.visit(root);
System.out.println("Num ACEs: " + numACEs[0]);
session.logout();
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class ConcurrentEveryoneACLTest method afterSuite.
@Override
public void afterSuite() throws Exception {
Session session = loginWriter();
Node root = session.getRootNode().getNode(ROOT_NODE_NAME);
root.remove();
session.logout();
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class AbstractLoginTest method beforeSuite.
@Override
public void beforeSuite() throws Exception {
Session s = loginAdministrative();
try {
AccessControlUtils.addAccessControlEntry(s, "/", EveryonePrincipal.getInstance(), new String[] { Privilege.JCR_READ }, true);
if (USER.equals(runAsUser)) {
((JackrabbitSession) s).getUserManager().createUser(USER, USER);
}
} finally {
s.save();
s.logout();
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class AbstractLoginTest method afterSuite.
@Override
public void afterSuite() throws Exception {
Session s = loginAdministrative();
try {
Authorizable authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(USER);
if (authorizable != null) {
authorizable.remove();
s.save();
}
} finally {
s.logout();
}
}
Aggregations