All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.luues.security.core.interfaces.SecurityInvalidProvider Maven / Gradle / Ivy

package com.luues.security.core.interfaces;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 验证失败实现接口
 * 非单点模块使用
 */
public interface SecurityInvalidProvider {

    /**
     * 身份认证失败回调
     * @param request
     * @param response
     * @param authentication
     */
    void onAuthenticationFail(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception, Authentication authentication) throws IOException, ServletException;

    /**
     * 无权访问 403 返回
     * Map paramMap = new HashMap<>();
     * paramMap.put("code", "500");
     * paramMap.put("message", exception.getMessage());
     * //设置返回请求头
     * response.setContentType("application/json;charset=utf-8");
     * //写出流
     * PrintWriter out = response.getWriter();
     * out.write(JSONObject.toJSONString(paramMap));
     * out.flush();
     * out.close();
     */
    void onForbidden(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException, ServletException;

    /**
     * 用户被挤掉后回调
     */
    void onSqueezeOut(HttpServletRequest request, HttpServletResponse response, List userIds);

    /**
     * 黑名单拦截后回调
     */
    void onBlack(HttpServletRequest request, HttpServletResponse response, String ip);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy