Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.User


    /**
     * Tests that a null authentication header will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateEmptyAuthenticationHeaderYieldsNull() {
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here


     */
    @Test(groups = { UNIT })
    public void testAuthenticateInvalidAuthenticationHeaderYieldsNull() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn(createAuthHeaderValue("bob"));
       
        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 BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateKnownUserWithInvalidPasswordYieldsNull() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn(createAuthHeaderValue("bob:secret"));
       
        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 BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateKnownUserYieldsValidResult() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn(createAuthHeaderValue("bob:secret"));
       
        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 BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result != null : "Expected a valid user to be returned!";
       
        assert "bob".equals(user.getName()) : "Expected user bob to be returned!";
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateNonBase64AuthenticationHeaderYieldsNull() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn("foo");
       
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateUnknownUserYieldsNull() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn(createAuthHeaderValue("alice:secret"));
       
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

        processor.updated(props);
       
        // Test whether we can use the new properties...
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn(createAuthHeaderValue("bob:secret"));
       
        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq(keyPassword), eq("secret"))).thenReturn(Boolean.TRUE);

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

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

    /**
     * {@inheritDoc}
     */
    public boolean login(String username, String password) {
        User user = m_authenticationService.authenticate(username, password);
        setUser(user);
        return login(user);
    }
View Full Code Here

            // No common name given; cannot retrieve user credentials...
            m_log.log(LogService.LOG_DEBUG, "Failed to obtain common name of X509 certificate!");
            return null;
        }
       
        User user = getUser(userAdmin, name);
        if (user == null) {
            // Invalid/unknown user!
            m_log.log(LogService.LOG_DEBUG, "Failed to validate user using certificate!");
            return null;
        }
View Full Code Here

            public void valueChange(ValueChangeEvent event) {
                UserDTO user = m_userDTO;
                if (user == null) {
                    return;
                }
                User result = m_userUtil.getUser(user.getPreviousUsername());
                if (result == null) {
                    return;
                }
                String password = (String) result.getCredentials().get("password");
                String passwordTextFieldInput = (String) m_passwordTextField.getValue();
                if (password.equals(passwordTextFieldInput)) {
                    if (!m_userDTO.getPassword().equals(passwordTextFieldInput)) {
                        m_userDTO.setPassword(passwordTextFieldInput);
                        m_userDTO.setPasswordChanged(false);
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.