|
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
|
|
@Log4j2
|
|
|
|
@Log4j2
|
|
|
@ -47,7 +48,7 @@ public class NiceCiGenerator {
|
|
|
|
@Value("${contract.nice.ci.rest.api.ci}")
|
|
|
|
@Value("${contract.nice.ci.rest.api.ci}")
|
|
|
|
private String API_CI;
|
|
|
|
private String API_CI;
|
|
|
|
|
|
|
|
|
|
|
|
public ResponseVO initialKey(){
|
|
|
|
public ResponseVO initialKey() {
|
|
|
|
|
|
|
|
|
|
|
|
NiceCiApiExecutor executor = buildExecutor();
|
|
|
|
NiceCiApiExecutor executor = buildExecutor();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -80,11 +81,12 @@ public class NiceCiGenerator {
|
|
|
|
dataBodySymkeyResp = SymmetricKey.getInstance().getData();
|
|
|
|
dataBodySymkeyResp = SymmetricKey.getInstance().getData();
|
|
|
|
} else { //대칭키 상태가 유효하지 않으면...
|
|
|
|
} else { //대칭키 상태가 유효하지 않으면...
|
|
|
|
//현재 대칭키 조회(by 공개키)
|
|
|
|
//현재 대칭키 조회(by 공개키)
|
|
|
|
Optional<NiceCiSymkeyMng> niceCiSymkeyMng = niceCiSymkeyMngRepository.findByPubkey(pubkeyResponseVO.getResultInfo().getPublicKey());
|
|
|
|
List<NiceCiSymkeyMng> niceCiSymkeyMngs = niceCiSymkeyMngRepository.findAllByPubkeyOrderByRegistDtDesc(pubkeyResponseVO.getResultInfo().getPublicKey());
|
|
|
|
|
|
|
|
Optional<NiceCiSymkeyMng> niceCiSymkeyMng = Optional.ofNullable(niceCiSymkeyMngs == null || niceCiSymkeyMngs.isEmpty() ? null : niceCiSymkeyMngs.get(0));
|
|
|
|
|
|
|
|
|
|
|
|
//대칭키 유효기간만료일이 1일 이상 남았으면
|
|
|
|
//대칭키 유효기간만료일이 1일 이상 남았으면
|
|
|
|
if (niceCiSymkeyMng.isPresent()
|
|
|
|
if (niceCiSymkeyMng.isPresent()
|
|
|
|
&&(Long.parseLong(niceCiSymkeyMng.get().getExpireDt()) > Long.parseLong(LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")))) ) {
|
|
|
|
&& (Long.parseLong(niceCiSymkeyMng.get().getExpireDt()) > Long.parseLong(LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))))) {
|
|
|
|
dataBodySymkeyResp = mapper.readValue(niceCiSymkeyMng.get().getRespJsonData(), DataBodySymkeyResp.class);
|
|
|
|
dataBodySymkeyResp = mapper.readValue(niceCiSymkeyMng.get().getRespJsonData(), DataBodySymkeyResp.class);
|
|
|
|
|
|
|
|
|
|
|
|
//대칭키 싱글톤 객체 초기화
|
|
|
|
//대칭키 싱글톤 객체 초기화
|
|
|
@ -137,7 +139,7 @@ public class NiceCiGenerator {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private NiceCiApiExecutor buildExecutor(){
|
|
|
|
private NiceCiApiExecutor buildExecutor() {
|
|
|
|
return NiceCiApiExecutor.builder()
|
|
|
|
return NiceCiApiExecutor.builder()
|
|
|
|
.HOST(this.HOST)
|
|
|
|
.HOST(this.HOST)
|
|
|
|
.CLIENT_ID(this.CLIENT_ID)
|
|
|
|
.CLIENT_ID(this.CLIENT_ID)
|
|
|
|