Package org.springframework.security.core.userdetails

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


    }

    private class MockAuthenticationDaoUserrodWithSalt implements UserDetailsService {
        public UserDetails loadUserByUsername(String username) {
            if ("rod".equals(username)) {
                return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here


    }

    private class MockAuthenticationDaoUserPeter implements UserDetailsService {
        public UserDetails loadUserByUsername(String username) {
            if ("peter".equals(username)) {
                return new User("peter", "opal", false, true, true, true, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here

    }

    private class MockAuthenticationDaoUserPeterAccountExpired implements UserDetailsService {
        public UserDetails loadUserByUsername(String username) {
            if ("peter".equals(username)) {
                return new User("peter", "opal", true, false, true, true, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here

    }

    private class MockAuthenticationDaoUserPeterAccountLocked implements UserDetailsService {
        public UserDetails loadUserByUsername(String username) {
            if ("peter".equals(username)) {
                return new User("peter", "opal", true, true, true, false, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here

    }

    private class MockAuthenticationDaoUserPeterCredentialsExpired implements UserDetailsService {
        public UserDetails loadUserByUsername(String username) {
            if ("peter".equals(username)) {
                return new User("peter", "opal", true, true, false, true, ROLES_12);
            } else {
                throw new UsernameNotFoundException("Could not find: " + username);
            }
        }
View Full Code Here

    }

    @Test
    public void updateUserChangesDataCorrectlyAndClearsCache() {
        insertJoe();
        User newJoe = new User("joe","newpassword",false,true,true,true,
                AuthorityUtils.createAuthorityList(new String[]{"D","F","E"}));

        manager.updateUser(newJoe);

        UserDetails joe = manager.loadUserByUsername("joe");
View Full Code Here

    @Before
    public void setUp() throws Exception {
        RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl();
        roleHierarchy.setHierarchy("ROLE_A > ROLE_B");
        final UserDetails user = new User("EXISTING_USER", "PASSWORD", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_A"));
        final UserDetailsService wrappedUserDetailsService = mock(UserDetailsService.class);
        when(wrappedUserDetailsService.loadUserByUsername("EXISTING_USER")).thenReturn(user);
        when(wrappedUserDetailsService.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION")).thenThrow(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION"));
View Full Code Here

        userDetailsServiceWrapper.setUserDetailsService(wrappedUserDetailsService);
    }

    @Test
    public void testLoadUserByUsername() {
        UserDetails expectedUserDetails = new User("EXISTING_USER", "PASSWORD", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B"));
        UserDetails userDetails = userDetailsServiceWrapper.loadUserByUsername("EXISTING_USER");
        assertEquals(expectedUserDetails.getPassword(), userDetails.getPassword());
        assertEquals(expectedUserDetails.getUsername(), userDetails.getUsername());
        assertEquals(expectedUserDetails.isAccountNonExpired(), userDetails.isAccountNonExpired());
        assertEquals(expectedUserDetails.isAccountNonLocked(), userDetails.isAccountNonLocked());
        assertEquals(expectedUserDetails.isCredentialsNonExpired(), expectedUserDetails.isCredentialsNonExpired());
        assertEquals(expectedUserDetails.isEnabled(), userDetails.isEnabled());
        assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(expectedUserDetails.getAuthorities(), userDetails.getAuthorities()));

        try {
            userDetails = userDetailsServiceWrapper.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION");
            fail("testLoadUserByUsername() - UsernameNotFoundException did not bubble up!");
        } catch (UsernameNotFoundException e) {}
View Full Code Here

    protected void setUp() throws Exception {
        RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl();
        roleHierarchy.setHierarchy("ROLE_A > ROLE_B");
        authorities = AuthorityUtils.createAuthorityList("ROLE_A");
        userDetails1 = new User("TestUser1", "TestPassword1", true, true, true, true, authorities);
        userDetails2 = new User("TestUser2", "TestPassword2", false, false, false, false, authorities);
        userDetailsWrapper1 = new UserDetailsWrapper(userDetails1, roleHierarchy);
        userDetailsWrapper2 = new UserDetailsWrapper(userDetails2, roleHierarchy);
    }
View Full Code Here

      boolean enabled = true;
      boolean accountNonExpired = true;
      boolean credentialsNonExpired = true;
      boolean accountNonLocked = true;
     
      return new User(
          domainUser.getUsername(),
          domainUser.getPassword().toLowerCase(),
          enabled,
          accountNonExpired,
          credentialsNonExpired,
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.