@Override public boolean preHandle( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { HttpSession session = httpServletRequest.getSession(); User user = (User) session.getAttribute("user"); if (user == null || user.getStatus() != UserConstant.Status.ACTIVE.value()) { return false; } Map<Privilege, Integer> map = PrivilegeHelper.getPrivilegeMap(); Privilege privilege = new Privilege( httpServletRequest .getRequestURI() .substring(httpServletRequest.getContextPath().length()), httpServletRequest.getMethod()); System.out.println("privilege = " + privilege); if (CollectionUtils.isEmpty(user.getPrivilegeIds())) { httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/error/low.html"); return false; } if (MapUtils.isNotEmpty(map) && map.containsKey(privilege) && !user.getPrivilegeIds().contains(map.get(privilege))) { httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/error/low.html"); return false; } return true; }
@Override public ApiResponse refreshACL() { ApiResponse response = ApiResponse.createDefaultApiResponse(); PrivilegeHelper.setPrivilegeMap(this.privilegeDao.getPrivilegeList()); return response; }