UserService.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //package com.yihu.jw.config.security;
  2. //
  3. //
  4. //import com.yihu.jw.fegin.base.user.EmployFeign;
  5. //import org.springframework.beans.factory.annotation.Autowired;
  6. //import org.springframework.security.core.authority.AuthorityUtils;
  7. //import org.springframework.security.core.userdetails.User;
  8. //import org.springframework.security.core.userdetails.UserDetails;
  9. //import org.springframework.security.core.userdetails.UserDetailsService;
  10. //import org.springframework.security.core.userdetails.UsernameNotFoundException;
  11. //import org.springframework.security.crypto.password.PasswordEncoder;
  12. //import org.springframework.stereotype.Component;
  13. //import org.springframework.util.StringUtils;
  14. //
  15. ///**
  16. // * Created by chenweida on 2017/11/29.
  17. // * 处理用户校验
  18. // */
  19. //@Component
  20. //public class UserService implements UserDetailsService {
  21. //
  22. // @Autowired
  23. // private PasswordEncoder passwordEncoder;
  24. // @Autowired
  25. // private EmployFeign employFeign;
  26. //
  27. // /**
  28. // * 我们只需要把用户返回给spring-security 密码框架自己帮我们校验
  29. // *
  30. // * @param userName
  31. // * @return
  32. // * @throws UsernameNotFoundException
  33. // */
  34. // @Override
  35. // public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
  36. // if ("admin".equals(userName)) {
  37. // System.out.printf("password:" + passwordEncoder.encode("123456"));
  38. // return new User("admin",
  39. // passwordEncoder.encode("123456"),
  40. // true,
  41. // true,
  42. // true,
  43. // true
  44. // , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
  45. // );
  46. // } else if ((!StringUtils.isEmpty(userName))&&userName.length() == 11) {
  47. // System.out.printf("password:" + passwordEncoder.encode("123456"));
  48. // return new User("admin",
  49. // passwordEncoder.encode("123456"),
  50. // true,
  51. // true,
  52. // true,
  53. // true
  54. // , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
  55. // );
  56. // } else {
  57. // throw new UsernameNotFoundException("用户不存在");
  58. // }
  59. // }
  60. //
  61. //}