Search in sources :

Example 1 with JackrabbitPrincipal

use of org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal in project jackrabbit by apache.

the class EveryonePrincipalTest method testEveryonePrincipal3.

public void testEveryonePrincipal3() {
    Principal everyone = EveryonePrincipal.getInstance();
    Principal someotherEveryone = new JackrabbitPrincipal() {

        public String getName() {
            return EveryonePrincipal.NAME;
        }

        @Override
        public boolean equals(Object o) {
            if (o instanceof JackrabbitPrincipal) {
                return getName().equals(((JackrabbitPrincipal) o).getName());
            }
            return false;
        }

        @Override
        public int hashCode() {
            return getName().hashCode();
        }
    };
    assertEquals(someotherEveryone, everyone);
    assertEquals(everyone, someotherEveryone);
}
Also used : JackrabbitPrincipal(org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal) Principal(java.security.Principal) JackrabbitPrincipal(org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal)

Example 2 with JackrabbitPrincipal

use of org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal in project jackrabbit by apache.

the class PrincipalManagerTest method testJackrabbitPrincipal.

/**
     * Test if a group which is not item based will be wrapped by a JackrabbitPrincipal implementation.
     * @throws NotExecutableException
     * @throws RepositoryException
     */
public void testJackrabbitPrincipal() throws NotExecutableException, RepositoryException {
    final PrincipalProvider testProvider = new CustomPrincipalProvider();
    testProvider.init(new Properties());
    PrincipalManagerImpl principalManager = new PrincipalManagerImpl(superuser, new PrincipalProvider[] { testProvider });
    Principal principalFromManager = principalManager.getPrincipal(TESTGROUP_NAME);
    assertTrue(principalFromManager instanceof JackrabbitPrincipal);
}
Also used : JackrabbitPrincipal(org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal) Properties(java.util.Properties) Principal(java.security.Principal) JackrabbitPrincipal(org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal)

Example 3 with JackrabbitPrincipal

use of org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal in project jackrabbit-oak by apache.

the class PrincipalImplTest method testEquals.

@Test
public void testEquals() {
    List<Principal> principals = new ArrayList<Principal>();
    principals.add(new PrincipalImpl("name"));
    principals.add(new TestPrincipal("name"));
    principals.add(new JackrabbitPrincipal() {

        @Override
        public String getName() {
            return "name";
        }
    });
    for (Principal p : principals) {
        assertEquals(principal, p);
    }
}
Also used : ArrayList(java.util.ArrayList) JackrabbitPrincipal(org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal) Principal(java.security.Principal) JackrabbitPrincipal(org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal) Test(org.junit.Test)

Aggregations

Principal (java.security.Principal)3 JackrabbitPrincipal (org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal)3 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Test (org.junit.Test)1