Package org.springframework.security.core.userdetails

Examples of org.springframework.security.core.userdetails.User


            UserAttribute attr = (UserAttribute) configAttribEd.getValue();

            // Make a user object, assuming the properties were properly provided
            if (attr != null) {
                UserDetails user = new User(username, attr.getPassword(), attr.isEnabled(), true, true, true,
                        attr.getAuthorities());
                userMap.addUser(user);
            }
        }
View Full Code Here


        return getJdbcTemplate().query(usersByUsernameQuery, new String[] {username}, new RowMapper<UserDetails>() {
            public UserDetails mapRow(ResultSet rs, int rowNum) throws SQLException {
                String username = rs.getString(1);
                String password = rs.getString(2);
                boolean enabled = rs.getBoolean(3);
                return new User(username, password, enabled, true, true, true, AuthorityUtils.NO_AUTHORITIES);
            }

        });
    }
View Full Code Here

        if (!usernameBasedPrimaryKey) {
            returnUsername = username;
        }

        return new User(returnUsername, userFromUserQuery.getPassword(), userFromUserQuery.isEnabled(),
                true, true, true, combinedAuthorities);
    }
View Full Code Here

        while(names.hasMoreElements()) {
            String name = (String) names.nextElement();
            editor.setAsText(users.getProperty(name));
            UserAttribute attr = (UserAttribute) editor.getValue();
            UserDetails user = new User(name, attr.getPassword(), attr.isEnabled(), true, true, true,
                    attr.getAuthorities());
            createUser(user);
        }
    }
View Full Code Here

        if (user == null) {
            throw new UsernameNotFoundException(username);
        }

        return new User(user.getUsername(), user.getPassword(), user.isEnabled(), user.isAccountNonExpired(),
                user.isCredentialsNonExpired(), user.isAccountNonLocked(), user.getAuthorities());
    }
View Full Code Here

        assertThat(resolver.resolveArgument(showUserAnnotationObject(), null, null, null)).isEqualTo(expectedPrincipal);
    }

    @Test
    public void resolveArgumentUserDetails() throws Exception {
        setAuthenticationPrincipal(new User("user", "password", AuthorityUtils.createAuthorityList("ROLE_USER")));
        assertThat(resolver.resolveArgument(showUserAnnotationUserDetails(), null, null, null)).isEqualTo(expectedPrincipal);
    }
View Full Code Here

        assertTrue(wrapper.isUserInRole("FOO"));
    }

    public void testCorrectOperationWithUserDetailsBasedPrincipal() throws Exception {
        Authentication auth = new TestingAuthenticationToken(new User("rodAsUserDetails", "koala", true, true,
                    true, true, AuthorityUtils.NO_AUTHORITIES ), "koala", "ROLE_HELLO", "ROLE_FOOBAR");
        SecurityContextHolder.getContext().setAuthentication(auth);

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setRequestURI("/");
View Full Code Here

        provider.afterPropertiesSet();
    }

    @Test
    public final void authenticateInvalidToken() throws Exception {
        UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new UsernamePasswordAuthenticationToken("dummyUser", "dummyPwd");
        Authentication result = provider.authenticate(request);
        assertNull(result);
    }
View Full Code Here

        assertNull(result);
    }

    @Test
    public final void authenticateKnownUser() throws Exception {
        UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser", "dummyPwd");
        Authentication result = provider.authenticate(request);
        assertNotNull(result);
        assertEquals(result.getPrincipal(), ud);
View Full Code Here

        // @TODO: Add more asserts?
    }

    @Test
    public final void authenticateIgnoreCredentials() throws Exception {
        UserDetails ud = new User("dummyUser1", "dummyPwd1", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser1", "dummyPwd2");
        Authentication result = provider.authenticate(request);
        assertNotNull(result);
        assertEquals(result.getPrincipal(), ud);
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.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.