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

org.shoulder.security.authentication.browser.handler.BrowserLogoutSuccessHandler Maven / Gradle / Ivy

Go to download

Shoulder 基础模块,基于 Spring Security + Spring Boot Web的安全模块,除了提供用户认证、授权、会话管理等基础功能,还允许轻松更换认证模式,如 Session / Token(JWT) 模式切换。

There is a newer version: 0.8.1
Show newest version
package org.shoulder.security.authentication.browser.handler;

import org.apache.commons.lang3.StringUtils;
import org.shoulder.core.util.JsonUtils;
import org.shoulder.core.dto.response.BaseResponse;
import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 40
 *
 * @author lym
 */
public class BrowserLogoutSuccessHandler implements LogoutSuccessHandler {

    public BrowserLogoutSuccessHandler(String signOutSuccessUrl) {
        this.signOutSuccessUrl = signOutSuccessUrl;
    }

    private String signOutSuccessUrl;

    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
            throws IOException {

        if (StringUtils.isBlank(signOutSuccessUrl)) {
            response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
            response.getWriter().write(JsonUtils.toJson(BaseResponse.success()));
        } else {
            response.sendRedirect(signOutSuccessUrl);
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy