mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
add ko-time.auth-expire
This commit is contained in:
parent
5395aaa777
commit
a96d30829c
@ -31,6 +31,16 @@ public class DefaultConfig {
|
||||
private String userName;
|
||||
private String password;
|
||||
|
||||
private Long authExpire;
|
||||
|
||||
public Long getAuthExpire() {
|
||||
return authExpire;
|
||||
}
|
||||
|
||||
public void setAuthExpire(Long authExpire) {
|
||||
this.authExpire = authExpire;
|
||||
}
|
||||
|
||||
public Double getDiscardRate() {
|
||||
return discardRate;
|
||||
}
|
||||
|
||||
@ -90,6 +90,7 @@ public class LoadConfig {
|
||||
config.setLanguage(defaultConfig.getLanguage() == null ? "chinese" : defaultConfig.getLanguage());
|
||||
config.setThreadNum(defaultConfig.getThreadNum() == null ? 2 : defaultConfig.getThreadNum());
|
||||
config.setDiscardRate(defaultConfig.getDiscardRate() == null ? 0.3 : defaultConfig.getDiscardRate());
|
||||
config.setAuthExpire(defaultConfig.getAuthExpire() == null ? (12*60*60l) : defaultConfig.getAuthExpire());
|
||||
config.setAuthEnable(defaultConfig.getAuthEnable() == null ? false : defaultConfig.getAuthEnable());
|
||||
config.setParamAnalyse(defaultConfig.getParamAnalyse() == null ? true : defaultConfig.getParamAnalyse());
|
||||
config.setDataReset(defaultConfig.getDataReset() == null ? false : defaultConfig.getDataReset());
|
||||
|
||||
@ -22,7 +22,7 @@ public class KoUtil {
|
||||
* nothing to introduce for this, that everyone knows!
|
||||
*/
|
||||
public static String login(String userName) {
|
||||
String token = encode(userName + "KOTO" + (System.currentTimeMillis() + (12 * 60 * 60 * 1000)));
|
||||
String token = encode(userName + "KOTO" + (System.currentTimeMillis() + (Context.getConfig().getAuthExpire() * 1000)));
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@ -123,6 +123,13 @@
|
||||
"description": "to enable authentication",
|
||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||
},
|
||||
{
|
||||
"name": "ko-time.auth-expire",
|
||||
"type": "java.lang.Long",
|
||||
"defaultValue":43200 ,
|
||||
"description": "expire within 43200 s",
|
||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||
},
|
||||
{
|
||||
"name": "ko-time.user-name",
|
||||
"type": "java.lang.String",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user