|
|
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
@Log4j2
|
|
|
|
@ -47,7 +48,7 @@ public class NiceCiGenerator {
|
|
|
|
|
@Value("${contract.nice.ci.rest.api.ci}")
|
|
|
|
|
private String API_CI;
|
|
|
|
|
|
|
|
|
|
public ResponseVO initialKey(){
|
|
|
|
|
public ResponseVO initialKey() {
|
|
|
|
|
|
|
|
|
|
NiceCiApiExecutor executor = buildExecutor();
|
|
|
|
|
try {
|
|
|
|
@ -80,11 +81,12 @@ public class NiceCiGenerator {
|
|
|
|
|
dataBodySymkeyResp = SymmetricKey.getInstance().getData();
|
|
|
|
|
} else { //대칭키 상태가 유효하지 않으면...
|
|
|
|
|
//현재 대칭키 조회(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일 이상 남았으면
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
//대칭키 싱글톤 객체 초기화
|
|
|
|
@ -137,7 +139,7 @@ public class NiceCiGenerator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private NiceCiApiExecutor buildExecutor(){
|
|
|
|
|
private NiceCiApiExecutor buildExecutor() {
|
|
|
|
|
return NiceCiApiExecutor.builder()
|
|
|
|
|
.HOST(this.HOST)
|
|
|
|
|
.CLIENT_ID(this.CLIENT_ID)
|
|
|
|
|