From d3e73f0ce93cfc9ff19559e02a0d6e867f6a56db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=B5=A9?= Date: Wed, 8 Jun 2016 22:47:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8C=BF=E5=90=8D=E8=AE=BF?= =?UTF-8?q?=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/core/authorize/AopAuthorizeValidator.java | 13 ++++++++----- .../web/core/authorize/annotation/Authorize.java | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java index b48de5cd6..f6d1c877b 100644 --- a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java +++ b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java @@ -38,11 +38,14 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator { return null; } Set authorizes = new LinkedHashSet<>(); - if (classAuth != null) + if (classAuth != null) { + if (classAuth.anonymous()) return null; authorizes.add(classAuth); - if (methodAuth != null) + } + if (methodAuth != null) { + if (methodAuth.anonymous()) return null; authorizes.add(methodAuth); - + } config.addAnnotation(authorizes); configCache.put(cacheKey, config); } @@ -65,11 +68,11 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator { Map param = new LinkedHashMap<>(); MethodSignature signature = (MethodSignature) pjp.getSignature(); String[] names = signature.getParameterNames(); - Object[] args=pjp.getArgs(); + Object[] args = pjp.getArgs(); for (int i = 0; i < names.length; i++) { param.put(names[i], args[i]); } - param.put("paramsMap",param); + param.put("paramsMap", param); return validate(user, param, config); } diff --git a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java index a965e0193..4dfa64402 100644 --- a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java +++ b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java @@ -54,6 +54,11 @@ public @interface Authorize { */ boolean api() default false; + /** + * 可匿名访问 + * @return 是否可匿名访问,匿名访问将不用登录 + */ + boolean anonymous() default false; /** * 验证模式,在使用多个验证条件时有效 *