com.flyfish.oauth.common.OAuthContext Maven / Gradle / Ivy
package com.flyfish.oauth.common;
import com.flyfish.oauth.client.OAuth2SsoClient;
import com.flyfish.oauth.client.OAuth2SsoClientInitializer;
import com.flyfish.oauth.configuration.OAuth2SsoProperties;
import com.flyfish.oauth.domain.OAuthSSOToken;
import org.apache.http.util.Asserts;
/**
* 统一认证上下文
*
* @author wybab
*/
public final class OAuthContext {
// 唯一单例
private static final OAuthContext CONTEXT = new OAuthContext();
/**
* 获取客户端token
*
* @return 结果
*/
public static OAuthSSOToken clientToken() {
OAuthSSOToken clientToken = OAuth2SsoClientInitializer.clientToken();
Asserts.notNull(clientToken, "客户端密钥获取失败!请检查配置或者本地网络连接!信息:clientToken");
// 返回
return clientToken;
}
/**
* 获取客户端
*
* @return 结果
*/
public static OAuth2SsoClient getClient() {
return OAuth2SsoClientInitializer.getClient();
}
/**
* 获取当前的配置变量
*
* @return 结果
*/
public static OAuth2SsoProperties getProperties() {
return getClient().getProperties();
}
/**
* 获取上下文
*
* @return 上下文
*/
public OAuthContext sharedContext() {
return CONTEXT;
}
}