Search in sources :

Example 71 with User

use of org.osgi.service.useradmin.User in project felix by apache.

the class CustomRoleImplTest method testAddUserCredentialsYieldsEvent.

/**
 * Tests that changing the credentials of a user-role yields an event.
 */
public void testAddUserCredentialsYieldsEvent() throws Exception {
    final User role = (User) m_repository.addRole("testUser", Role.USER);
    assertNotNull(role);
    m_latch = new CountDownLatch(1);
    new Thread(new Runnable() {

        public void run() {
            role.getCredentials().put("key", "value");
        }
    }).start();
    assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
Also used : User(org.osgi.service.useradmin.User) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 72 with User

use of org.osgi.service.useradmin.User in project felix by apache.

the class CustomRoleImplTest method testRemoveUserCredentialsYieldsEvent.

/**
 * Tests that changing the credentials of a user-role yields an event.
 */
public void testRemoveUserCredentialsYieldsEvent() throws Exception {
    final User role = (User) m_repository.addRole("testUser", Role.USER);
    role.getCredentials().put("key", "value");
    assertNotNull(role);
    m_latch = new CountDownLatch(1);
    new Thread(new Runnable() {

        public void run() {
            role.getCredentials().remove("key");
        }
    }).start();
    assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
Also used : User(org.osgi.service.useradmin.User) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 73 with User

use of org.osgi.service.useradmin.User in project felix by apache.

the class RoleCheckerTest method testGroupDoesNotImplyNotImpliedUser.

/**
 * Test that a user does never imply a group to which it is not a member.
 */
public void testGroupDoesNotImplyNotImpliedUser() {
    User user = RoleFactory.createUser("foo");
    Group group = RoleFactory.createGroup("bar");
    group.addMember(user);
    assertFalse(m_roleChecker.isImpliedBy(user, group));
}
Also used : Group(org.osgi.service.useradmin.Group) User(org.osgi.service.useradmin.User)

Example 74 with User

use of org.osgi.service.useradmin.User in project felix by apache.

the class RoleCheckerTest method testUserDoesNotImplyNotImpliedGroup.

/**
 * Test that a user does never imply a group to which it is not a member.
 */
public void testUserDoesNotImplyNotImpliedGroup() {
    User user = RoleFactory.createUser("foo");
    Group group = RoleFactory.createGroup("bar");
    assertFalse(m_roleChecker.isImpliedBy(user, group));
}
Also used : Group(org.osgi.service.useradmin.Group) User(org.osgi.service.useradmin.User)

Example 75 with User

use of org.osgi.service.useradmin.User in project felix by apache.

the class RoleCheckerTest method testRequiredRolesMultipleRequiredGroupsOk.

/**
 * Test that a membership can be implied for users belonging to multiple required groups.
 */
public void testRequiredRolesMultipleRequiredGroupsOk() {
    User elmer = RoleFactory.createUser("elmer");
    User pepe = RoleFactory.createUser("pepe");
    User bugs = RoleFactory.createUser("bugs");
    User daffy = RoleFactory.createUser("daffy");
    Group administrators = RoleFactory.createGroup("administrators");
    administrators.addRequiredMember(m_anyone);
    administrators.addMember(elmer);
    administrators.addMember(pepe);
    administrators.addMember(bugs);
    Group family = RoleFactory.createGroup("family");
    family.addRequiredMember(m_anyone);
    family.addMember(elmer);
    family.addMember(pepe);
    family.addMember(daffy);
    Group alarmSystemActivation = RoleFactory.createGroup("alarmSystemActivation");
    alarmSystemActivation.addMember(m_anyone);
    alarmSystemActivation.addRequiredMember(administrators);
    alarmSystemActivation.addRequiredMember(family);
    assertTrue(m_roleChecker.isImpliedBy(alarmSystemActivation, elmer));
    assertTrue(m_roleChecker.isImpliedBy(alarmSystemActivation, pepe));
    assertFalse(m_roleChecker.isImpliedBy(alarmSystemActivation, bugs));
    assertFalse(m_roleChecker.isImpliedBy(alarmSystemActivation, daffy));
}
Also used : Group(org.osgi.service.useradmin.Group) User(org.osgi.service.useradmin.User)

Aggregations

User (org.osgi.service.useradmin.User)128 Group (org.osgi.service.useradmin.Group)60 Test (org.junit.Test)30 Role (org.osgi.service.useradmin.Role)17 Authorization (org.osgi.service.useradmin.Authorization)13 CountDownLatch (java.util.concurrent.CountDownLatch)12 Hashtable (java.util.Hashtable)10 UserAdmin (org.osgi.service.useradmin.UserAdmin)8 Bundle (org.osgi.framework.Bundle)6 CompositeData (javax.management.openmbean.CompositeData)5 BasicDBObject (com.mongodb.BasicDBObject)4 Dictionary (java.util.Dictionary)4 IOException (java.io.IOException)3 TabularData (javax.management.openmbean.TabularData)3 Collection (java.util.Collection)2 Enumeration (java.util.Enumeration)2 Iterator (java.util.Iterator)2 List (java.util.List)2 UserData (org.apache.aries.jmx.codec.UserData)2 HashSet (java.util.HashSet)1