/** * 获得当前用户权限 */ private String getAuthorities() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); List<String> roles = new ArrayList<String>(); for (GrantedAuthority ga : authentication.getAuthorities()) { roles.add(ga.getAuthority()); } return roles.toString(); }
/** * 获得当前用户名称 */ private String getUname() { return SecurityContextHolder.getContext().getAuthentication().getName(); }