Search in sources :

Example 61 with JackrabbitSession

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

the class GetOrNullTest method testGetNodeOrNullNonExisting.

public void testGetNodeOrNullNonExisting() throws RepositoryException {
    JackrabbitSession js = (JackrabbitSession) superuser;
    Node node = js.getNodeOrNull(PATH_NON_EXISTING_NODE);
    assertNull(node);
}
Also used : Node(javax.jcr.Node) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 62 with JackrabbitSession

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

the class GetOrNullTest method testGetItemOrNullNonExistingProperty.

public void testGetItemOrNullNonExistingProperty() throws RepositoryException {
    JackrabbitSession js = (JackrabbitSession) superuser;
    Item item = js.getItemOrNull(PATH_NON_EXISTING_PROPERTY);
    assertNull(item);
}
Also used : Item(javax.jcr.Item) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 63 with JackrabbitSession

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

the class GetOrNullTest method testGetPropertyOrNullExisting.

public void testGetPropertyOrNullExisting() throws RepositoryException {
    JackrabbitSession js = (JackrabbitSession) superuser;
    Property property = js.getPropertyOrNull(PATH_EXISTING_PROPERTY);
    assertNotNull(property);
    assertEquals(property.getPath(), PATH_EXISTING_PROPERTY);
}
Also used : JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Property(javax.jcr.Property)

Example 64 with JackrabbitSession

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

the class GetOrNullTest method testGetItemOrNullExistingNode.

public void testGetItemOrNullExistingNode() throws RepositoryException {
    JackrabbitSession js = (JackrabbitSession) superuser;
    Item item = js.getItemOrNull(PATH_EXISTING_NODE);
    assertNotNull(item);
    assertTrue(item instanceof Node);
    assertEquals(item.getPath(), PATH_EXISTING_NODE);
}
Also used : Item(javax.jcr.Item) Node(javax.jcr.Node) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 65 with JackrabbitSession

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

the class AuthorizableTest method testRecreateUser.

public void testRecreateUser() throws RepositoryException, NotExecutableException {
    String id = "bla";
    Authorizable auth = userMgr.getAuthorizable(id);
    if (auth == null) {
        auth = userMgr.createUser(id, id);
    }
    auth.remove();
    save(superuser);
    assertNull(userMgr.getAuthorizable(id));
    // recreate the user using another session.
    Session s2 = getHelper().getSuperuserSession();
    User u2 = null;
    try {
        UserManager umgr = ((JackrabbitSession) s2).getUserManager();
        assertNull(umgr.getAuthorizable(id));
        // recreation must succeed
        u2 = umgr.createUser(id, id);
        // must be present with both session.
        assertNotNull(umgr.getAuthorizable(id));
        assertNotNull(userMgr.getAuthorizable(id));
    } finally {
        if (u2 != null) {
            u2.remove();
            save(s2);
        }
        s2.logout();
    }
}
Also used : JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Session(javax.jcr.Session) 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