Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.Group.addMember()


        user.getProperties().put("fullname", "Mr. M. Me");
        user.getCredentials().put("password", "swordfish");
        user.getCredentials().put("certificate", new byte[] {'4', '2'});
        Group group = (Group) m_impl.createRole("myGroup", Role.GROUP);
        group.getProperties().put("description", "One group to rule them all.");
        group.addMember(user);

        // Write it to the store
        new Thread("RepositoryUserAdmin committer") {
            @Override
            public void run() {
View Full Code Here


    @Test(groups = { UNIT })
    public void testCircularDependency() throws Exception {
        Group g1 = (Group) m_impl.createRole("group1", Role.GROUP);
        Group g2 = (Group) m_impl.createRole("group2", Role.GROUP);
        g1.addMember(g2);
        g2.addMember(g1);

        try {
            m_impl.commit();
            assert false : "There is a circular dependency, this should be detected and reason for failure.";
        }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testCreation() {
        User user = (User) m_impl.createRole("me", Role.USER);
        Group group = (Group) m_impl.createRole("myGroup", Role.GROUP);
        group.addMember(user);
        assert group.getMembers().length == 1 : "We expect to find one member, not " + group.getMembers().length;
    }

    @SuppressWarnings("unchecked")
    @Test(groups = { UNIT })
View Full Code Here

        Group group1 = Mockito.mock(Group.class);
        User user1 = Mockito.mock(User.class);
        Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
        Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
        Mockito.when(group1.getType()).thenReturn(Role.GROUP);
        Mockito.when(group1.addMember(user1)).thenReturn(true);
        boolean isAdded = mbean.addMember("group1", "user1");
        Assert.assertTrue(isAdded);
        Mockito.verify(group1).addMember(user1);
    }
View Full Code Here

            Group g = (Group) m_userAdmin.getRole(groupName);
            if (g == null) {
                m_log.log(LogService.LOG_WARNING, "Cannot add user " + role.getName() + " to group " + groupName + ", because the group does not exist.");
                continue;
            }
            g.addMember(r);
        }
    }

    /**
     * Updates the currently present UserAdmin with the data in m_toInstall and m_toRemove.
View Full Code Here

        }

        User newUser = (User) newRole;
        newUser.getProperties().put("username", username);
        newUser.getCredentials().put("password", password);
        group.addMember(newUser);
    }

    @Override
    public void editGroup(UserDTO userDTO) throws UserNotFoundException, GroupNotFoundException {
        String username = userDTO.getUsername();
View Full Code Here

        if (newGroup == null) {
            throw new GroupNotFoundException(group);
        }

        oldGroup.removeMember(user);
        newGroup.addMember(user);
    }

    @Override
    public void editPassword(UserDTO userDTO) throws UserNotFoundException {
        String username = userDTO.getUsername();
View Full Code Here

        User newUser = (User) m_useradmin.createRole(newUsername, Role.USER);
        newUser.getProperties().put("username", newUsername);
        newUser.getCredentials().put("password", userDTO.getPassword());

        group.addMember(newUser);
    }

    @Override
    public List<UserDTO> getData() {
        List<UserDTO> tempData = new ArrayList<UserDTO>();
View Full Code Here

        Group group = (Group) m_userAdmin.getRole(TEST_GROUP);
        if (newRole != null && group != null) {
            newUser = (User) newRole;
            newUser.getProperties().put("username", "u");
            newUser.getCredentials().put("password", "p");
            group.addMember(newUser);
        }
        assertEquals("Testuser", m_userEditor.getUser("u").getName());
    }

    public void testAddUserAndRemove() throws Exception {
View Full Code Here

        assertNotNull(group);

        User newUser = (User) newRole;
        newUser.getProperties().put("username", "u");
        newUser.getCredentials().put("password", "p");
        group.addMember(newUser);

        Group userGroup = m_userEditor.getGroup(newUser);
        assertNotNull(userGroup);
        assertEquals(group.getName(), userGroup.getName());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.