Class SecurityAuthenticationEntryPoint
java.lang.Object
com.codeupsoft.component.security.handler.SecurityAuthenticationEntryPoint
- All Implemented Interfaces:
org.springframework.security.web.AuthenticationEntryPoint
public class SecurityAuthenticationEntryPoint
extends Object
implements org.springframework.security.web.AuthenticationEntryPoint
认证入口点处理器.
当用户未认证或认证失败时,返回401未授权错误信息. 将错误信息以JSON格式返回给客户端.
- Author:
- Liu,Dongdong
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcommence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) 处理认证异常.
-
Constructor Details
-
SecurityAuthenticationEntryPoint
public SecurityAuthenticationEntryPoint()
-
-
Method Details
-
commence
public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) throws IOException 处理认证异常.当用户未认证或认证信息无效时,此方法被调用. 返回401状态码和JSON格式的错误信息.
- Specified by:
commencein interfaceorg.springframework.security.web.AuthenticationEntryPoint- Parameters:
request- HTTP请求对象response- HTTP响应对象authException- 认证异常- Throws:
IOException- IO异常
-