diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7f74778553b8ee82747e2752b8b826fa3060ba68..c941afc21677546875455db5d855b7c4a126daf5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,7 @@ - + diff --git a/src/main/java/com/zhxy/Handler/AccessDeny.java b/src/main/java/com/zhxy/Handler/AccessDeny.java deleted file mode 100644 index 4ba3ef4fdc024a1ccfe4ea503a7c8cb074e6d7f4..0000000000000000000000000000000000000000 --- a/src/main/java/com/zhxy/Handler/AccessDeny.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.zhxy.Handler; - -import com.google.gson.Gson; -import com.zhxy.common.R; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.access.AccessDeniedHandler; -import org.springframework.stereotype.Component; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -//无权访问 -@Component -public class AccessDeny implements AccessDeniedHandler{ - @Autowired - Gson gson; - - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException { - response.setContentType("application/json;charset=utf-8"); - response.getWriter().write(gson.toJson(R.error("无权访问,need Authorities!!"))); - } -} diff --git a/src/main/java/com/zhxy/config/SecurityConfig.java b/src/main/java/com/zhxy/config/SecurityConfig.java index c0414ebc064cc4a734c53c968c0bdd57d31924d9..1b53f2d2f2d42601e9ccf300e67cdcd756c9404d 100644 --- a/src/main/java/com/zhxy/config/SecurityConfig.java +++ b/src/main/java/com/zhxy/config/SecurityConfig.java @@ -29,8 +29,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired AuthenticationLogout authenticationLogout; //注销 @Autowired - AccessDeny accessDeny; //无权访问 - @Autowired SelfAuthenticationProvider selfAuthenticationProvider; //自定义认证逻辑处理 @Autowired private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter; @@ -83,7 +81,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .deleteCookies("JSESSIONID") //删除cookie .and().exceptionHandling() - .accessDeniedHandler(accessDeny) //权限不足的时候的逻辑处理 .authenticationEntryPoint(authenticationEnryPoint);//未登录是的逻辑处理