Bläddra i källkod

新增isEmpty判断,用于判断权限配置是否为空,为空则表示只需要登录即可

周浩 9 år sedan
förälder
incheckning
a3f544456f

+ 3 - 3
hsweb-web-core/src/main/java/org/hsweb/web/authorize/AuthorizeValidatorConfig.java

@@ -1,6 +1,6 @@
-package org.hsweb.web.authorize;
+package org.hsweb.web.core.authorize;
 
-import org.hsweb.web.authorize.annotation.Authorize;
+import org.hsweb.web.core.authorize.annotation.Authorize;
 
 import java.util.*;
 
@@ -17,7 +17,7 @@ public interface AuthorizeValidatorConfig {
     AuthorizeValidatorConfig setMod(Authorize.MOD mod);
 
     AuthorizeValidatorConfig addExpression(String expression, String language);
-
+    boolean isEmpty();
     default AuthorizeValidatorConfig addAnnotation(Set<Authorize> authorizes) {
         Set<String> modules = new LinkedHashSet<>();
         Set<String> roles = new LinkedHashSet<>();

+ 9 - 4
hsweb-web-core/src/main/java/org/hsweb/web/authorize/validator/SimpleAuthorizeValidatorConfig.java

@@ -1,8 +1,8 @@
-package org.hsweb.web.authorize.validator;
+package org.hsweb.web.core.authorize.validator;
 
-import org.hsweb.web.authorize.AuthorizeValidatorConfig;
-import org.hsweb.web.authorize.annotation.Authorize;
-import org.hsweb.web.exception.AuthorizeException;
+import org.hsweb.web.core.authorize.AuthorizeValidatorConfig;
+import org.hsweb.web.core.authorize.annotation.Authorize;
+import org.hsweb.web.core.exception.AuthorizeException;
 import org.webbuilder.utils.common.StringUtils;
 import org.webbuilder.utils.script.engine.DynamicScriptEngine;
 import org.webbuilder.utils.script.engine.DynamicScriptEngineFactory;
@@ -91,6 +91,11 @@ public class SimpleAuthorizeValidatorConfig implements AuthorizeValidatorConfig
         return mod;
     }
 
+    @Override
+    public boolean isEmpty() {
+        return getModules().isEmpty() && getRoles().isEmpty() && getActions().isEmpty() && getExpressions().isEmpty();
+    }
+
     public static class Expression {
         private String id;
         private String language;