|
@@ -3,6 +3,7 @@ package com.its.op;
|
|
|
import com.its.utils.AES256Util;
|
|
|
import com.its.utils.SHA256Util;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import net.jodah.expiringmap.ExpiringMap;
|
|
|
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
|
|
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
|
|
|
import org.jasypt.salt.StringFixedSaltGenerator;
|
|
@@ -11,8 +12,11 @@ import org.springframework.test.context.ActiveProfiles;
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.DriverManager;
|
|
|
+import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Slf4j
|
|
|
//@SpringBootTest
|
|
@@ -21,6 +25,21 @@ public class ItsOpServerApplicationTests {
|
|
|
// @Autowired
|
|
|
// DefaultListableBeanFactory bf;
|
|
|
|
|
|
+ @Test
|
|
|
+ void ttl() {
|
|
|
+ ExpiringMap<String, String> tokenEventMap;
|
|
|
+ tokenEventMap = ExpiringMap.builder()
|
|
|
+ .variableExpiration()
|
|
|
+ .maxSize(1000)
|
|
|
+ .build();
|
|
|
+ Date date = new Date();
|
|
|
+ long secondAtExpiry = date.toInstant().getEpochSecond();
|
|
|
+ long secondAtLogout = Instant.now().getEpochSecond();
|
|
|
+ long ttl = Math.max(0, secondAtExpiry - secondAtLogout);
|
|
|
+ log.error("{}, {}, {}", secondAtExpiry, secondAtLogout, ttl);
|
|
|
+ tokenEventMap.put("TEST", "data", ttl, TimeUnit.SECONDS);
|
|
|
+ log.error("{}", tokenEventMap);
|
|
|
+ }
|
|
|
@Test
|
|
|
void encrypt() {
|
|
|
// for(String n : bf.getBeanDefinitionNames()){
|