相关疑难解决方法(0)

Spring安全性返回String作为主体而不是登录失败时的UserDetails?

要么我错过了一些东西,要么就是它的工作原理......
也就是说,我实现了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)

java authentication spring login spring-security

9
推荐指数
1
解决办法
4486
查看次数

标签 统计

authentication ×1

java ×1

login ×1

spring ×1

spring-security ×1