RbasService.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //package com.yihu.jw.config.security;
  2. //
  3. //import com.yihu.base.security.rbas.RbasServiceProvider;
  4. //import com.yihu.jw.fegin.base.user.BaseRoleFeign;
  5. //import org.springframework.beans.factory.annotation.Autowired;
  6. //import org.springframework.security.authentication.AnonymousAuthenticationToken;
  7. //import org.springframework.security.core.Authentication;
  8. //import org.springframework.security.core.userdetails.UserDetails;
  9. //import org.springframework.stereotype.Service;
  10. //import org.springframework.util.AntPathMatcher;
  11. //
  12. //import javax.servlet.http.HttpServletRequest;
  13. //import java.util.HashSet;
  14. //import java.util.List;
  15. //import java.util.Set;
  16. //
  17. ///**
  18. // * Created by chenweida on 2017/12/5.
  19. // * 判断用户是否有权限访问该请求路径
  20. // */
  21. //@Service("rbasServiceProvider")
  22. //public class RbasService implements RbasServiceProvider {
  23. //
  24. //
  25. // private AntPathMatcher antPathMatcher = new AntPathMatcher();
  26. //
  27. //
  28. // @Override
  29. // public Boolean hasPerssion(HttpServletRequest request, Authentication authentication) {
  30. // Object principal = authentication.getPrincipal();
  31. // boolean hasPerssion = false;
  32. // if(authentication instanceof AnonymousAuthenticationToken){
  33. // if("anonymousUser".equals(authentication.getPrincipal().toString())){
  34. // return hasPerssion;
  35. // }
  36. // }
  37. //
  38. // //角色列表
  39. // List<String> list = (List)authentication.getAuthorities();
  40. //
  41. //
  42. // if (principal instanceof UserDetails) {
  43. // //获取用户名字
  44. // String username = ((UserDetails) principal).getUsername();
  45. // String[] saasPhone = username.split(",");
  46. // String phone = saasPhone[0];
  47. // String saas = saasPhone[1];
  48. //
  49. //
  50. // //从数据库获取用户全部权限
  51. // Set<String> uris = new HashSet<>();
  52. //
  53. // for (String uri : uris) {
  54. // if (antPathMatcher.match(uri, request.getRequestURI())) {
  55. // hasPerssion = true;
  56. // break;
  57. // }
  58. // }
  59. // return hasPerssion;
  60. // }else{
  61. // return true;
  62. // }
  63. // }
  64. //}