|
@@ -21,29 +21,29 @@ public class CustomizeAccessDecisionManager implements AccessDecisionManager {
|
|
|
public void decide(Authentication authentication, Object o, Collection<ConfigAttribute> collection)
|
|
|
throws AccessDeniedException, InsufficientAuthenticationException {
|
|
|
Iterator<ConfigAttribute> iterator = collection.iterator();
|
|
|
-// while (iterator.hasNext()) {
|
|
|
-// ConfigAttribute ca = iterator.next();
|
|
|
-// //当前请求需要的权限
|
|
|
-// String needRole = ca.getAttribute();
|
|
|
-// if ("ROLE_LOGIN".equalsIgnoreCase(needRole)) {
|
|
|
-// //判断是否登录
|
|
|
-// if (authentication instanceof AnonymousAuthenticationToken) {
|
|
|
-// throw new AccessDeniedException("尚未登录,请登录!");
|
|
|
-// } else {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// }else if("ROLE_NO_AUTH".equalsIgnoreCase(needRole)){
|
|
|
-// throw new AccessDeniedException("未授权可以访问!");
|
|
|
-// }
|
|
|
-// //当前用户所具有的权限
|
|
|
-// Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
|
|
|
-// for (GrantedAuthority authority : authorities) {
|
|
|
-// if (authority.getAuthority().equals(needRole)) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// throw new AccessDeniedException("权限不足!");
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ ConfigAttribute ca = iterator.next();
|
|
|
+ //当前请求需要的权限
|
|
|
+ String needRole = ca.getAttribute();
|
|
|
+ if ("ROLE_LOGIN".equalsIgnoreCase(needRole)) {
|
|
|
+ //判断是否登录
|
|
|
+ if (authentication instanceof AnonymousAuthenticationToken) {
|
|
|
+ throw new AccessDeniedException("尚未登录,请登录!");
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }else if("ROLE_NO_AUTH".equalsIgnoreCase(needRole)){
|
|
|
+ throw new AccessDeniedException("未授权可以访问!");
|
|
|
+ }
|
|
|
+ //当前用户所具有的权限
|
|
|
+ Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
|
|
|
+ for (GrantedAuthority authority : authorities) {
|
|
|
+ if (authority.getAuthority().equals(needRole)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new AccessDeniedException("权限不足!");
|
|
|
}
|
|
|
|
|
|
@Override
|