Search in sources :

Example 71 with PrincipalImpl

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

the class AccessControlManagerImplTest method testGetApplicablePoliciesInternalPrincipal.

@Test
public void testGetApplicablePoliciesInternalPrincipal() throws Exception {
    Principal unknown = getPrincipalManager(root).getPrincipal("unknown");
    int i = 0;
    while (unknown != null) {
        unknown = getPrincipalManager(root).getPrincipal("unknown" + i);
    }
    unknown = new PrincipalImpl("unknown" + i);
    assertEquals(1, acMgr.getApplicablePolicies(unknown).length);
}
Also used : Principal(java.security.Principal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 72 with PrincipalImpl

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

the class AbstractPrincipalProviderTest method before.

@Override
public void before() throws Exception {
    super.before();
    userPrincipal = getTestUser().getPrincipal();
    nonExisting = new PrincipalImpl("nonExisting");
    groupId = "testGroup" + UUID.randomUUID();
    testGroup = getUserManager(root).createGroup(groupId);
    testGroup.addMember(getTestUser());
    groupId2 = "testGroup2" + UUID.randomUUID();
    testGroup2 = getUserManager(root).createGroup(groupId2);
    testGroup.addMember(testGroup2);
    root.commit();
    principalProvider = createPrincipalProvider();
    assertNull(principalProvider.getPrincipal(nonExisting.getName()));
}
Also used : PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)

Example 73 with PrincipalImpl

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

the class AbstractGroupPrincipalTest method testIsMemberOf.

@Test
public void testIsMemberOf() throws Exception {
    final Principal p = getTestUser().getPrincipal();
    assertTrue(agp.isMember(p));
    assertTrue(agp.isMember(new PrincipalImpl(p.getName())));
    assertTrue(agp.isMember(new Principal() {

        @Override
        public String getName() {
            return p.getName();
        }
    }));
}
Also used : Principal(java.security.Principal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 74 with PrincipalImpl

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

the class AuthorizablePropertiesImplTest method before.

@Override
public void before() throws Exception {
    super.before();
    User user = getTestUser();
    emptyProperties = new AuthorizablePropertiesImpl((AuthorizableImpl) user, getNamePathMapper());
    String id2 = "user2" + UUID.randomUUID().toString();
    user2 = getUserManager(root).createUser(id2, null, new PrincipalImpl(id2), PathUtils.getAncestorPath(user.getPath(), 1));
    vf = getValueFactory(root);
    Value v = vf.createValue("value");
    Value[] vArr = new Value[] { vf.createValue(2), vf.createValue(30) };
    user2.setProperty("prop", v);
    user2.setProperty("mvProp", vArr);
    user2.setProperty("relPath/prop", v);
    user2.setProperty("relPath/mvProp", vArr);
    root.commit();
    properties = new AuthorizablePropertiesImpl((AuthorizableImpl) user2, getNamePathMapper());
}
Also used : User(org.apache.jackrabbit.api.security.user.User) Value(javax.jcr.Value) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)

Example 75 with PrincipalImpl

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

the class RandomAuthorizableNodeNameTest method testCreateUserWithPath.

@Test
public void testCreateUserWithPath() throws Exception {
    User user = getUserManager(root).createUser(id, "pw", new PrincipalImpl(id), "a/b");
    root.commit();
    assertNodeName(user, "a/b");
}
Also used : User(org.apache.jackrabbit.api.security.user.User) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

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