Examples of loadUserByUsername()


Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

        }

        private UsernamePasswordAuthenticationToken authentication(ServletContext servletContext) {
            ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
            UserDetailsService userDetailsService = userDetailsService(context);
            UserDetails userDetails = userDetailsService.loadUserByUsername(username);
            return new UsernamePasswordAuthenticationToken(
                    userDetails, userDetails.getPassword(), userDetails.getAuthorities());
        }

        private UserDetailsService userDetailsService(ApplicationContext context) {
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

      String userXmlPath = confPath + File.separator + UsersFile;
      File usrXmlFile = new File(userXmlPath);

      TestFileUtils.createXMLFile(users1, usrXmlFile);
      try {
         userDetails1 = accountService.loadUserByUsername("root");
      } catch (UsernameNotFoundException e) {
      }
      Assert.assertNull(userDetails1);
      UserDetails userDetails2 = accountService.loadUserByUsername("serengeti");
      assertNotNull(userDetails2);
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

      try {
         userDetails1 = accountService.loadUserByUsername("root");
      } catch (UsernameNotFoundException e) {
      }
      Assert.assertNull(userDetails1);
      UserDetails userDetails2 = accountService.loadUserByUsername("serengeti");
      assertNotNull(userDetails2);
      TestFileUtils.deleteXMLFile(usrXmlFile);
      Users users2 = new Users();
      User user2 = new User();
      user2.setName("*");
 
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

      Users users2 = new Users();
      User user2 = new User();
      user2.setName("*");
      users2.setUsers(Arrays.asList(user2));
      TestFileUtils.createXMLFile(users2, usrXmlFile);
      userDetails1 = accountService.loadUserByUsername("root");
      assertNotNull(userDetails1);
      assertEquals(userDetails1.getUsername(), "Guest");
      TestFileUtils.deleteXMLFile(usrXmlFile);
      Users users3 = new Users();
      users3.setUsers(Arrays.asList(user2, user1));
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

      assertEquals(userDetails1.getUsername(), "Guest");
      TestFileUtils.deleteXMLFile(usrXmlFile);
      Users users3 = new Users();
      users3.setUsers(Arrays.asList(user2, user1));
      TestFileUtils.createXMLFile(users3, usrXmlFile);
      userDetails1 = accountService.loadUserByUsername("serengeti");
      assertNotNull(userDetails1);
      assertEquals(userDetails1.getUsername(), "serengeti");
      TestFileUtils.deleteXMLFile(usrXmlFile);
   }
}
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

        this.applicationContext = new AnnotationConfigApplicationContext();
        this.applicationContext.register(SecurityConfiguration.class);
        this.applicationContext.refresh();
        UserDetailsService userDetailsService = this.applicationContext.getBean(UserDetailsService.class);
        Assert.assertNotNull("the userDetailsService should not be null", userDetailsService);
        assertEquals("there should only be 1 authority", userDetailsService.loadUserByUsername("jlong").getAuthorities().size(), 1);
        assertEquals("there should be 2 authorities", userDetailsService.loadUserByUsername("jbarrez").getAuthorities().size(), 2);
    }

    @Configuration
    @Import({DataSourceAutoConfiguration.class, DataSourceProcessEngineAutoConfiguration.DataSourceConfiguration.class,
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

        this.applicationContext.register(SecurityConfiguration.class);
        this.applicationContext.refresh();
        UserDetailsService userDetailsService = this.applicationContext.getBean(UserDetailsService.class);
        Assert.assertNotNull("the userDetailsService should not be null", userDetailsService);
        assertEquals("there should only be 1 authority", userDetailsService.loadUserByUsername("jlong").getAuthorities().size(), 1);
        assertEquals("there should be 2 authorities", userDetailsService.loadUserByUsername("jbarrez").getAuthorities().size(), 2);
    }

    @Configuration
    @Import({DataSourceAutoConfiguration.class, DataSourceProcessEngineAutoConfiguration.DataSourceConfiguration.class,
            org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration.class,
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

        }

        private UsernamePasswordAuthenticationToken authentication(ServletContext servletContext) {
            ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
            UserDetailsService userDetailsService = userDetailsService(context);
            UserDetails userDetails = userDetailsService.loadUserByUsername(this.username);
            return new UsernamePasswordAuthenticationToken(
                    userDetails, userDetails.getPassword(), userDetails.getAuthorities());
        }

        private UserDetailsService userDetailsService(ApplicationContext context) {
View Full Code Here

Examples of org.springframework.security.core.userdetails.UserDetailsService.loadUserByUsername()

        .getBean(AuthenticationManager.class);
    DaoAuthenticationProvider provider = (DaoAuthenticationProvider) parent
        .getProviders().get(0);
    UserDetailsService service = (UserDetailsService) ReflectionTestUtils.getField(
        provider, "userDetailsService");
    UserDetails user = service.loadUserByUsername("user");
    return user;
  }

  @Test
  public void testDisableIgnoredStaticApplicationPaths() throws Exception {
View Full Code Here

Examples of org.springframework.security.provisioning.JdbcUserDetailsManager.loadUserByUsername()

    @Test
    public void validUsernameIsFound() {
        setContext("<jdbc-user-service data-source-ref='dataSource'/>" + DATA_SOURCE);
        JdbcUserDetailsManager mgr = (JdbcUserDetailsManager) appContext.getBean(BeanIds.USER_DETAILS_SERVICE);
        assertNotNull(mgr.loadUserByUsername("rod"));
    }

    @Test
    public void beanIdIsParsedCorrectly() {
        setContext("<jdbc-user-service id='myUserService' data-source-ref='dataSource'/>" + DATA_SOURCE);
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.