Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.Group


     * Tests that retrieving the basic members from a group works.
     */
    public void testGetGroupMemberOk() {
        User user1 = (User) m_userAdmin.createRole("user1", Role.USER);
       
        Group group1 = (Group) m_userAdmin.createRole("group1", Role.GROUP);
        assertNull(group1.getMembers());
       
        assertTrue(group1.addMember(user1));
       
        assertEquals(1, group1.getMembers().length);
    }
View Full Code Here


     * Tests that retrieving the required members from a group works.
     */
    public void testGetRequiredGroupMemberOk() {
        User user1 = (User) m_userAdmin.createRole("user1", Role.USER);
       
        Group group1 = (Group) m_userAdmin.createRole("group1", Role.GROUP);
        assertNull(group1.getRequiredMembers());
       
        assertTrue(group1.addRequiredMember(user1));
       
        assertEquals(1, group1.getRequiredMembers().length);
    }
View Full Code Here

     * Tests that testing for group membership with anonymous users works.
     */
    public void testGroupMembershipWithAnonymousUserOk() {
        Role user = m_userAdmin.createRole("user", Role.USER);

        Group group = (Group) m_userAdmin.createRole("group", Role.GROUP);
        group.addMember(user);

        Authorization auth = m_userAdmin.getAuthorization(null);
        assertTrue(auth.hasRole(Role.USER_ANYONE));
        assertFalse(auth.hasRole("group"));
    }
View Full Code Here

        User user1 = (User) m_userAdmin.createRole("user1", Role.USER);
        User user2 = (User) m_userAdmin.createRole("user2", Role.USER);
        User user3 = (User) m_userAdmin.createRole("user3", Role.USER);
        User user4 = (User) m_userAdmin.createRole("user4", Role.USER);

        Group reqGroup = (Group) m_userAdmin.createRole("reqGroup", Role.GROUP);
        reqGroup.addMember(user1);
        reqGroup.addMember(user2);
       
        Group group = (Group) m_userAdmin.createRole("group", Role.GROUP);
        group.addRequiredMember(reqGroup);
        group.addMember(m_userAdmin.getRole(Role.USER_ANYONE));

        Authorization auth = m_userAdmin.getAuthorization(user1);
        assertTrue(auth.hasRole("group"));

        auth = m_userAdmin.getAuthorization(user2);
View Full Code Here

     */
    public void testRemoveRoleRemovesItAsGroupMemberOk() {
        Role user1 = m_userAdmin.createRole("user1", Role.USER);
        Role user2 = m_userAdmin.createRole("user2", Role.USER);

        Group group1 = (Group) m_userAdmin.createRole("group1", Role.GROUP);
        group1.addMember(user1);

        Group group2 = (Group) m_userAdmin.createRole("group2", Role.GROUP);
        group2.addMember(user1);
        group2.addMember(user2);
       
        // Remove user...
        m_userAdmin.removeRole(user1.getName());

        // Retrieve an up-to-date instance of the first group...
        group1 = (Group) m_userAdmin.getRole("group1");
        assertNull(group1.getMembers());

        // Retrieve an up-to-date instance of the second group...
        group2 = (Group) m_userAdmin.getRole("group2");

        Role[] members = group2.getMembers();
    assertNotNull(members);
    assertEquals(1, members.length);
        assertEquals(user2, members[0]);
    }
View Full Code Here

    /**
     * Test for example presented in section 107.3.2 of OSGi compendium v4.2.
     */
    public void testAuthorizationExampleOk() {
        // Action groups...
        Group alarmSystemControl = createGroup("AlarmSystemControl");
        Group internetAccess = createGroup("InternetAccess");
        Group temperatureControl = createGroup("TemperatureControl");
        Group photoAlbumEdit = createGroup("PhotoAlbumEdit");
        Group photoAlbumView = createGroup("PhotoAlbumView");
        Group portForwarding = createGroup("PortForwarding");
       
        // System user groups...
        Group administrators = createGroup("Administrators");
        Group buddies = createGroup("Buddies");
        Group children = createGroup("Children");
        Group adults = createGroup("Adults");
        Group residents = createGroup("Residents");
       
        // Users
        User elmer = RoleFactory.createUser("Elmer");
        User fudd = RoleFactory.createUser("Fudd");
        User marvin = RoleFactory.createUser("Marvin");
        User pepe = RoleFactory.createUser("Pepe");
        User daffy =RoleFactory.createUser("Daffy");
        User foghorn = RoleFactory.createUser("Foghorn");
       
        // Not explicitly mentioned; but needed to comply with the semantics
        alarmSystemControl.addRequiredMember(m_anyone);
        internetAccess.addRequiredMember(m_anyone);
        temperatureControl.addRequiredMember(m_anyone);
        photoAlbumEdit.addRequiredMember(m_anyone);
        photoAlbumView.addRequiredMember(m_anyone);
        portForwarding.addRequiredMember(m_anyone);

        administrators.addRequiredMember(m_anyone);
        buddies.addRequiredMember(m_anyone);
        children.addRequiredMember(m_anyone);
        adults.addRequiredMember(m_anyone);
        residents.addRequiredMember(m_anyone);

        // Table 107.1
        residents.addMember(elmer);
        residents.addMember(fudd);
        residents.addMember(marvin);
        residents.addMember(pepe);
       
        buddies.addMember(daffy);
        buddies.addMember(foghorn);
       
        children.addMember(marvin);
View Full Code Here

    /**
     * Test that the tests for membership work correctly.
     */
    public void testHasRoleOk() {
        Group citizens = createGroup("citizen");
        citizens.addRequiredMember(m_anyone);
       
        Group adults = createGroup("adult");
        adults.addRequiredMember(m_anyone);
       
        Group voters = createGroup("voter");
        voters.addRequiredMember(citizens);
        voters.addRequiredMember(adults);
        voters.addMember(m_anyone);
       
        // Elmer belongs to the citizens and adults...
        User elmer = createUser("elmer");
        citizens.addMember(elmer);
        adults.addMember(elmer);
View Full Code Here

    /**
     * Test that the tests for membership work correctly.
     */
    public void testGetRolesOk() {
        Group citizens = createGroup("citizen");
        citizens.addRequiredMember(m_anyone);
       
        Group adults = createGroup("adult");
        adults.addRequiredMember(m_anyone);
       
        Group voters = createGroup("voter");
        voters.addRequiredMember(citizens);
        voters.addRequiredMember(adults);
        voters.addMember(m_anyone);
       
        // Elmer belongs to the citizens and adults...
        User elmer = createUser("elmer");
        citizens.addMember(elmer);
        adults.addMember(elmer);
View Full Code Here

    /**
     * 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));
    }
View Full Code Here

     * Test that a user does never imply a group to which it is not a member.
     */
    public void testUserImpliesImpliedGroup() {
        User user = RoleFactory.createUser("foo");
       
        Group group = RoleFactory.createGroup("bar");
        group.addRequiredMember(m_anyone);
        group.addMember(user);

        assertTrue(m_roleChecker.isImpliedBy(group, user));
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.useradmin.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.