mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
ConstantsTimeInterval
This commit is contained in:
parent
f3b799e741
commit
c0cdc6843b
@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.joda.time.DateTime;
|
||||
import org.maxkey.config.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstantsLoginType;
|
||||
import org.maxkey.constants.ConstantsTimeInterval;
|
||||
import org.maxkey.crypto.Base64Utils;
|
||||
import org.maxkey.crypto.ReciprocalUtils;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
@ -21,7 +22,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
public abstract class AbstractRemeberMeService {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(AbstractRemeberMeService.class);
|
||||
|
||||
protected Integer remeberMeValidity = RemeberMe.TWO_WEEK;
|
||||
protected Integer remeberMeValidity = ConstantsTimeInterval.TWO_WEEK;
|
||||
|
||||
protected String validity;
|
||||
|
||||
@ -169,13 +170,13 @@ public abstract class AbstractRemeberMeService {
|
||||
if (Pattern.matches("[0-9]+", validity)) {
|
||||
remeberMeValidity = Integer.parseInt(validity);
|
||||
} else if (validity.equalsIgnoreCase("ONE_DAY")) {
|
||||
remeberMeValidity = RemeberMe.ONE_DAY;
|
||||
remeberMeValidity = ConstantsTimeInterval.ONE_DAY;
|
||||
} else if (validity.equalsIgnoreCase("ONE_WEEK")) {
|
||||
remeberMeValidity = RemeberMe.ONE_WEEK;
|
||||
remeberMeValidity = ConstantsTimeInterval.ONE_WEEK;
|
||||
} else if (validity.equalsIgnoreCase("TWO_WEEK")) {
|
||||
remeberMeValidity = RemeberMe.TWO_WEEK;
|
||||
remeberMeValidity = ConstantsTimeInterval.TWO_WEEK;
|
||||
} else if (validity.equalsIgnoreCase("ONE_YEAR")) {
|
||||
remeberMeValidity = RemeberMe.ONE_YEAR;
|
||||
remeberMeValidity = ConstantsTimeInterval.ONE_YEAR;
|
||||
}
|
||||
|
||||
_logger.debug("Remeber Me Validity : " + remeberMeValidity);
|
||||
|
||||
@ -4,6 +4,7 @@ import java.time.Duration;
|
||||
import org.ehcache.UserManagedCache;
|
||||
import org.ehcache.config.builders.ExpiryPolicyBuilder;
|
||||
import org.ehcache.config.builders.UserManagedCacheBuilder;
|
||||
import org.maxkey.constants.ConstantsTimeInterval;
|
||||
|
||||
public class InMemoryRemeberMeService extends AbstractRemeberMeService {
|
||||
|
||||
@ -11,7 +12,7 @@ public class InMemoryRemeberMeService extends AbstractRemeberMeService {
|
||||
UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, RemeberMe.class)
|
||||
.withExpiry(
|
||||
ExpiryPolicyBuilder.timeToLiveExpiration(
|
||||
Duration.ofMinutes(RemeberMe.TWO_WEEK)
|
||||
Duration.ofMinutes(ConstantsTimeInterval.TWO_WEEK)
|
||||
)
|
||||
)
|
||||
.build(true);
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package org.maxkey.authn.support.rememberme;
|
||||
|
||||
import org.maxkey.constants.ConstantsTimeInterval;
|
||||
import org.maxkey.persistence.redis.RedisConnection;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
|
||||
public class RedisRemeberMeService extends AbstractRemeberMeService {
|
||||
|
||||
protected int serviceTicketValiditySeconds = RemeberMe.TWO_WEEK;
|
||||
protected int serviceTicketValiditySeconds = ConstantsTimeInterval.TWO_WEEK;
|
||||
|
||||
RedisConnectionFactory connectionFactory;
|
||||
|
||||
|
||||
@ -7,23 +7,6 @@ public class RemeberMe implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8010496585233991785L;
|
||||
|
||||
|
||||
|
||||
public static final Integer ONE_DAY = 60 * 60 * 24; // 1 day
|
||||
|
||||
public static final Integer ONE_WEEK = ONE_DAY * 7; // 1 week
|
||||
|
||||
public static final Integer TWO_WEEK = ONE_DAY * 14; // 2 week
|
||||
|
||||
public static final Integer ONE_MONTH = ONE_DAY * 30; // 1 month
|
||||
|
||||
public static final Integer TWO_MONTH = ONE_DAY * 60; // 2 month
|
||||
|
||||
/**
|
||||
* The number of seconds in one year (= 60 * 60 * 24 * 365).
|
||||
*/
|
||||
public static final Integer ONE_YEAR = 60 * 60 * 24 * 365;
|
||||
|
||||
String id;
|
||||
|
||||
String username;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.time.Duration;
|
||||
import org.ehcache.UserManagedCache;
|
||||
import org.ehcache.config.builders.ExpiryPolicyBuilder;
|
||||
import org.ehcache.config.builders.UserManagedCacheBuilder;
|
||||
import org.maxkey.authn.support.rememberme.RemeberMe;
|
||||
import org.maxkey.constants.ConstantsTimeInterval;
|
||||
import org.maxkey.crypto.password.opt.OneTimePassword;
|
||||
|
||||
public class InMemoryOptTokenStore {
|
||||
@ -12,7 +12,7 @@ public class InMemoryOptTokenStore {
|
||||
UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OneTimePassword.class)
|
||||
.withExpiry(
|
||||
ExpiryPolicyBuilder.timeToLiveExpiration(
|
||||
Duration.ofMinutes(RemeberMe.TWO_WEEK)
|
||||
Duration.ofMinutes(ConstantsTimeInterval.TWO_WEEK)
|
||||
)
|
||||
)
|
||||
.build(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user