spring boot oauth2我可以在UserDetailsS​​ervice中获取客户端信息

时间:2017-10-17 02:56:44

标签: spring oauth-2.0

public class UserService implements UserDetailsService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication a = SecurityContextHolder.getContext().getAuthentication();

        return userMapper.findUserByUsername(username);
    }

    public void create(User user) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        user.setPassword(encoder.encode(user.getPassword()));
        userMapper.insert(user);
    }
}

我想获取客户端类型当我在loadUserInfo中,我在SecurityContextHolder中找到,但是,我仍然找到了客户端类型,我该如何编写这段代码? 感谢您的评论

0 个答案:

没有答案