package io.renren.modules.kubesphere.interceptor;

import io.renren.modules.app.entity.UserEntity;

/**
 * KubeSphere token 管理器
 *
 * @author chenrj
 * @email 1412736935@qq.com
 * @since 2021/8/1
 */
public class KubeSphereTokenManger {
    private static volatile KubeSphereTokenManger sInstance;
    private static String token;
    private static UserEntity user;

    private KubeSphereTokenManger() {

    }

    public static KubeSphereTokenManger get() {
        if (sInstance == null) {
            synchronized (KubeSphereTokenManger.class) {
                if (sInstance == null) {
                    sInstance = new KubeSphereTokenManger();
                }
            }
        }
        return sInstance;
    }

    public void setUser(UserEntity user) {
        this.user = user;
    }

    public UserEntity getUser() {
        return user;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getToken() {
        return token;
    }

    public static void clearMemory() {
        KubeSphereTokenManger.user = null;
        KubeSphereTokenManger.token = null;
    }

}
