Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.User


        String username = userDTO.getUsername();
        String group = userDTO.getGroupname();
        if (username == null || group == null) {
            throw new IllegalArgumentException("Username and group cannot be null or \"\" ");
        }
        User user = getUser(username);
        Group newGroup = (Group) m_useradmin.getRole(group);
        if (newGroup == null) {
            throw new GroupNotFoundException(group);
        }
        if (user == null) {
View Full Code Here


    public void removeUser(UserDTO userDTO) throws UserNotFoundException {
        String username = userDTO.getPreviousUsername();
        if (username == null) {
            throw new IllegalArgumentException("Username cannot be null or \"\" ");
        }
        User user = getUser(username);
        if (user == null) {
            throw new UserNotFoundException(username);
        }
        Group group = getGroup(user);
        group.removeMember(user);
        m_useradmin.removeRole(user.getName());
    }
View Full Code Here

        try {
            Role[] roles = m_useradmin.getRoles(null);
            if (roles != null) {
                for (Role role : roles) {
                    if (role.getType() == Role.USER) {
                        User user = (User) role;
                        tempData.add(new UserDTO((User) role, getGroup(user)));
                    }
                }
            }
        }
View Full Code Here

    /**
     * Tests that authenticating with a empty username will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateEmptyUserNameYieldsNull() {
        User result = new PasswordAuthenticationProcessor().authenticate(m_userAdmin, "", "secret");
        assert result == null : "Expected no valid user to be returned!";
    }
View Full Code Here

    /**
     * Tests that authenticating a known user with an invalid password will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateKnownUserWithInvalidPasswordYieldsNull() {
        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("password"), eq("otherSecret"))).thenReturn(Boolean.TRUE);

        when(m_userAdmin.getUser(eq("username"), eq("bob"))).thenReturn(user);

        User result = new PasswordAuthenticationProcessor().authenticate(m_userAdmin, "bob", "secret");
        assert result == null : "Expected no valid user to be returned!";
    }
View Full Code Here

    /**
     * Tests that authenticating a known user with a correct password will not yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateKnownUserYieldsValidResult() {
        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("password"), eq("secret"))).thenReturn(Boolean.TRUE);

        when(m_userAdmin.getUser(eq("username"), eq("bob"))).thenReturn(user);

        User result = new PasswordAuthenticationProcessor().authenticate(m_userAdmin, "bob", "secret");
        assert result != null : "Expected a valid user to be returned!";
       
        assert "bob".equals(user.getName()) : "Expected bob to be returned!";
    }
View Full Code Here

    /**
     * Tests that authenticating with a null password will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateNullPasswordYieldsNull() {
        User result = new PasswordAuthenticationProcessor().authenticate(m_userAdmin, "bob", null);
        assert result == null : "Expected no valid user to be returned!";
    }
View Full Code Here

    /**
     * Tests that authenticating with a null username will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateNullUserNameYieldsNull() {
        User result = new PasswordAuthenticationProcessor().authenticate(m_userAdmin, null, "secret");
        assert result == null : "Expected no valid user to be returned!";
    }
View Full Code Here

    /**
     * Tests that authenticating an unknown user will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateUnknownUserYieldsNull() {
        User result = new PasswordAuthenticationProcessor().authenticate(m_userAdmin, "alice", "secret");
        assert result == null : "Expected no valid user to be returned!";
    }
View Full Code Here

        processor.updated(props);

        byte[] hashedPw = DigestUtils.sha("secret");
       
        // Test whether we can use the new properties...
        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq(keyPassword), eq(hashedPw))).thenReturn(Boolean.TRUE);

        when(m_userAdmin.getUser(eq(keyUsername), eq("bob"))).thenReturn(user);

        User result = processor.authenticate(m_userAdmin, "bob", "secret");
        assert result != null : "Expected a valid user to be returned!";
       
        assert "bob".equals(user.getName()) : "Expected bob to be returned!";
    }
View Full Code Here

TOP

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

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.