Blame view

src/main/java/fr/plil/sio/web/mvc/UserDetailsServiceImpl.java 778 Bytes
322c9502   Julien Cartigny   Ad Spring securit...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  package fr.plil.sio.web.mvc;
  
  import org.springframework.security.core.userdetails.UserDetails;
  import org.springframework.security.core.userdetails.UserDetailsService;
  import org.springframework.security.core.userdetails.UsernameNotFoundException;
  import org.springframework.stereotype.Service;
  
  import javax.annotation.Resource;
  
  @Service
  public class UserDetailsServiceImpl implements UserDetailsService {
  
      @Resource
      private UserService userService;
  
      @Override
      public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
          User user = userService.findByUsername(username);
  
          if (user == null) {
              throw new UsernameNotFoundException("cannot found user " + username);
          }
  
          return user;
      }
  }