修改异常命名

This commit is contained in:
zhouhao
2017-08-18 15:21:23 +08:00
parent d7f84f399b
commit 4c6108550a
4 changed files with 16 additions and 12 deletions

View File

@@ -6,7 +6,6 @@ import org.hswebframework.web.authorization.Authentication;
import org.hswebframework.web.authorization.define.AuthorizingContext;
import org.hswebframework.web.authorization.basic.handler.AuthorizingHandler;
import org.hswebframework.web.authorization.define.AuthorizeDefinition;
import org.hswebframework.web.authorization.exception.AuthorizationException;
import org.hswebframework.web.authorization.exception.UnAuthorizedException;
import org.hswebframework.web.boost.aop.context.MethodInterceptorHolder;
import org.hswebframework.web.boost.aop.context.MethodInterceptorParamContext;

View File

@@ -11,7 +11,7 @@ import org.hswebframework.web.authorization.access.DataAccessController;
import org.hswebframework.web.authorization.annotation.Logical;
import org.hswebframework.web.authorization.define.AuthorizeDefinition;
import org.hswebframework.web.authorization.define.AuthorizingContext;
import org.hswebframework.web.authorization.exception.AuthorizationException;
import org.hswebframework.web.authorization.exception.AccessDenyException;
import org.hswebframework.web.boost.aop.context.MethodInterceptorParamContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,7 +80,7 @@ public class DefaultAuthorizingHandler implements AuthorizingHandler {
//调用控制器进行验证
boolean isAccess = function.apply(access -> finalAccessController.doAccess(access, context));
if (!isAccess) {
throw new AuthorizationException(context.getDefinition().getMessage());
throw new AccessDenyException(context.getDefinition().getMessage());
}
}
@@ -91,21 +91,21 @@ public class DefaultAuthorizingHandler implements AuthorizingHandler {
DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(definition.getScript().getLanguage());
if (null == engine) {
throw new AuthorizationException("{unknown_engine}:" + definition.getScript().getLanguage());
throw new AccessDenyException("{unknown_engine}:" + definition.getScript().getLanguage());
}
if (!engine.compiled(scriptId)) {
try {
engine.compile(scriptId, definition.getScript().getScript());
} catch (Exception e) {
logger.error("express compile error", e);
throw new AuthorizationException("{expression_error}");
throw new AccessDenyException("{expression_error}");
}
}
Map<String, Object> var = new HashMap<>(paramContext.getParams());
var.put("auth", authentication);
Object success = engine.execute(scriptId, var).get();
if (!(success instanceof Boolean) || !((Boolean) success)) {
throw new AuthorizationException(definition.getMessage());
throw new AccessDenyException(definition.getMessage());
}
}
}
@@ -171,7 +171,7 @@ public class DefaultAuthorizingHandler implements AuthorizingHandler {
access = func.apply(authentication.getUser().getUsername()::equals);
}
if (!access) {
throw new AuthorizationException(definition.getMessage());
throw new AccessDenyException(definition.getMessage());
}
}
}