提交 930039e9 编写于 作者: 智布道's avatar 智布道 👁 提交者: Gitee

!10 添加 JapConfig#enableSso,AbstractJapStrategy 添加 JapUserStore 自定义

Merge pull request !10 from 如梦技术/dev
......@@ -18,6 +18,7 @@ package com.fujieid.jap.core.config;
import com.fujieid.jap.sso.config.JapSsoConfig;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
/**
* Jap configuration.
......@@ -52,6 +53,17 @@ public class JapConfig {
return sso;
}
public JapConfig enableSso() {
return setSso(true);
}
public JapConfig enableSso(Consumer<JapSsoConfig> ssoConfig) {
setSso(true);
JapSsoConfig japSsoConfig = new JapSsoConfig();
ssoConfig.accept(japSsoConfig);
return setSsoConfig(japSsoConfig);
}
public JapConfig setSso(boolean sso) {
this.sso = sso;
return this;
......
......@@ -74,19 +74,29 @@ public abstract class AbstractJapStrategy implements JapStrategy {
* @param japConfig japConfig
*/
public AbstractJapStrategy(JapUserService japUserService, JapConfig japConfig, JapCache japCache) {
this(japUserService, japConfig, japConfig.isSso() ? new SsoJapUserStore(japUserService, japConfig.getSsoConfig()) : new SessionJapUserStore(), japCache);
}
/**
* `Strategy` constructor.
*
* @param japUserService japUserService
* @param japConfig japConfig
* @param japUserStore JapUserStore
* @param japCache Jap cache
*/
public AbstractJapStrategy(JapUserService japUserService, JapConfig japConfig, JapUserStore japUserStore, JapCache japCache) {
this.japUserService = japUserService;
if (japConfig.isSso()) {
// init Kisso config
JapSsoHelper.initKissoConfig(japConfig.getSsoConfig());
}
JapUserStore japUserStore = japConfig.isSso() ? new SsoJapUserStore(japUserService, japConfig.getSsoConfig()) : new SessionJapUserStore();
this.japContext = new JapContext(japUserStore, japCache, japConfig);
JapAuthentication.setContext(this.japContext);
// Update the cache validity period
JapCacheConfig.timeout = japConfig.getCacheExpireTime();
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册