|
|
@@ -1,6 +1,7 @@
|
|
|
package com.zd.common.core.aspect;
|
|
|
|
|
|
import com.zd.common.core.annotation.PreAuthorize;
|
|
|
+import com.zd.common.core.exception.PreAuthorizeException;
|
|
|
import com.zd.common.core.security.TokenService;
|
|
|
import com.zd.common.core.utils.StringUtils;
|
|
|
import com.zd.model.entity.LoginUser;
|
|
|
@@ -14,8 +15,10 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.PatternMatchUtils;
|
|
|
|
|
|
+import java.lang.reflect.Array;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* 自定义权限实现
|
|
|
@@ -52,38 +55,37 @@ public class PreAuthorizeAspect {
|
|
|
if (annotation == null) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ //权限验证
|
|
|
if (StringUtils.isNotEmpty(annotation.hasPermi())) {
|
|
|
if (hasPermi(annotation.hasPermi())) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
- throw new RuntimeException();
|
|
|
+ throw new PreAuthorizeException();
|
|
|
} else if (StringUtils.isNotEmpty(annotation.lacksPermi())) {
|
|
|
if (lacksPermi(annotation.lacksPermi())) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
- throw new RuntimeException();
|
|
|
+ throw new PreAuthorizeException();
|
|
|
} else if (ARRAY_EMPTY < annotation.hasAnyPermi().length) {
|
|
|
if (hasAnyPermi(annotation.hasAnyPermi())) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
- throw new RuntimeException();
|
|
|
+ throw new PreAuthorizeException();
|
|
|
} else if (StringUtils.isNotEmpty(annotation.hasRole())) {
|
|
|
if (hasRole(annotation.hasRole())) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
- throw new RuntimeException();
|
|
|
+ throw new PreAuthorizeException();
|
|
|
} else if (StringUtils.isNotEmpty(annotation.lacksRole())) {
|
|
|
if (lacksRole(annotation.lacksRole())) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
- throw new RuntimeException();
|
|
|
+ throw new PreAuthorizeException();
|
|
|
} else if (ARRAY_EMPTY < annotation.hasAnyRoles().length) {
|
|
|
if (hasAnyRoles(annotation.hasAnyRoles())) {
|
|
|
return point.proceed();
|
|
|
}
|
|
|
- throw new RuntimeException();
|
|
|
+ throw new PreAuthorizeException();
|
|
|
}
|
|
|
|
|
|
return point.proceed();
|