|
|
@@ -11,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
11
|
11
|
import org.springframework.stereotype.Component;
|
|
12
|
12
|
import org.springframework.util.CollectionUtils;
|
|
13
|
13
|
import org.springframework.util.PatternMatchUtils;
|
|
14
|
|
-import org.springframework.util.StringUtils;
|
|
15
|
14
|
import com.ruoyi.common.core.exception.PreAuthorizeException;
|
|
|
15
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
16
|
16
|
import com.ruoyi.common.security.annotation.PreAuthorize;
|
|
17
|
17
|
import com.ruoyi.common.security.service.TokenService;
|
|
18
|
18
|
import com.ruoyi.system.api.model.LoginUser;
|
|
|
@@ -50,7 +50,7 @@ public class PreAuthorizeAspect
|
|
50
|
50
|
return point.proceed();
|
|
51
|
51
|
}
|
|
52
|
52
|
|
|
53
|
|
- if (!StringUtils.isEmpty(annotation.hasPermi()))
|
|
|
53
|
+ if (StringUtils.isNotEmpty(annotation.hasPermi()))
|
|
54
|
54
|
{
|
|
55
|
55
|
if (hasPermi(annotation.hasPermi()))
|
|
56
|
56
|
{
|
|
|
@@ -58,7 +58,7 @@ public class PreAuthorizeAspect
|
|
58
|
58
|
}
|
|
59
|
59
|
throw new PreAuthorizeException();
|
|
60
|
60
|
}
|
|
61
|
|
- else if (!StringUtils.isEmpty(annotation.lacksPermi()))
|
|
|
61
|
+ else if (StringUtils.isNotEmpty(annotation.lacksPermi()))
|
|
62
|
62
|
{
|
|
63
|
63
|
if (lacksPermi(annotation.lacksPermi()))
|
|
64
|
64
|
{
|
|
|
@@ -74,7 +74,7 @@ public class PreAuthorizeAspect
|
|
74
|
74
|
}
|
|
75
|
75
|
throw new PreAuthorizeException();
|
|
76
|
76
|
}
|
|
77
|
|
- else if (!StringUtils.isEmpty(annotation.hasRole()))
|
|
|
77
|
+ else if (StringUtils.isNotEmpty(annotation.hasRole()))
|
|
78
|
78
|
{
|
|
79
|
79
|
if (hasRole(annotation.hasRole()))
|
|
80
|
80
|
{
|
|
|
@@ -82,7 +82,7 @@ public class PreAuthorizeAspect
|
|
82
|
82
|
}
|
|
83
|
83
|
throw new PreAuthorizeException();
|
|
84
|
84
|
}
|
|
85
|
|
- else if (!StringUtils.isEmpty(annotation.lacksRole()))
|
|
|
85
|
+ else if (StringUtils.isNotEmpty(annotation.lacksRole()))
|
|
86
|
86
|
{
|
|
87
|
87
|
if (lacksRole(annotation.lacksRole()))
|
|
88
|
88
|
{
|
|
|
@@ -111,7 +111,7 @@ public class PreAuthorizeAspect
|
|
111
|
111
|
public boolean hasPermi(String permission)
|
|
112
|
112
|
{
|
|
113
|
113
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
114
|
|
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
|
|
|
114
|
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
|
|
115
|
115
|
{
|
|
116
|
116
|
return false;
|
|
117
|
117
|
}
|
|
|
@@ -138,7 +138,7 @@ public class PreAuthorizeAspect
|
|
138
|
138
|
public boolean hasAnyPermi(String[] permissions)
|
|
139
|
139
|
{
|
|
140
|
140
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
141
|
|
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
|
|
|
141
|
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
|
|
142
|
142
|
{
|
|
143
|
143
|
return false;
|
|
144
|
144
|
}
|
|
|
@@ -162,7 +162,7 @@ public class PreAuthorizeAspect
|
|
162
|
162
|
public boolean hasRole(String role)
|
|
163
|
163
|
{
|
|
164
|
164
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
165
|
|
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
|
|
|
165
|
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
|
|
166
|
166
|
{
|
|
167
|
167
|
return false;
|
|
168
|
168
|
}
|
|
|
@@ -196,7 +196,7 @@ public class PreAuthorizeAspect
|
|
196
|
196
|
public boolean hasAnyRoles(String[] roles)
|
|
197
|
197
|
{
|
|
198
|
198
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
199
|
|
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
|
|
|
199
|
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
|
|
200
|
200
|
{
|
|
201
|
201
|
return false;
|
|
202
|
202
|
}
|
|
|
@@ -220,6 +220,6 @@ public class PreAuthorizeAspect
|
|
220
|
220
|
private boolean hasPermissions(Collection<String> authorities, String permission)
|
|
221
|
221
|
{
|
|
222
|
222
|
return authorities.stream().filter(StringUtils::hasText)
|
|
223
|
|
- .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x));
|
|
|
223
|
+ .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(x, permission));
|
|
224
|
224
|
}
|
|
225
|
225
|
}
|