-
Notifications
You must be signed in to change notification settings - Fork 575
Expand file tree
/
Copy pathApplicationUserService.java
More file actions
25 lines (20 loc) · 1.01 KB
/
ApplicationUserService.java
File metadata and controls
25 lines (20 loc) · 1.01 KB
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
package com.example.demo.auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
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;
@Service
public class ApplicationUserService implements UserDetailsService {
private final ApplicationUserDAO applicationUserDAO;
@Autowired
public ApplicationUserService(@Qualifier("fake") ApplicationUserDAO applicationUserDAO){
this.applicationUserDAO = applicationUserDAO;
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return applicationUserDAO.selectApplicationUserByUsername(username)
.orElseThrow(() -> new UsernameNotFoundException(String.format("Username %s not found", username)));
}
}