cn.gybyt.advice.GybytControllerSecurityExceptionAdvice Maven / Gradle / Ivy
The newest version!
package cn.gybyt.advice;
import cn.gybyt.util.BaseResponse;
import cn.gybyt.util.HttpStatusEnum;
import cn.gybyt.util.SpringUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.expression.SecurityExpressionHandler;
import org.springframework.security.authentication.*;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* security异常处理
*
* @program: utils
* @classname: GybytControllerSecurityExceptionAdvice
* @author: codetiger
* @create: 2022/11/21 20:01
**/
@Order(Ordered.HIGHEST_PRECEDENCE)
@RestControllerAdvice
@ConditionalOnClass(SecurityExpressionHandler.class)
public class GybytControllerSecurityExceptionAdvice {
@ExceptionHandler({AuthenticationException.class})
public BaseResponse