2020-02-05 00:31:51 +08:00
|
|
|
package cn.dev33.satoken;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.config.SaTokenConfig;
|
|
|
|
import cn.dev33.satoken.config.SaTokenConfigFactory;
|
|
|
|
import cn.dev33.satoken.dao.SaTokenDao;
|
|
|
|
import cn.dev33.satoken.dao.SaTokenDaoDefault;
|
|
|
|
import cn.dev33.satoken.stp.StpInterface;
|
|
|
|
import cn.dev33.satoken.stp.StpInterfaceDefaultImpl;
|
2020-09-07 02:21:35 +08:00
|
|
|
import cn.dev33.satoken.util.SaTokenInsideUtil;
|
2020-02-05 00:31:51 +08:00
|
|
|
|
|
|
|
/**
|
2020-09-07 02:21:35 +08:00
|
|
|
* 管理sa-token所有对象
|
2020-02-05 00:31:51 +08:00
|
|
|
* @author kong
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class SaTokenManager {
|
|
|
|
|
2020-09-07 02:21:35 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 配置文件 Bean
|
|
|
|
*/
|
2020-02-05 00:31:51 +08:00
|
|
|
private static SaTokenConfig config;
|
|
|
|
public static SaTokenConfig getConfig() {
|
|
|
|
if (config == null) {
|
|
|
|
initConfig();
|
|
|
|
}
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
public static void setConfig(SaTokenConfig config) {
|
|
|
|
SaTokenManager.config = config;
|
|
|
|
if(config.getIsV()) {
|
2020-09-07 02:21:35 +08:00
|
|
|
SaTokenInsideUtil.printSaToken();
|
2020-02-05 00:31:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
public synchronized static void initConfig() {
|
|
|
|
if (config == null) {
|
|
|
|
setConfig(SaTokenConfigFactory.createConfig());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 02:21:35 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 持久化 Bean
|
|
|
|
*/
|
2020-02-05 00:31:51 +08:00
|
|
|
public static SaTokenDao dao;
|
|
|
|
public static SaTokenDao getDao() {
|
|
|
|
if (dao == null) {
|
|
|
|
initDao();
|
|
|
|
}
|
|
|
|
return dao;
|
|
|
|
}
|
|
|
|
public static void setDao(SaTokenDao dao) {
|
|
|
|
SaTokenManager.dao = dao;
|
|
|
|
}
|
|
|
|
public synchronized static void initDao() {
|
|
|
|
if (dao == null) {
|
|
|
|
setDao(new SaTokenDaoDefault());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-07 02:21:35 +08:00
|
|
|
/**
|
|
|
|
* 权限认证 Bean
|
|
|
|
*/
|
2020-02-05 00:31:51 +08:00
|
|
|
public static StpInterface stp;
|
|
|
|
public static StpInterface getStp() {
|
|
|
|
if (stp == null) {
|
|
|
|
initStp();
|
|
|
|
}
|
|
|
|
return stp;
|
|
|
|
}
|
|
|
|
public static void setStp(StpInterface stp) {
|
|
|
|
SaTokenManager.stp = stp;
|
|
|
|
}
|
|
|
|
public synchronized static void initStp() {
|
|
|
|
if (stp == null) {
|
|
|
|
setStp(new StpInterfaceDefaultImpl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|