top.lingkang.finalsecurity.solonplugin.config.DefaultFinalExceptionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of final-security-solon-plugin Show documentation
Show all versions of final-security-solon-plugin Show documentation
final-security,一个基于RBAC,专注于授权认证的轻量级框架
package top.lingkang.finalsecurity.solonplugin.config;
import org.noear.solon.core.handle.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.lingkang.finalsecurity.common.base.FinalExceptionHandler;
/**
* @author lingkang
* Created by 2022/10/28
* @since 3.0.0
*/
public class DefaultFinalExceptionHandler implements FinalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(DefaultFinalExceptionHandler.class);
/**
* 需要注意, request、response 在 solon 下均为 org.noear.solon.core.handle.Context
*
* @param e
* @param request org.noear.solon.core.handle.Context
* @param response org.noear.solon.core.handle.Context
*/
@Override
public void permissionException(Throwable e, Object request, Object response) {
Context context = (Context) response;
log.warn("URL=" + context.path() + " " + e.getMessage());
context.status(403);
context.output(e.getMessage());
}
/**
* 需要注意, request、response 在 solon 下均为 org.noear.solon.core.handle.Context
*
* @param e
* @param request org.noear.solon.core.handle.Context
* @param response org.noear.solon.core.handle.Context
*/
@Override
public void notLoginException(Throwable e, Object request, Object response) {
Context context = (Context) response;
log.warn("URL=" + context.path() + " " + e.getMessage());
context.status(403);
context.output(e.getMessage());
}
/**
* 需要注意, request、response 在 solon 下均为 org.noear.solon.core.handle.Context
*
* @param e
* @param request org.noear.solon.core.handle.Context
* @param response org.noear.solon.core.handle.Context
*/
@Override
public void exception(Throwable e, Object request, Object response) {
Context context = (Context) response;
log.warn("URL=" + context.path() + " " + e.getMessage());
context.status(200);
context.output(e.getMessage());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy