Search in sources :

Example 31 with JackrabbitSession

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

the class GetOrNullTest method testGetPropertyOrNullNonExisting.

public void testGetPropertyOrNullNonExisting() throws RepositoryException {
    JackrabbitSession js = (JackrabbitSession) superuser;
    Property property = js.getPropertyOrNull(PATH_NON_EXISTING_PROPERTY);
    assertNull(property);
}
Also used : JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Property(javax.jcr.Property)

Example 32 with JackrabbitSession

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

the class AbstractACLTemplateTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    if (!(superuser instanceof JackrabbitSession)) {
        throw new NotExecutableException();
    }
    principalMgr = ((JackrabbitSession) superuser).getPrincipalManager();
    PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP);
    if (it.hasNext()) {
        testPrincipal = it.nextPrincipal();
    } else {
        throw new NotExecutableException();
    }
    privilegeMgr = (PrivilegeManagerImpl) ((JackrabbitWorkspace) superuser.getWorkspace()).getPrivilegeManager();
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PrincipalIterator(org.apache.jackrabbit.api.security.principal.PrincipalIterator) JackrabbitWorkspace(org.apache.jackrabbit.api.JackrabbitWorkspace) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 33 with JackrabbitSession

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

the class AddMembersTest method afterSuite.

@Override
public void afterSuite() throws Exception {
    Session s = loginAdministrative();
    try {
        Authorizable authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(GROUP + "0");
        if (authorizable != null) {
            Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
            n.remove();
        }
        if (!ImportBehavior.NAME_BESTEFFORT.equals(importBehavior)) {
            authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(USER + "0");
            if (authorizable != null) {
                Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
                n.remove();
            }
        }
        s.save();
    } finally {
        s.logout();
    }
}
Also used : Node(javax.jcr.Node) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 34 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession 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();
    }
}
Also used : Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 35 with JackrabbitSession

use of org.apache.jackrabbit.api.JackrabbitSession 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();
    }
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) 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