要么我错过了一些东西,要么就是它的工作原理......
也就是说,我实现了UserDetailsService,并将其分为(AppUser下面)spring实用类User,(实现UserDetails).如果重要,它会是这样的:
@Override
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {
// try loading user by its name
SystemUser user = null;
try {
user = this.sysUserService.getByUsername(username);
if(user == null)
throw new UsernameNotFoundException("User not found!");
}
catch(Exception e) {
throw new DataRetrievalFailureException(
"Could not load user with username: " + username);
}
// load user rights, and create UserDetails instance
UserDetails res = new AppUser(user, getUserAuthorities(user));
return res;
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用这种方法实现帐户锁定:
public class LoginFailureEventListenter …Run Code Online (Sandbox Code Playgroud)