Search in sources :

Example 61 with PrincipalImpl

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.

the class CugExcludeDefaultTest method testMixedPrincipals.

@Test
public void testMixedPrincipals() {
    Set<Principal> principals = new HashSet<Principal>();
    principals.add(new PrincipalImpl("test"));
    principals.add(new SystemUserPrincipal() {

        @Override
        public String getName() {
            return "test";
        }
    });
    assertTrue(exclude.isExcluded(principals));
}
Also used : SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) SystemPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) Principal(java.security.Principal) ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 62 with PrincipalImpl

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.

the class LoginWithMembersTest method beforeSuite.

@Override
public void beforeSuite() throws Exception {
    super.beforeSuite();
    Session s = loginAdministrative();
    try {
        UserManager userManager = ((JackrabbitSession) s).getUserManager();
        Authorizable user = userManager.getAuthorizable(USER);
        Group gr = userManager.createGroup(new PrincipalImpl(GROUP), "test");
        gr.addMember(user);
        // add other members to this group which the test user is not member of.
        for (int i = 1; i < numberOfMembers; i++) {
            Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), "test");
            gr.addMember(g);
        }
        s.save();
    } finally {
        s.logout();
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UserManager(org.apache.jackrabbit.api.security.user.UserManager) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 63 with PrincipalImpl

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.

the class GetAuthorizableByPrincipalTest method runTest.

@Override
protected void runTest() throws Exception {
    Session s = loginWriter();
    UserManager userManager = ((JackrabbitSession) s).getUserManager();
    for (int i = 0; i < 1000; i++) {
        Authorizable a = userManager.getAuthorizable(new PrincipalImpl(getUserId()));
    }
}
Also used : UserManager(org.apache.jackrabbit.api.security.user.UserManager) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 64 with PrincipalImpl

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.

the class FindAuthorizableWithScopeTest method beforeSuite.

@Override
protected void beforeSuite() throws Exception {
    adminSession = loginWriter();
    userMgr = ((JackrabbitSession) adminSession).getUserManager();
    Group gr = userMgr.createGroup(GROUP_ID, new PrincipalImpl(GROUP_ID), "test");
    for (int i = 0; i < numberOfUsers; i++) {
        User u = userMgr.createUser("testUser" + i, null, new PrincipalImpl("testUser" + i), "test");
        gr.addMember(u);
    }
    adminSession.save();
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) User(org.apache.jackrabbit.api.security.user.User) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)

Example 65 with PrincipalImpl

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.

the class AddMembersTest method beforeSuite.

@Override
public void beforeSuite() throws Exception {
    super.beforeSuite();
    Session s = loginAdministrative();
    try {
        UserManager userManager = ((JackrabbitSession) s).getUserManager();
        for (int i = 0; i <= GROUP_CNT; i++) {
            Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), REL_TEST_PATH);
            groupPaths.add(g.getPath());
        }
        createUsers(userManager);
    } finally {
        s.save();
        s.logout();
    }
    System.out.println("setup done");
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UserManager(org.apache.jackrabbit.api.security.user.UserManager) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Aggregations

PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)87 Test (org.junit.Test)59 Principal (java.security.Principal)39 Group (org.apache.jackrabbit.api.security.user.Group)23 User (org.apache.jackrabbit.api.security.user.User)20 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)20 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)19 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)15 UserManager (org.apache.jackrabbit.api.security.user.UserManager)14 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)11 Session (javax.jcr.Session)8 SimpleCredentials (javax.jcr.SimpleCredentials)7 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)6 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)6 CugPolicy (org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy)6 HashSet (java.util.HashSet)5 Nonnull (javax.annotation.Nonnull)4 SystemPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal)4 ArrayList (java.util.ArrayList)3 AccessControlList (javax.jcr.security.AccessControlList)3