diff --git a/mens-api/src/main/java/kr/xit/biz/ens/package-info.java b/mens-api/src/main/java/kr/xit/biz/ens/package-info.java deleted file mode 100644 index 54aed88..0000000 --- a/mens-api/src/main/java/kr/xit/biz/ens/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * ENS business packages - *
- * 전자고지 : ens - *
- * @since 1.0 - * @author limju - * @version 1.0 - */ -package kr.xit.biz.ens; diff --git a/mens-api/src/main/java/kr/xit/biz/ens/mapper/IKkoMyDocMapper.java b/mens-api/src/main/java/kr/xit/biz/kakao/mapper/IKkoMyDocMapper.java similarity index 82% rename from mens-api/src/main/java/kr/xit/biz/ens/mapper/IKkoMyDocMapper.java rename to mens-api/src/main/java/kr/xit/biz/kakao/mapper/IKkoMyDocMapper.java index ee16ccf..5aa084c 100644 --- a/mens-api/src/main/java/kr/xit/biz/ens/mapper/IKkoMyDocMapper.java +++ b/mens-api/src/main/java/kr/xit/biz/kakao/mapper/IKkoMyDocMapper.java @@ -1,14 +1,14 @@ -package kr.xit.biz.ens.mapper; +package kr.xit.biz.kakao.mapper; -import kr.xit.biz.ens.model.KkoMyDocDTO.MobilePageManage; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; +import kr.xit.biz.kakao.model.KkoMyDocDTO.MobilePageManage; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; /** ** description : 카카오 전자문서 API용 mapper * - * packageName : kr.xit.biz.ens.mapper + * packageName : kr.xit.biz.kakao.mapper * fileName : IKkoMyDocMapper * author : limju * date : 2023-08-31 diff --git a/mens-api/src/main/java/kr/xit/biz/ens/model/KkoMyDocDTO.java b/mens-api/src/main/java/kr/xit/biz/kakao/model/KkoMyDocDTO.java similarity index 88% rename from mens-api/src/main/java/kr/xit/biz/ens/model/KkoMyDocDTO.java rename to mens-api/src/main/java/kr/xit/biz/kakao/model/KkoMyDocDTO.java index 1a71192..b166cc7 100644 --- a/mens-api/src/main/java/kr/xit/biz/ens/model/KkoMyDocDTO.java +++ b/mens-api/src/main/java/kr/xit/biz/kakao/model/KkoMyDocDTO.java @@ -1,19 +1,20 @@ -package kr.xit.biz.ens.model; - -import java.io.Serializable; -import java.time.LocalDateTime; +package kr.xit.biz.kakao.model; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; - -import lombok.*; +import java.io.Serializable; +import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; /** ** description : 카카오 전자문서 DTO * - * packageName : kr.xit.biz.ens.model + * packageName : kr.xit.biz.kakao.model * fileName : KkoMyDocDTO * author : limju * date : 2023-08-31 diff --git a/mens-api/src/main/java/kr/xit/biz/kakao/package-info.java b/mens-api/src/main/java/kr/xit/biz/kakao/package-info.java new file mode 100644 index 0000000..0b5242f --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/kakao/package-info.java @@ -0,0 +1,10 @@ +/** + * kakao ENS business packages + *+ * 전자고지 : kakao + *
+ * @since 1.0 + * @author limju + * @version 1.0 + */ +package kr.xit.biz.kakao; diff --git a/mens-api/src/main/java/kr/xit/biz/ens/service/IKkoMyDocService.java b/mens-api/src/main/java/kr/xit/biz/kakao/service/IKkoMyDocService.java similarity index 89% rename from mens-api/src/main/java/kr/xit/biz/ens/service/IKkoMyDocService.java rename to mens-api/src/main/java/kr/xit/biz/kakao/service/IKkoMyDocService.java index 50a276b..c653494 100644 --- a/mens-api/src/main/java/kr/xit/biz/ens/service/IKkoMyDocService.java +++ b/mens-api/src/main/java/kr/xit/biz/kakao/service/IKkoMyDocService.java @@ -1,4 +1,4 @@ -package kr.xit.biz.ens.service; +package kr.xit.biz.kakao.service; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; import kr.xit.core.model.ApiResponseDTO; @@ -7,7 +7,7 @@ import kr.xit.core.model.ApiResponseDTO; ** description : 카카오 전자문서 API Service Interface * - * packageName : kr.xit.biz.ens.service + * packageName : kr.xit.biz.kakao.service * fileName : IKkoMyDocService * author : limju * date : 2023-08-31 diff --git a/mens-api/src/main/java/kr/xit/biz/ens/service/KkoMyDocService.java b/mens-api/src/main/java/kr/xit/biz/kakao/service/KkoMyDocService.java similarity index 91% rename from mens-api/src/main/java/kr/xit/biz/ens/service/KkoMyDocService.java rename to mens-api/src/main/java/kr/xit/biz/kakao/service/KkoMyDocService.java index 755f070..340ab11 100644 --- a/mens-api/src/main/java/kr/xit/biz/ens/service/KkoMyDocService.java +++ b/mens-api/src/main/java/kr/xit/biz/kakao/service/KkoMyDocService.java @@ -1,24 +1,23 @@ -package kr.xit.biz.ens.service; +package kr.xit.biz.kakao.service; -import kr.xit.biz.ens.mapper.IKkoMyDocMapper; -import kr.xit.biz.ens.model.KkoMyDocDTO.MobilePageManage; import kr.xit.biz.ens.model.kakao.KkopayDocDTO; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; +import kr.xit.biz.kakao.mapper.IKkoMyDocMapper; +import kr.xit.biz.kakao.model.KkoMyDocDTO.MobilePageManage; import kr.xit.core.consts.ErrorCode; -import kr.xit.ens.support.kakao.service.IKkopayEltrcDocService; -import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; -import org.springframework.stereotype.Service; - import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.support.utils.Checks; +import kr.xit.ens.kakao.service.IKkopayEltrcDocService; import lombok.RequiredArgsConstructor; +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; +import org.springframework.stereotype.Service; /** ** description : 카카오 전자문서 API Service * - * packageName : kr.xit.biz.ens.service + * packageName : kr.xit.biz.kakao.service * fileName : KkoMyDocService * author : limju * date : 2023-08-31 diff --git a/mens-api/src/main/java/kr/xit/biz/ens/web/KkoMyDocController.java b/mens-api/src/main/java/kr/xit/biz/kakao/web/KkoMyDocController.java similarity index 90% rename from mens-api/src/main/java/kr/xit/biz/ens/web/KkoMyDocController.java rename to mens-api/src/main/java/kr/xit/biz/kakao/web/KkoMyDocController.java index 1c1b65d..d7132b6 100644 --- a/mens-api/src/main/java/kr/xit/biz/ens/web/KkoMyDocController.java +++ b/mens-api/src/main/java/kr/xit/biz/kakao/web/KkoMyDocController.java @@ -1,9 +1,9 @@ -package kr.xit.biz.ens.web; +package kr.xit.biz.kakao.web; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; -import kr.xit.biz.ens.service.IKkoMyDocService; +import kr.xit.biz.kakao.service.IKkoMyDocService; import kr.xit.core.model.ApiResponseDTO; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; ** description : 카카오 전자문서 API Controller * - * packageName : kr.xit.biz.ens.web + * packageName : kr.xit.biz.kakao.web * fileName : KkoMyDocController * author : limju * date : 2023-08-31 @@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController; @Tag(name = "KkoMyDocController", description = "카카오페이 전자문서 API Controller") @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/ens/v1") +@RequestMapping(value = "/api/biz/kakao/v1") public class KkoMyDocController { private final IKkoMyDocService service; diff --git a/mens-api/src/main/java/kr/xit/ens/support/cmm/mapper/ICmmEnsMapper.java b/mens-api/src/main/java/kr/xit/ens/cmm/mapper/ICmmEnsMapper.java similarity index 89% rename from mens-api/src/main/java/kr/xit/ens/support/cmm/mapper/ICmmEnsMapper.java rename to mens-api/src/main/java/kr/xit/ens/cmm/mapper/ICmmEnsMapper.java index 7d6ee12..fb6ae18 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/cmm/mapper/ICmmEnsMapper.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/mapper/ICmmEnsMapper.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.cmm.mapper; +package kr.xit.ens.cmm.mapper; import kr.xit.biz.ens.model.nice.NiceCiDTO.CrtfInfo; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; @@ -8,7 +8,7 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper; * description : 전자고지 공통 mapper * - cache: CaffeineCache use * - * packageName : kr.xit.ens.support.cmm.mapper + * packageName : kr.xit.ens.cmm.mapper * fileName : ICmmEnsMapper * author : limju * date : 2023-09-12 diff --git a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/CmmEnsCacheService.java b/mens-api/src/main/java/kr/xit/ens/cmm/service/CmmEnsCacheService.java similarity index 95% rename from mens-api/src/main/java/kr/xit/ens/support/cmm/service/CmmEnsCacheService.java rename to mens-api/src/main/java/kr/xit/ens/cmm/service/CmmEnsCacheService.java index ad1e021..26751f2 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/CmmEnsCacheService.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/service/CmmEnsCacheService.java @@ -1,9 +1,9 @@ -package kr.xit.ens.support.cmm.service; +package kr.xit.ens.cmm.service; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.stats.CacheStats; import kr.xit.biz.ens.model.nice.NiceCiDTO.CrtfInfo; -import kr.xit.ens.support.cmm.mapper.ICmmEnsMapper; +import kr.xit.ens.cmm.mapper.ICmmEnsMapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.cache.CacheManager; diff --git a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/CmmEnsFileService.java b/mens-api/src/main/java/kr/xit/ens/cmm/service/CmmEnsFileService.java similarity index 97% rename from mens-api/src/main/java/kr/xit/ens/support/cmm/service/CmmEnsFileService.java rename to mens-api/src/main/java/kr/xit/ens/cmm/service/CmmEnsFileService.java index 7fa7d08..5d4eca6 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/CmmEnsFileService.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/service/CmmEnsFileService.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.cmm.service; +package kr.xit.ens.cmm.service; import java.io.IOException; import java.io.InputStream; @@ -29,7 +29,7 @@ import org.springframework.web.multipart.MultipartFile; ** description : * - * packageName : kr.xit.ens.support.cmm.service + * packageName : kr.xit.ens.cmm.service * fileName : CmmEnsFileService * author : limju * date : 2023-09-05 @@ -43,7 +43,7 @@ import org.springframework.web.multipart.MultipartFile; @Slf4j @RequiredArgsConstructor @Service -public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEnsFileService{ +public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEnsFileService { private final static int FMC_EXCEL_DATA_START_ROW = 3; private final static int FMC_EXCEL_CELL_CNT = 7; diff --git a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/ICmmEnsCacheService.java b/mens-api/src/main/java/kr/xit/ens/cmm/service/ICmmEnsCacheService.java similarity index 89% rename from mens-api/src/main/java/kr/xit/ens/support/cmm/service/ICmmEnsCacheService.java rename to mens-api/src/main/java/kr/xit/ens/cmm/service/ICmmEnsCacheService.java index 57e7b47..0983492 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/ICmmEnsCacheService.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/service/ICmmEnsCacheService.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.cmm.service; +package kr.xit.ens.cmm.service; import kr.xit.biz.ens.model.nice.NiceCiDTO.CrtfInfo; @@ -6,7 +6,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.CrtfInfo; ** description : CaffeineCache 적용 * - * packageName : kr.xit.ens.support.cmm.service + * packageName : kr.xit.ens.cmm.service * fileName : ICmmEnsCacheService * author : limju * date : 2023-09-12 diff --git a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/ICmmEnsFileService.java b/mens-api/src/main/java/kr/xit/ens/cmm/service/ICmmEnsFileService.java similarity index 85% rename from mens-api/src/main/java/kr/xit/ens/support/cmm/service/ICmmEnsFileService.java rename to mens-api/src/main/java/kr/xit/ens/cmm/service/ICmmEnsFileService.java index 5ab9442..3ca18be 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/cmm/service/ICmmEnsFileService.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/service/ICmmEnsFileService.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.cmm.service; +package kr.xit.ens.cmm.service; import kr.xit.biz.ens.model.cmm.CmmEnsFileDTO.FmcExcelUpload; @@ -6,7 +6,7 @@ import kr.xit.biz.ens.model.cmm.CmmEnsFileDTO.FmcExcelUpload; ** description : * - * packageName : kr.xit.ens.support.cmm.service + * packageName : kr.xit.ens.cmm.service * fileName : ICmmEnsFileService * author : limju * date : 2023-09-05 diff --git a/mens-api/src/main/java/kr/xit/ens/support/cmm/web/CmmEnsFileController.java b/mens-api/src/main/java/kr/xit/ens/cmm/web/CmmEnsFileController.java similarity index 91% rename from mens-api/src/main/java/kr/xit/ens/support/cmm/web/CmmEnsFileController.java rename to mens-api/src/main/java/kr/xit/ens/cmm/web/CmmEnsFileController.java index 1f8b34e..c20e6ba 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/cmm/web/CmmEnsFileController.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/web/CmmEnsFileController.java @@ -1,10 +1,10 @@ -package kr.xit.ens.support.cmm.web; +package kr.xit.ens.cmm.web; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import kr.xit.biz.ens.model.cmm.CmmEnsFileDTO.FmcExcelUpload; import kr.xit.core.model.ApiResponseDTO; -import kr.xit.ens.support.cmm.service.ICmmEnsFileService; +import kr.xit.ens.cmm.service.ICmmEnsFileService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; @@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController; ** description : 전자고지 연계 파일 관련 처리 * - * packageName : kr.xit.ens.support.cmm.web + * packageName : kr.xit.ens.cmm.web * fileName : CmmFileMgtController * author : limju * date : 2023-09-04 @@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController; @Tag(name = "CmmEnsFileController", description = "전자고지 연계 파일 관련 처리") @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/cmm") +@RequestMapping(value = "/api/ens/cmm") public class CmmEnsFileController { private final ICmmEnsFileService service; diff --git a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/AsyncKkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java similarity index 98% rename from mens-api/src/main/java/kr/xit/ens/support/kakao/service/AsyncKkopayEltrcDocService.java rename to mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java index 2fbccb5..71f9ef8 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/AsyncKkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/service/AsyncKkopayEltrcDocService.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.kakao.service; +package kr.xit.ens.kakao.service; import java.util.ArrayList; import java.util.List; @@ -6,11 +6,9 @@ import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; - import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; - import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.Receiver; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendRequests; @@ -23,25 +21,24 @@ import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendRequest; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendResponse; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenRequest; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenResponse; -import kr.xit.core.spring.util.ApiWebClientUtil; -import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpMethod; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.spring.annotation.TraceLogging; +import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.support.utils.Checks; import kr.xit.core.support.utils.JsonUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; /** ** description : 카카오 페이 전자 문서 발송 요청 서비스 - * packageName : kr.xit.ens.support.kakao.service + * packageName : kr.xit.ens.kakao.service * fileName : KkopayEltrcDocService * author : julim * date : 2023-04-28 @@ -56,7 +53,8 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @RequiredArgsConstructor @Component -public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implements IAsyncKkopayEltrcDocService { +public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implements + IAsyncKkopayEltrcDocService { @Value("${contract.kakao.host}") private String HOST; diff --git a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/IAsyncKkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/service/IAsyncKkopayEltrcDocService.java similarity index 95% rename from mens-api/src/main/java/kr/xit/ens/support/kakao/service/IAsyncKkopayEltrcDocService.java rename to mens-api/src/main/java/kr/xit/ens/kakao/service/IAsyncKkopayEltrcDocService.java index f07e2cb..5e0885b 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/IAsyncKkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/service/IAsyncKkopayEltrcDocService.java @@ -1,15 +1,11 @@ -package kr.xit.ens.support.kakao.service; +package kr.xit.ens.kakao.service; import java.util.concurrent.CompletableFuture; - -import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; -import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendResponses; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusResponses; -import kr.xit.biz.ens.model.kakao.KkopayDocDTO; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.DocStatusResponse; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendRequest; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendResponse; @@ -20,7 +16,7 @@ import kr.xit.core.model.ApiResponseDTO; /** ** description : 카카오 페이 전자 문서 발송 요청 인터 페이스 - * packageName : kr.xit.ens.support.kakao.service + * packageName : kr.xit.ens.kakao.service * fileName : IKkopayEltrcDocService * author : julim * date : 2023-04-28 diff --git a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/IKkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/service/IKkopayEltrcDocService.java similarity index 92% rename from mens-api/src/main/java/kr/xit/ens/support/kakao/service/IKkopayEltrcDocService.java rename to mens-api/src/main/java/kr/xit/ens/kakao/service/IKkopayEltrcDocService.java index a566874..59da08e 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/IKkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/service/IKkopayEltrcDocService.java @@ -1,13 +1,10 @@ -package kr.xit.ens.support.kakao.service; +package kr.xit.ens.kakao.service; -import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; -import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendResponses; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusResponses; -import kr.xit.biz.ens.model.kakao.KkopayDocDTO; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.DocStatusResponse; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendRequest; @@ -19,7 +16,7 @@ import kr.xit.core.model.ApiResponseDTO; /** ** description : 카카오 페이 전자 문서 발송 요청 인터 페이스 - * packageName : kr.xit.ens.support.kakao.service + * packageName : kr.xit.ens.kakao.service * fileName : IKkopayEltrcDocService * author : julim * date : 2023-04-28 @@ -103,6 +100,6 @@ public interface IKkopayEltrcDocService { BulkStatusResponses findBulkStatus(final BulkStatusRequests reqDTO); - ApiResponseDTOfindMyDocReadyAndMblPage(OneTimeToken reqDTO); + ApiResponseDTO findMyDocReadyAndMblPage(OneTimeToken reqDTO); } diff --git a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/KkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java similarity index 97% rename from mens-api/src/main/java/kr/xit/ens/support/kakao/service/KkopayEltrcDocService.java rename to mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java index 5ba6f38..10d8a65 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/kakao/service/KkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/service/KkopayEltrcDocService.java @@ -1,11 +1,13 @@ -package kr.xit.ens.support.kakao.service; +package kr.xit.ens.kakao.service; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; - +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.Receiver; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendReq; @@ -13,7 +15,6 @@ import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendResponses; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusResponses; -import kr.xit.biz.ens.model.kakao.KkopayDocDTO; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.DocStatusResponse; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.RequestSend; @@ -28,24 +29,18 @@ import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.support.utils.Checks; import kr.xit.core.support.utils.JsonUtils; - import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.lang3.StringUtils; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.*; +import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; - /** * * description : 카카오 페이 전자 문서 발송 요청 서비스 - * packageName : kr.xit.ens.support.kakao.service + * packageName : kr.xit.ens.kakao.service * fileName : KkopayEltrcDocService * author : julim * date : 2023-04-28 @@ -59,7 +54,8 @@ import javax.validation.Validator; @Slf4j @RequiredArgsConstructor @Component -public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements IKkopayEltrcDocService { +public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements + IKkopayEltrcDocService { @Value("${contract.kakao.host}") private String HOST; @@ -262,7 +258,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements IK } @Override - public ApiResponseDTOfindMyDocReadyAndMblPage(OneTimeToken reqDTO) { + public ApiResponseDTO findMyDocReadyAndMblPage(OneTimeToken reqDTO) { String url = HOST + API_VALID_TOKEN[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()) .replace("{tokens}", reqDTO.getToken()); diff --git a/mens-api/src/main/java/kr/xit/ens/support/kakao/web/AsyncKkopayEltrcDocController.java b/mens-api/src/main/java/kr/xit/ens/kakao/web/AsyncKkopayEltrcDocController.java similarity index 95% rename from mens-api/src/main/java/kr/xit/ens/support/kakao/web/AsyncKkopayEltrcDocController.java rename to mens-api/src/main/java/kr/xit/ens/kakao/web/AsyncKkopayEltrcDocController.java index 5e78e40..50b77d0 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/kakao/web/AsyncKkopayEltrcDocController.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/web/AsyncKkopayEltrcDocController.java @@ -1,26 +1,28 @@ -package kr.xit.ens.support.kakao.web; +package kr.xit.ens.kakao.web; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.tags.Tag; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendRequests; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusRequests; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendRequest; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenRequest; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.tags.Tag; import kr.xit.core.model.ApiResponseDTO; -import kr.xit.ens.support.kakao.service.IAsyncKkopayEltrcDocService; +import kr.xit.ens.kakao.service.IAsyncKkopayEltrcDocService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * * description : 카카오 페이 전자 문서 발송 비동기용 controller - * packageName : kr.xit.ens.support.kakao.web + * packageName : kr.xit.ens.kakao.web * fileName : AsyncKkopayEltrcDocController * author : julim * date : 2023-04-28 @@ -35,7 +37,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/kakaopay/v2") +@RequestMapping(value = "/api/ens/kakao/v2") public class AsyncKkopayEltrcDocController { private final IAsyncKkopayEltrcDocService service; diff --git a/mens-api/src/main/java/kr/xit/ens/support/kakao/web/KkopayEltrcDocController.java b/mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java similarity index 94% rename from mens-api/src/main/java/kr/xit/ens/support/kakao/web/KkopayEltrcDocController.java rename to mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java index 1a9de67..540fb7b 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/kakao/web/KkopayEltrcDocController.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/web/KkopayEltrcDocController.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.kakao.web; +package kr.xit.ens.kakao.web; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -10,19 +10,20 @@ import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusRequests; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendRequest; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenRequest; import kr.xit.core.model.ApiResponseDTO; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import kr.xit.ens.support.kakao.service.IKkopayEltrcDocService; +import kr.xit.ens.kakao.service.IKkopayEltrcDocService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** ** description : 카카오 페이 전자 문서 발송 controller - * packageName : kr.xit.ens.support.kakao.web + * packageName : kr.xit.ens.kakao.web * fileName : KkopayEltrcDocController * author : julim * date : 2023-04-28 @@ -37,7 +38,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/kakaopay/v1") +@RequestMapping(value = "/api/ens/kakao/v1") public class KkopayEltrcDocController { @Value("${contract.kakao.token}") private String accessToken; diff --git a/mens-api/src/main/java/kr/xit/ens/support/nice/service/INiceCiService.java b/mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java similarity index 88% rename from mens-api/src/main/java/kr/xit/ens/support/nice/service/INiceCiService.java rename to mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java index ccafbe8..4388c8d 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/nice/service/INiceCiService.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.nice.service; +package kr.xit.ens.nice.service; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; @@ -7,12 +7,13 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRegResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRegResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; +import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; /** ** description : * - * packageName : kr.xit.ens.support.nice.service + * packageName : kr.xit.ens.nice.service * fileName : INiceCiService * author : limju * date : 2023-09-06 @@ -28,7 +29,7 @@ public interface INiceCiService { // 기관용 Token //-------------------------------------------------------------------------------- TokenResponse generateToken(final TokenRequest reqDTO); - TokenResponse revokeToken(); + TokenRevokeResponse revokeToken(); //-------------------------------------------------------------------------------- // 기관용 Token //-------------------------------------------------------------------------------- @@ -36,7 +37,7 @@ public interface INiceCiService { //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - PublickeyResponse requestPublickey(final PublickeyRequest reqDTO); + PublickeyResponse requestPublickey(); //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- @@ -44,7 +45,7 @@ public interface INiceCiService { //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- - SymmetrickeyRegResponse requestRegSymmetrickey(SymmetrickeyRegRequest reqDTO); + SymmetrickeyRegResponse requestRegSymmetrickey(); //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- diff --git a/mens-api/src/main/java/kr/xit/ens/support/nice/service/NiceCiDummyTestService.java b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiDummyTestService.java similarity index 75% rename from mens-api/src/main/java/kr/xit/ens/support/nice/service/NiceCiDummyTestService.java rename to mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiDummyTestService.java index a90e9f4..16861d1 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/nice/service/NiceCiDummyTestService.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiDummyTestService.java @@ -1,4 +1,4 @@ -package kr.xit.ens.support.nice.service; +package kr.xit.ens.nice.service; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -13,9 +13,12 @@ import java.util.stream.Collectors; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; +import kr.xit.biz.ens.model.nice.NiceCiDTO.CrtfInfo; +import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyReqDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; +import kr.xit.biz.ens.model.nice.NiceCiDTO.RequestDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResDataBody; @@ -25,7 +28,10 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.util.ApiWebClientUtil; +import kr.xit.core.support.utils.DateUtils; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; @@ -38,7 +44,7 @@ import org.springframework.util.Base64Utils; ** description : * - * packageName : kr.xit.ens.support.nice.service + * packageName : kr.xit.ens.nice.service * fileName : NiceCiService * author : limju * date : 2023-09-06 @@ -50,6 +56,7 @@ import org.springframework.util.Base64Utils; **/ //FIXME : client_id, client_secret, access_token DB 처리후 반영 필요 +@Slf4j @RequiredArgsConstructor @Service public class NiceCiDummyTestService extends EgovAbstractServiceImpl { @@ -73,8 +80,11 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl { @Value("${contract.nice.api.ci}") private String API_CI; + private final int EXPIRED_CHECK_DAYS = 1; private static final String AUTH_TYPE_BASIC = "Basic"; private static final String AUTH_TYPE_BEARER = "bearer"; + private static final String CNTY_CD = "kr"; + private static final String PUB_KEY_REQ_TRAN_ID_PREFIX = "TRAN_ID-"; private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); private final ApiWebClientUtil webClient; @@ -91,15 +101,6 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl { @TraceLogging public TokenResponse generateToken(final TokenRequest reqDTO){ validate(reqDTO); - Mapmap = new HashMap<>(); - map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); - map.put(HttpHeaders.AUTHORIZATION, - String.format("%s %s", AUTH_TYPE_BASIC, - Base64Utils.encodeToString( - Base64Utils.encode(String.format("%s:%s", this.CLIENT_ID, "this.CLIENT_SECRET").getBytes(StandardCharsets.UTF_8)) - ) - ) - ); return TokenResponse.builder() .dataHeader(ResponseDataHeader.builder() @@ -147,15 +148,26 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl { // 공개키(Publickey) //-------------------------------------------------------------------------------- - public PublickeyResponse requestPublickey(final PublickeyRequest reqDTO) { - validate(reqDTO); + public PublickeyResponse requestPublickey() { + final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"); + final PublickeyRequest pubReqDTO = PublickeyRequest.builder() + .dataHeader(RequestDataHeader.builder() + .cntyId(CNTY_CD) + .tranId(String.format("%s%s", PUB_KEY_REQ_TRAN_ID_PREFIX, todayDt)) + .build()) + .dataBody(PublickeyReqDataBody.builder() + .reqDtim(todayDt) + .build()) + .build(); + log.debug("{}", pubReqDTO); + validate(pubReqDTO); return PublickeyResponse.builder() .dataHeader(ResponseDataHeader.builder() .gwRsltCd("1200") .gwRsltMsg("오류없음") - .tranId(reqDTO.getDataHeader().getTranId()) - .cntyId(reqDTO.getDataHeader().getCntyId()) + .tranId(pubReqDTO.getDataHeader().getTranId()) + .cntyId(pubReqDTO.getDataHeader().getCntyId()) .build()) .dataBody(PublickeyResDataBody.builder() .rspCd("P000") @@ -174,25 +186,6 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl { //-------------------------------------------------------------------------------- //------------------------------------------------------------------------------- - private Map getHeaderMap(final String contentType, final String type){ - Map map = new HashMap<>(); - map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); - map.put( - HttpHeaders.AUTHORIZATION, - String.format("%s %s", - type, - Base64Utils.encodeToString( - Base64Utils.encode( - String.format("%s:%s:%s", - "accessToken", - (new Date().getTime() / 1000), - this.CLIENT_ID).getBytes(StandardCharsets.UTF_8)) - ) - ) - ); - return map; - } - private static void validate(T t) { Set > list = validator.validate(t); @@ -207,4 +200,27 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl { .collect(Collectors.toList()).toString()); } } + + private CrtfInfo getNiceCrtInfo() { + return CrtfInfo.builder() + .signguCode("11000") + .ffnlgCode("11") + .clientId("6c3eb1ff-530d-458a-9a6e-e02e3346f679") + .clientSecret("960f204ec45bb312b7ad2d6b54b984d9c353b8") + .productId("2101466024") + .accessToken("ff5e27fe-8b5d-49db-ab1e-0ccf07de6ac1") + .expiresIn(1576983050) + .tokenType("bearer") + .scope("default") + .siteCode("AAAA==") + .keyVersion("20210121ca8c1612-2c2d-IPaa-aad1-xxxxxxxxxxxx") + .publicKey("MIIBIjANBgkqhkiG9w0BAQEFAA.....JJxwIDAQAB...") + .validDtim("20220121181550") + .remainingDays(2) + .build(); + } + + private CrtfInfo getPublickeyCrtInfo(RequestDataHeader reqHeader){ + return getNiceCrtInfo(); + } } diff --git a/mens-api/src/main/java/kr/xit/ens/support/nice/service/NiceCiService.java b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java similarity index 63% rename from mens-api/src/main/java/kr/xit/ens/support/nice/service/NiceCiService.java rename to mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java index a2c031e..656285e 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/nice/service/NiceCiService.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java @@ -1,9 +1,11 @@ -package kr.xit.ens.support.nice.service; +package kr.xit.ens.nice.service; +import egovframework.com.cmm.EgovMessageSource; import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; +import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.Base64; @@ -11,7 +13,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.Set; import java.util.stream.Collectors; import javax.crypto.BadPaddingException; @@ -28,17 +29,21 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.RequestDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader; +import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyRegInfo; +import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRegReqDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRegRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRegResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; +import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.JsonUtils; -import kr.xit.ens.support.cmm.mapper.ICmmEnsMapper; -import kr.xit.ens.support.cmm.service.CmmEnsCacheService; +import kr.xit.core.support.utils.UUIDGenerateUtils; +import kr.xit.ens.cmm.mapper.ICmmEnsMapper; +import kr.xit.ens.cmm.service.CmmEnsCacheService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; @@ -55,7 +60,7 @@ import org.springframework.util.Base64Utils; * * description : * - * packageName : kr.xit.ens.support.nice.service + * packageName : kr.xit.ens.nice.service * fileName : NiceCiService * author : limju * date : 2023-09-06 @@ -92,12 +97,15 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer private String API_CI; //FIXME::업무처리 최대 주기 - private final int EXPIRED_CHECK_DAYS = 1; + private final int EXPIRED_CHECK_DAYS = 0; private static final String AUTH_TYPE_BASIC = "Basic"; private static final String AUTH_TYPE_BEARER = "bearer"; - private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); + private static final String CNTY_CD = "kr"; + private static final String TRAN_ID_PREFIX = "TRAN_ID-"; + private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); + private final EgovMessageSource messageSource; private final ApiWebClientUtil webClient; private final CmmEnsCacheService cacheService; private final ICmmEnsMapper cmmEnsMapper; @@ -117,10 +125,12 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer public TokenResponse generateToken(final TokenRequest reqDTO){ validate(reqDTO); + CrtfInfo niceDTO = getNiceCrtInfo(); + Map*/ @Override - public SymmetrickeyRegResponse requestRegSymmetrickey(SymmetrickeyRegRequest reqDTO) { + public SymmetrickeyRegResponse requestRegSymmetrickey() { + //FIXME::NICE 연계이후 메소드 교체 + //CrtfInfo niceDTO = getPublickeyCrtInfo(); + CrtfInfo niceDTO = getNiceCrtInfo(); + + SymkeyRegInfo symkeyRegInfo = getSymkeyRegInfo(niceDTO); + + //FIXME::NICE 연계이후 comment 제거 + //String encSymkeyRegInfo = encodeString(niceDTO.getPublicKey(), JsonUtils.toJson(symkeyRegInfo)); + String encSymkeyRegInfo = "encodeStringniceDTOgetPublicKeyJsonUtilstoJsonsymkeyRegInfo"; + + + final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"); + + SymmetrickeyRegRequest reqDTO = SymmetrickeyRegRequest.builder() + .dataHeader(RequestDataHeader.builder() + .cntyId(CNTY_CD) + .tranId(TRAN_ID_PREFIX + todayDt) + .build()) + .dataBody(SymmetrickeyRegReqDataBody.builder() + .pubkeyVersion(niceDTO.getKeyVersion()) + .symkeyRegInfo(encSymkeyRegInfo) + .build()) + .build(); validate(reqDTO); + Mapmap = new HashMap<>(); map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); map.put(HttpHeaders.AUTHORIZATION, - String.format("%s %s", AUTH_TYPE_BASIC, Base64Utils.encodeToString(Base64Utils.encode(String.format("%s:%s", this.CLIENT_ID, "this.CLIENT_SECRET").getBytes(StandardCharsets.UTF_8))))); + String.format("%s %s", AUTH_TYPE_BASIC, Base64Utils.encodeToString(Base64Utils.encode(String.format("%s:%s", CLIENT_ID, niceDTO.getClientSecret()).getBytes(StandardCharsets.UTF_8))))); return webClient.exchange(HOST + API_GENERATE_TOKEN, HttpMethod.POST, JsonUtils.toJson(reqDTO), TokenResponse.class, map); } @@ -138,15 +148,15 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer */ @Override @TraceLogging - public TokenResponse revokeToken(){ - //validate(reqDTO, null); + public TokenRevokeResponse revokeToken(){ + CrtfInfo niceDTO = getNiceCrtInfo(); return webClient.exchange( HOST + API_GENERATE_TOKEN, HttpMethod.POST, null, - TokenResponse.class, - getHeaderMap(MediaType.APPLICATION_FORM_URLENCODED_VALUE, AUTH_TYPE_BASIC)); + TokenRevokeResponse.class, + getHeaderMap(MediaType.APPLICATION_FORM_URLENCODED_VALUE, AUTH_TYPE_BASIC, niceDTO.getAccessToken())); } //-------------------------------------------------------------------------------- // 기관용 Token @@ -158,15 +168,27 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer @Override @TraceLogging - public PublickeyResponse requestPublickey(final PublickeyRequest reqDTO) { - validate(reqDTO); + public PublickeyResponse requestPublickey() { + CrtfInfo niceDTO = getNiceCrtInfo(); + + final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"); + final PublickeyRequest pubReqDTO = PublickeyRequest.builder() + .dataHeader(RequestDataHeader.builder() + .cntyId(CNTY_CD) + .tranId(String.format("%s%s", TRAN_ID_PREFIX, todayDt)) + .build()) + .dataBody(PublickeyReqDataBody.builder() + .reqDtim(todayDt) + .build()) + .build(); + validate(pubReqDTO); return webClient.exchange( HOST + API_GENERATE_TOKEN, HttpMethod.POST, null, PublickeyResponse.class, - getHeaderMap(MediaType.APPLICATION_JSON_VALUE, AUTH_TYPE_BEARER)); + getHeaderMap(MediaType.APPLICATION_JSON_VALUE, AUTH_TYPE_BEARER, niceDTO.getAccessToken())); } //-------------------------------------------------------------------------------- @@ -188,49 +210,91 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer * headerMap = getHeaderMap(MediaType.APPLICATION_JSON_VALUE, AUTH_TYPE_BEARER, niceDTO.getAccessToken()); + headerMap.put("ProductID", niceDTO.getProductId()); - CrtfInfo crtfInfo = getNiceCrtInfo(reqDTO.getDataHeader()); + return webClient.exchange( + HOST + API_SYMMETRICKEY, + HttpMethod.POST, + reqDTO, + SymmetrickeyRegResponse.class, + headerMap); + } + //-------------------------------------------------------------------------------- + // 대칭키 : symmetrickey + //-------------------------------------------------------------------------------- + //------------------------------------------------------------------------------- + /** + * Nice 인증 정보 조회 + * @return + */ + private CrtfInfo getNiceCrtInfo() { + CrtfInfo crtfInfo = cacheService.getNiceCrtfInfoCache(SIGNGU_CODE, FFNLG_CODE, CLIENT_ID); + if(ObjectUtils.isEmpty(crtfInfo)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.crtfInfo")); + cacheService.logCache(); - return null; + return crtfInfo; } /** * + * 공개키 정보 조회 * 0. cache call - * --> 공개키 잔여일 수가 5보다 작으면 - * 1. 공개키 재발급후 공개키 정보 update - * 2. cache 삭제 && cache call - * @param reqHeader RequestDataHeader + * --> 공개키 잔여일 기준 보다 작으면 + * 1. 토큰 폐기 + * 2. 공개키 재발급후 + * 3. 공개키 정보 update + * 4. cache 삭제 && cache reload * @return **/ - private CrtfInfo getNiceCrtInfo(RequestDataHeader reqHeader) { - CrtfInfo crtfInfo = cacheService.getNiceCrtfInfoCache(SIGNGU_CODE, FFNLG_CODE, CLIENT_ID); - cacheService.logCache(); - + private CrtfInfo getPublickeyCrtInfo() { + CrtfInfo crtfInfo = getNiceCrtInfo(); if(crtfInfo.getRemainingDays() > EXPIRED_CHECK_DAYS) return crtfInfo; - //FIXME::공개키 발급요청 call - PublickeyRequest pubReqDTO = PublickeyRequest.builder() - .dataHeader(reqHeader) - .dataBody(PublickeyReqDataBody.builder() - .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) - .build()) - .build(); + // 1. 토큰 폐기 + TokenRevokeResponse revokeResDTO = revokeToken(); + if(!(revokeResDTO.getDataHeader().getGwRsltCd().equals("1200") && revokeResDTO.getDataBody().isResult())){ + throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.revoke.token")); + } - PublickeyResponse pubResDTO = requestPublickey(pubReqDTO); - //PublickeyResponse pubResDTO = JsonUtils.toObject(pubResJson, PublickeyResponse.class); + // 2. 공개키 발급 요청 + PublickeyResponse pubResDTO = requestPublickey(); - //FIXME::공개키 정보 갱신 + //FIXME::공개키 정보 갱신 - Error code enum 전환 ResponseDataHeader dataHeader = pubResDTO.getDataHeader(); PublickeyResDataBody dataBody = pubResDTO.getDataBody(); + // 3. 공개키 정보 update if(dataHeader.getGwRsltCd().equals("1200") && dataBody.getRspCd().equals("P000") && dataBody.getResultCd().equals("0000")){ @@ -244,16 +308,29 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer throw BizRuntimeException.create(JsonUtils.toJson(dataHeader)); } + // 4. cache 삭제 && cache reload cacheService.removeNiceCrtfInfoCache(SIGNGU_CODE, FFNLG_CODE, CLIENT_ID); return cacheService.getNiceCrtfInfoCache(SIGNGU_CODE, FFNLG_CODE, CLIENT_ID); } - //-------------------------------------------------------------------------------- - // 대칭키 : symmetrickey - //-------------------------------------------------------------------------------- + /** + *+ * 대칭키(symmetrickey) 등록 요청시 symkey_reg_info JSON 데이타 생성 + * @param crtfInfo + * @return + *+ */ + private SymkeyRegInfo getSymkeyRegInfo(CrtfInfo crtfInfo) { + return SymkeyRegInfo.builder() + .siteCode(crtfInfo.getSiteCode()) + .requestNo(UUIDGenerateUtils.generateLengthUuid(30)) + .key(UUIDGenerateUtils.generateLengthUuid(32)) + .iv(UUIDGenerateUtils.generateLengthUuid(16)) + .hmacKey(UUIDGenerateUtils.generateLengthUuid(32)) + .build(); + } - //------------------------------------------------------------------------------- - private MapgetHeaderMap(final String contentType, final String type){ + private Map getHeaderMap(final String contentType, final String type, final String accessToken){ Map map = new HashMap<>(); if(ObjectUtils.isNotEmpty(contentType)) map.put(HttpHeaders.CONTENT_TYPE, contentType); map.put( @@ -263,7 +340,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer Base64Utils.encodeToString( Base64Utils.encode( String.format("%s:%s:%s", - "accessToken", + accessToken, (new Date().getTime() / 1000), this.CLIENT_ID).getBytes(StandardCharsets.UTF_8)) ) @@ -295,13 +372,12 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer * @param planText * @return */ - protected final String encodeString(final String strPublicKey, final String planText) { //throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - + private String encodeString(final String strPublicKey, String planText) { //throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { try { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); byte[] cipherEnc = Base64.getDecoder().decode(strPublicKey); X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(cipherEnc); - java.security.PublicKey publicKey = keyFactory.generatePublic(publicKeySpec); + PublicKey publicKey = keyFactory.generatePublic(publicKeySpec); Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); @@ -317,16 +393,21 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer } } - protected final String randomAlphaWord(int wordLength) { - Random r = new Random(); - - StringBuilder sb = new StringBuilder(wordLength); - for (int i = 0; i < wordLength; i++) { - char tmp = (char) ('a' + r.nextInt('z' - 'a')); - sb.append(tmp); - - } - return sb.toString(); - - } +// private String encodeString2(final String strPublicKey, final String planText) { //throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { +// +// try { +// PublicKey publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAJJxwIDAQAB"; +// Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); +// cipher.init(Cipher.ENCRYPT_MODE, publicKey); +// byte[] bytePlain = cipher.doFinal(planText.getBytes()); +// return Base64Utils.encodeToString(bytePlain); +// +// } catch (NoSuchAlgorithmException|InvalidKeySpecException|NoSuchPaddingException|InvalidKeyException e){ +// throw BizRuntimeException.create(e.getMessage()); +// } catch (IllegalBlockSizeException e) { +// throw BizRuntimeException.create(e.getMessage()); +// } catch (BadPaddingException e) { +// throw BizRuntimeException.create(e.getMessage()); +// } +// } } diff --git a/mens-api/src/main/java/kr/xit/ens/support/nice/web/NiceCiController.java b/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java similarity index 85% rename from mens-api/src/main/java/kr/xit/ens/support/nice/web/NiceCiController.java rename to mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java index 6b891ad..fa45697 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/nice/web/NiceCiController.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java @@ -1,14 +1,10 @@ -package kr.xit.ens.support.nice.web; +package kr.xit.ens.nice.web; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.tags.Tag; -import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyRequest; -import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRegRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRequest; import kr.xit.core.model.ApiResponseDTO; -import kr.xit.ens.support.nice.service.INiceCiService; +import kr.xit.ens.nice.service.INiceCiService; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; @@ -20,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; * * description : * - * packageName : kr.xit.ens.support.nice.web + * packageName : kr.xit.ens.nice.web * fileName : NiceCiController * author : limju * date : 2023-09-06 @@ -34,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController; @Tag(name = "NiceCiController", description = "Nice CI API") @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/nice/v1") +@RequestMapping(value = "/api/ens/nice/v1") public class NiceCiController { private final INiceCiService service; @@ -70,9 +66,9 @@ public class NiceCiController { @Operation(summary = "공개키 요청", description = "공개키 요청") @PostMapping(value = "/requestPublickey", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestPublickey( - @RequestBody final PublickeyRequest reqDTO + //@RequestBody final PublickeyRequest reqDTO ) { - return ApiResponseDTO.success(service.requestPublickey(reqDTO)); + return ApiResponseDTO.success(service.requestPublickey()); } //-------------------------------------------------------------------------------- // 공개키(Publickey) @@ -84,9 +80,9 @@ public class NiceCiController { @Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청") @PostMapping(value = "/requestRegSymmetrickey", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestRegSymmetrickey( - @RequestBody final SymmetrickeyRegRequest reqDTO + final String requestNo ) { - return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO)); + return ApiResponseDTO.success(service.requestRegSymmetrickey()); } //-------------------------------------------------------------------------------- diff --git a/mens-api/src/main/java/kr/xit/ens/support/nice/web/NiceCiDummyTestController.java b/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiDummyTestController.java similarity index 78% rename from mens-api/src/main/java/kr/xit/ens/support/nice/web/NiceCiDummyTestController.java rename to mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiDummyTestController.java index 6041a37..b6cdc20 100644 --- a/mens-api/src/main/java/kr/xit/ens/support/nice/web/NiceCiDummyTestController.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiDummyTestController.java @@ -1,27 +1,12 @@ -package kr.xit.ens.support.nice.web; +package kr.xit.ens.nice.web; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyRequest; -import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRequest; -import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResDataBody; -import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; -import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.model.ApiResponseDTO; -import kr.xit.core.spring.annotation.TraceLogging; -import kr.xit.core.support.utils.JsonUtils; -import kr.xit.ens.support.nice.service.INiceCiService; -import kr.xit.ens.support.nice.service.NiceCiDummyTestService; -import kr.xit.ens.support.nice.service.NiceCiService; +import kr.xit.ens.nice.service.NiceCiDummyTestService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; @@ -36,7 +21,7 @@ import org.springframework.web.bind.annotation.RestController; ** description : * - * packageName : kr.xit.ens.support.nice.web + * packageName : kr.xit.ens.nice.web * fileName : NiceCiDummyTestController * author : limju * date : 2023-09-06 @@ -51,7 +36,7 @@ import org.springframework.web.bind.annotation.RestController; @Tag(name = "NiceCiDummyTestController", description = "Nice CI Dummy Test") @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/nice/test") +@RequestMapping(value = "/api/ens/nice/test") public class NiceCiDummyTestController { private final NiceCiDummyTestService service; private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); @@ -97,9 +82,9 @@ public class NiceCiDummyTestController { @Operation(summary = "공개키 요청", description = "공개키 요청") @PostMapping(value = "/requestPublickey", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestPublickey( - @RequestBody final PublickeyRequest reqDTO + //@RequestBody final PublickeyRequest reqDTO ) { - return ApiResponseDTO.success(service.requestPublickey(reqDTO)); + return ApiResponseDTO.success(service.requestPublickey()); } //-------------------------------------------------------------------------------- diff --git a/mens-api/src/main/resources/config/application-ens.yml b/mens-api/src/main/resources/config/application-ens.yml index 2431ac0..f0befdc 100644 --- a/mens-api/src/main/resources/config/application-ens.yml +++ b/mens-api/src/main/resources/config/application-ens.yml @@ -14,7 +14,6 @@ contract: kakao: bulk-max-cnt: 10 host: https://docs-gw.kakaopay.com - #host: https://dummy.restapiexample.com token: dd394da7f66211eb9cbe46e139ceffc2 uuid: CON-41ef0535f67211ebbdedd2e6ed332381 api: @@ -25,7 +24,6 @@ contract: bulksend: /v1/documents/bulk;POST bulkstatus: /v1/documents/bulk/status;POST nice: - #host: http://parking.cheonan.go.kr host: https://svc.niceapi.co.kr:22001 signgu-code: 11000 ffnlg-code: 11