Search in sources :

Example 81 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.

the class ConcurrentHasPermissionTest2 method createDeepTree.

@Override
protected void createDeepTree() throws Exception {
    UserManager uMgr = ((JackrabbitSession) adminSession).getUserManager();
    for (int i = 0; i < 100; i++) {
        Authorizable a = uMgr.getAuthorizable("group" + i);
        if (a == null) {
            a = uMgr.createGroup("group" + i);
            principals.add(a.getPrincipal());
        }
    }
    super.createDeepTree();
}
Also used : UserManager(org.apache.jackrabbit.api.security.user.UserManager) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 82 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.

the class ConcurrentReadAccessControlledTreeTest2 method createDeepTree.

@Override
protected void createDeepTree() throws Exception {
    UserManager uMgr = ((JackrabbitSession) adminSession).getUserManager();
    for (int i = 0; i < 100; i++) {
        Authorizable a = uMgr.getAuthorizable("group" + i);
        if (a == null) {
            a = uMgr.createGroup("group" + i);
            principals.add(a.getPrincipal());
        }
    }
    super.createDeepTree();
}
Also used : UserManager(org.apache.jackrabbit.api.security.user.UserManager) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 83 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.

the class ConcurrentCreateNodesTest method beforeSuite.

@Override
protected void beforeSuite() throws Exception {
    Session session = loginWriter();
    if (DISABLE_INDEX) {
        disableNodeTypeIndex(session);
    }
    Node rootNode = session.getRootNode();
    if (rootNode.hasNode(ROOT_NODE_NAME)) {
        Node root = rootNode.getNode(ROOT_NODE_NAME);
        root.remove();
    }
    rootNode = session.getRootNode().addNode(ROOT_NODE_NAME, NODE_TYPE);
    for (int i = 0; i < WORKER_COUNT; i++) {
        rootNode.addNode("node" + i);
    }
    session.save();
    for (int i = 1; i < WORKER_COUNT; i++) {
        addBackgroundJob(new Writer(rootNode.getPath() + "/node" + i));
    }
    UserManager uMgr = ((JackrabbitSession) session).getUserManager();
    String userId;
    String password;
    if (NON_ADMIN_LISTENER) {
        userId = "user-" + System.currentTimeMillis();
        password = "secret";
        uMgr.createUser(userId, password);
        session.save();
    } else {
        userId = "admin";
        password = "admin";
    }
    createACLsForEveryone(session, ACL_COUNT);
    for (int i = 0; i < LISTENER_COUNT; i++) {
        Session s = login(new SimpleCredentials(userId, password.toCharArray()));
        s.getWorkspace().getObservationManager().addEventListener(new Listener(), EVENT_TYPES, LISTENER_PATH, true, null, null, false);
    }
    writer = new Writer(rootNode.getPath() + "/node" + 0);
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) EventListener(javax.jcr.observation.EventListener) UserManager(org.apache.jackrabbit.api.security.user.UserManager) Node(javax.jcr.Node) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 84 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.

the class GetGroupPrincipalsTest method runTest.

@Override
public void runTest() throws Exception {
    PrincipalManager principalManager = ((JackrabbitSession) session).getPrincipalManager();
    for (int i = 0; i < 1000; i++) {
        Principal p = principalManager.getPrincipal(principalName);
        PrincipalIterator principals = principalManager.getGroupMembership(p);
    //            while (principals.hasNext()) {
    //                Principal groupPrincipal = principals.nextPrincipal();
    //            }
    }
}
Also used : PrincipalManager(org.apache.jackrabbit.api.security.principal.PrincipalManager) PrincipalIterator(org.apache.jackrabbit.api.security.principal.PrincipalIterator) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Principal(java.security.Principal)

Example 85 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.

the class GetGroupPrincipalsTest method afterSuite.

@Override
public void afterSuite() throws Exception {
    UserManager userMgr = ((JackrabbitSession) session).getUserManager();
    Authorizable authorizable = userMgr.getAuthorizable(USER);
    if (authorizable != null) {
        authorizable.remove();
    }
    authorizable = userMgr.getAuthorizable(GROUP);
    if (authorizable != null) {
        Node n = session.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
        n.remove();
    }
    session.save();
}
Also used : UserManager(org.apache.jackrabbit.api.security.user.UserManager) Node(javax.jcr.Node) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Aggregations

JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)114 UserManager (org.apache.jackrabbit.api.security.user.UserManager)51 Session (javax.jcr.Session)50 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)34 Node (javax.jcr.Node)25 Group (org.apache.jackrabbit.api.security.user.Group)25 User (org.apache.jackrabbit.api.security.user.User)24 Principal (java.security.Principal)19 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)17 Test (org.junit.Test)16 SimpleCredentials (javax.jcr.SimpleCredentials)15 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)11 RepositoryException (javax.jcr.RepositoryException)10 PrincipalIterator (org.apache.jackrabbit.api.security.principal.PrincipalIterator)9 PrincipalManager (org.apache.jackrabbit.api.security.principal.PrincipalManager)9 Privilege (javax.jcr.security.Privilege)8 LoginException (javax.jcr.LoginException)6 Property (javax.jcr.Property)6 ItemBasedPrincipal (org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal)6 Item (javax.jcr.Item)5