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

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

package com.luues.security.core.interfaces;

import com.luues.security.core.authentication.expand.ExpandAuthenticationDetails;
import com.luues.security.core.entity.SysUser;
import com.luues.security.enumeration.VerifyType;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.ui.Model;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 登录实现接口
 * 单点模块使用
 */
public interface SecurityAuthenticationProvider {

    /**
     * 返回指定登录页
     * @param request
     * @param response
     * @param model
     * @return
     */
    ModelAndView loginPage(HttpServletRequest request, HttpServletResponse response, Model model);

    /**
     * 创建加密方式
     * @return
     */
    PasswordEncoder passwordEncoder();

    /**
     * 登录逻辑处理方法
     * @param authentication
     * @param captchaAuthenticationDetails
     * @return
     * @throws AuthenticationException
     */
    SysUser authenticate(Authentication authentication, ExpandAuthenticationDetails captchaAuthenticationDetails) throws AuthenticationException;

    /**
     * 登录成功回调方法
     * Map paramMap = new HashMap<>();
     * paramMap.put("code", "400");
     * paramMap.put("message", "登录成功!");
     * //设置返回请求头
     * response.setContentType("application/json;charset=utf-8");
     * //写出流
     * PrintWriter out = response.getWriter();
     * out.write(JsonUtils.toJson(paramMap));
     * out.flush();
     * out.close();
     */
    void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication, VerifyType verifyType, String identity) throws IOException, ServletException;

    /**
     * 登录失败回调方法
     * 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(JsonUtils.toJson(paramMap));
     * out.flush();
     * out.close();
     */
    void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException;

    /**
     * 获取用户权限组
     * @param sysUser
     * @return
     */
    List findUserRoles(SysUser sysUser) ;

    /**
     * 获取用户权限(细分)
     * @param sysUser
     * @return
     */
    List findUserPermissions(SysUser sysUser) ;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy