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

com.flyfish.oauth.domain.OAuthSSOToken Maven / Gradle / Ivy

package com.flyfish.oauth.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.flyfish.oauth.common.OAuthContext;
import com.flyfish.oauth.configuration.OAuth2SsoProperties;
import lombok.Data;

import javax.servlet.http.Cookie;
import java.util.Arrays;
import java.util.List;

/**
 * 统一登录用户信息
 *
 * @author wangyu
 */
@Data
public class OAuthSSOToken implements OAuth2AccessToken {

    @JsonProperty("access_token")
    private String accessToken;

    @JsonProperty("expires_in")
    private Integer expiresIn;

    @JsonProperty("refresh_token")
    private String refreshToken;

    @JsonProperty("user_id")
    private String userId;

    private String scope;

    public List toCookies() {
        OAuth2SsoProperties properties = OAuthContext.getProperties();
        // access_token
        Cookie accessTokenCookie = new Cookie(OAuth2AccessToken.ACCESS_TOKEN, accessToken);
        accessTokenCookie.setPath(properties.getCookiePath());
        accessTokenCookie.setMaxAge(expiresIn);
        // refresh_token
        Cookie refreshTokenCookie = new Cookie(OAuth2AccessToken.REFRESH_TOKEN, refreshToken);
        refreshTokenCookie.setPath(properties.getCookiePath());
        return Arrays.asList(accessTokenCookie, refreshTokenCookie);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy