From 195df24b4bc660b249aca092f0554bdcf2d7c1a2 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Wed, 16 Jun 2021 10:05:53 +0800
Subject: [PATCH] 升级commons.io到最新版本v2.10.0
---
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java
index 777b5b1..20e20e3 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java
@@ -11,8 +11,8 @@
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.PatternMatchUtils;
-import org.springframework.util.StringUtils;
import com.ruoyi.common.core.exception.PreAuthorizeException;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser;
@@ -35,6 +35,9 @@
/** 管理员角色权限标识 */
private static final String SUPER_ADMIN = "admin";
+ /** 数组为0时 */
+ private static final Integer ARRAY_EMPTY = 0;
+
@Around("@annotation(com.ruoyi.common.security.annotation.PreAuthorize)")
public Object around(ProceedingJoinPoint point) throws Throwable
{
@@ -47,7 +50,7 @@
return point.proceed();
}
- if (!StringUtils.isEmpty(annotation.hasPermi()))
+ if (StringUtils.isNotEmpty(annotation.hasPermi()))
{
if (hasPermi(annotation.hasPermi()))
{
@@ -55,7 +58,7 @@
}
throw new PreAuthorizeException();
}
- else if (!StringUtils.isEmpty(annotation.lacksPermi()))
+ else if (StringUtils.isNotEmpty(annotation.lacksPermi()))
{
if (lacksPermi(annotation.lacksPermi()))
{
@@ -63,7 +66,7 @@
}
throw new PreAuthorizeException();
}
- else if (!StringUtils.isEmpty(annotation.hasAnyPermi()))
+ else if (ARRAY_EMPTY < annotation.hasAnyPermi().length)
{
if (hasAnyPermi(annotation.hasAnyPermi()))
{
@@ -71,7 +74,7 @@
}
throw new PreAuthorizeException();
}
- else if (!StringUtils.isEmpty(annotation.hasRole()))
+ else if (StringUtils.isNotEmpty(annotation.hasRole()))
{
if (hasRole(annotation.hasRole()))
{
@@ -79,7 +82,7 @@
}
throw new PreAuthorizeException();
}
- else if (StringUtils.isEmpty(annotation.lacksRole()))
+ else if (StringUtils.isNotEmpty(annotation.lacksRole()))
{
if (lacksRole(annotation.lacksRole()))
{
@@ -87,7 +90,7 @@
}
throw new PreAuthorizeException();
}
- else if (StringUtils.isEmpty(annotation.hasAnyRoles()))
+ else if (ARRAY_EMPTY < annotation.hasAnyRoles().length)
{
if (hasAnyRoles(annotation.hasAnyRoles()))
{
@@ -108,7 +111,7 @@
public boolean hasPermi(String permission)
{
LoginUser userInfo = tokenService.getLoginUser();
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
{
return false;
}
@@ -135,7 +138,7 @@
public boolean hasAnyPermi(String[] permissions)
{
LoginUser userInfo = tokenService.getLoginUser();
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
{
return false;
}
@@ -159,13 +162,13 @@
public boolean hasRole(String role)
{
LoginUser userInfo = tokenService.getLoginUser();
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
{
return false;
}
for (String roleKey : userInfo.getRoles())
{
- if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(role))
+ if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(role))
{
return true;
}
@@ -193,7 +196,7 @@
public boolean hasAnyRoles(String[] roles)
{
LoginUser userInfo = tokenService.getLoginUser();
- if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
+ if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
{
return false;
}
@@ -217,6 +220,6 @@
private boolean hasPermissions(Collection<String> authorities, String permission)
{
return authorities.stream().filter(StringUtils::hasText)
- .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x));
+ .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(x, permission));
}
}
--
Gitblit v1.9.3