From 68dbdbe66b246ee1c162ed865f80fbd51ac66b8d Mon Sep 17 00:00:00 2001 From: zhouhao Date: Fri, 16 Jun 2017 22:54:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleAuthorizeMethodInterceptor.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java b/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java index b314c1fb3..75c82368c 100644 --- a/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java +++ b/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java @@ -28,6 +28,7 @@ import org.hswebframework.expands.script.engine.DynamicScriptEngine; import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; import org.hswebframework.utils.ClassUtils; import org.hswebframework.utils.StringUtils; +import org.hswebframework.web.ExpressionUtils; import org.hswebframework.web.authorization.Authentication; import org.hswebframework.web.authorization.Permission; import org.hswebframework.web.authorization.Role; @@ -149,22 +150,27 @@ public class SimpleAuthorizeMethodInterceptor extends AuthorizingAnnotationMetho } public String tryCompileExpression(String express) { - if (express.startsWith("${") && express.endsWith("}")) { - express = express.substring(2, express.length() - 1); - DynamicScriptEngine spelEngine = DynamicScriptEngineFactory.getEngine("spel"); - String id = DigestUtils.md5Hex(express); - try { - if (!spelEngine.compiled(id)) - spelEngine.compile(id, express); - return String.valueOf(spelEngine.execute(id, var).getIfSuccess()); - } catch (Exception e) { - throw new AuthorizationException("系统错误", e); - } finally { - // spelEngine.remove(id); - } - } else { - return express; + try { + return ExpressionUtils.analytical(express, var, "spel"); + } catch (Exception e) { + throw new AuthorizationException("系统错误", e); } +// if (express.startsWith("${") && express.endsWith("}")) { +// express = express.substring(2, express.length() - 1); +// DynamicScriptEngine spelEngine = DynamicScriptEngineFactory.getEngine("spel"); +// String id = DigestUtils.md5Hex(express); +// try { +// if (!spelEngine.compiled(id)) +// spelEngine.compile(id, express); +// return String.valueOf(spelEngine.execute(id, var).getIfSuccess()); +// } catch (Exception e) { +// throw new AuthorizationException("系统错误", e); +// } finally { +// // spelEngine.remove(id); +// } +// } else { +// return express; +// } } public Collection tryCompileExpression(String... expresses) {