diff --git a/src/main/java/nlib/restful/service/impl/DataApiRESTful.java b/src/main/java/nlib/restful/service/impl/DataApiRESTful.java index 8723c6f4..a533a791 100644 --- a/src/main/java/nlib/restful/service/impl/DataApiRESTful.java +++ b/src/main/java/nlib/restful/service/impl/DataApiRESTful.java @@ -1,168 +1,168 @@ -package nlib.restful.service.impl; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import nlib.restful.service.DataApiReqVO; -import nlib.restful.service.DataApiResVO; -import nlib.restful.service.DataApiInterface; -import nlib.util.StringUtil; - -/** - *
- * @Class Name : DataApiRESTful.java - * - * @Description : 통합자료관리시스템에 RESTful API를 통해 질의/응답을 처리한다. - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -public class DataApiRESTful implements DataApiInterface { - - private static final Logger log = LoggerFactory.getLogger(DataApiRESTful.class); - - /* DataApi 접속 서버 정보 */ - @Value("#{properties['dataapi.server.ip']}") - private String DAPI_SERVER_IP; - - @Value("#{properties['dataapi.server.port']}") - private String DAPI_SERVER_PORT; - - @Value("#{properties['dataapi.server.protocol']}") - private String DAPI_SERVER_PROTOCOL; - - - /** - * 조회 - * - * @param reqVO - * @return - */ - public DataApiResVO get(DataApiReqVO reqVO) { - - return send(reqVO, HttpMethod.GET); - } - - /** - * 등록 - * - * @param reqVO - * @return - */ - public DataApiResVO put(DataApiReqVO reqVO) { - return send(reqVO, HttpMethod.PUT); - } - - /** - * 수정 - * - * @param reqVO - * @return - */ - public DataApiResVO post(DataApiReqVO reqVO) { - return send(reqVO, HttpMethod.POST); - } - - /** - * 삭제 - * - * @param reqVO - * @return - */ - public DataApiResVO delete (DataApiReqVO reqVO) { - return send(reqVO, HttpMethod.DELETE); - } - - /** - * 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다. - * - * @param reqVO - * @param method - * @return - */ - public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) { - - DataApiResVO resVO = null; - - try { - //----------------------------------- - // 입력값 검증작업 - //----------------------------------- - resVO = DataApiInterface.checkReqCommonParams(reqVO); - if(resVO != null) return resVO; - if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다."); - - //----------------------------------- - // 폼 파라메터 생성 작업 - //----------------------------------- - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - MultiValueMap
+ * @Class Name : DataApiRESTful.java + * + * @Description : 통합자료관리시스템에 RESTful API를 통해 질의/응답을 처리한다. + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 6. 22. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 6. 22. + * @version 1.0 + * + */ +public class DataApiRESTful implements DataApiInterface { + + private static final Logger log = LoggerFactory.getLogger(DataApiRESTful.class); + + /* DataApi 접속 서버 정보 */ + @Value("#{properties['dataapi.server.ip']}") + private String DAPI_SERVER_IP; + + @Value("#{properties['dataapi.server.port']}") + private String DAPI_SERVER_PORT; + + @Value("#{properties['dataapi.server.protocol']}") + private String DAPI_SERVER_PROTOCOL; + + + /** + * 조회 + * + * @param reqVO + * @return + */ + public DataApiResVO get(DataApiReqVO reqVO) { + + return send(reqVO, HttpMethod.GET); + } + + /** + * 등록 + * + * @param reqVO + * @return + */ + public DataApiResVO put(DataApiReqVO reqVO) { + return send(reqVO, HttpMethod.PUT); + } + + /** + * 수정 + * + * @param reqVO + * @return + */ + public DataApiResVO post(DataApiReqVO reqVO) { + return send(reqVO, HttpMethod.POST); + } + + /** + * 삭제 + * + * @param reqVO + * @return + */ + public DataApiResVO delete (DataApiReqVO reqVO) { + return send(reqVO, HttpMethod.DELETE); + } + + /** + * 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다. + * + * @param reqVO + * @param method + * @return + */ + public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) { + + DataApiResVO resVO = null; + + try { + //----------------------------------- + // 입력값 검증작업 + //----------------------------------- + resVO = DataApiInterface.checkReqCommonParams(reqVO); + if(resVO != null) return resVO; + if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다."); + + //----------------------------------- + // 폼 파라메터 생성 작업 + //----------------------------------- + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + MultiValueMap
- * @Class Name : DataApiTempXml.java - * - * @Description : DataAPI의 요청에 대해서 로컬의 테스트용 XML 파일을 읽어서 응답을 처리한다. (자체 선개발 진행용) - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 7. 9. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 7. 9. - * @version 1.0 - * - */ -public class DataApiTempXml implements DataApiInterface { - - private static final Logger log = LoggerFactory.getLogger(DataApiTempXml.class); - - /* DataApi 접속 서버 정보 */ - @Value("#{properties['dataapi.temp.xml.path']}") - private String DAPI_TEMP_XML_PATH; - - - /** - * 조회 - * - * @param reqVO - * @return - */ - public DataApiResVO get(DataApiReqVO reqVO) { - - return send(reqVO, HttpMethod.GET); - } - - /** - * 등록 - * - * @param reqVO - * @return - */ - public DataApiResVO put(DataApiReqVO reqVO) { - return send(reqVO, HttpMethod.PUT); - } - - /** - * 수정 - * - * @param reqVO - * @return - */ - public DataApiResVO post(DataApiReqVO reqVO) { - return send(reqVO, HttpMethod.POST); - } - - /** - * 삭제 - * - * @param reqVO - * @return - */ - public DataApiResVO delete (DataApiReqVO reqVO) { - return send(reqVO, HttpMethod.DELETE); - } - - /** - * 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다. - * - * @param reqVO - * @param method - * @return - */ - public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) { - - DataApiResVO resVO = null; - - try { - //----------------------------------- - // 입력값 검증작업 - //----------------------------------- - resVO = DataApiInterface.checkReqCommonParams(reqVO); - if(resVO != null) return resVO; - if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다."); - - //----------------------------------- - // 폼 파라메터 생성 작업 - //----------------------------------- - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - MultiValueMap
+ * @Class Name : DataApiTempXml.java + * + * @Description : DataAPI의 요청에 대해서 로컬의 테스트용 XML 파일을 읽어서 응답을 처리한다. (자체 선개발 진행용) + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 7. 9. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 7. 9. + * @version 1.0 + * + */ +public class DataApiTempXml implements DataApiInterface { + + private static final Logger log = LoggerFactory.getLogger(DataApiTempXml.class); + + /* DataApi 접속 서버 정보 */ + @Value("#{properties['dataapi.temp.xml.path']}") + private String DAPI_TEMP_XML_PATH; + + + /** + * 조회 + * + * @param reqVO + * @return + */ + public DataApiResVO get(DataApiReqVO reqVO) { + + return send(reqVO, HttpMethod.GET); + } + + /** + * 등록 + * + * @param reqVO + * @return + */ + public DataApiResVO put(DataApiReqVO reqVO) { + return send(reqVO, HttpMethod.PUT); + } + + /** + * 수정 + * + * @param reqVO + * @return + */ + public DataApiResVO post(DataApiReqVO reqVO) { + return send(reqVO, HttpMethod.POST); + } + + /** + * 삭제 + * + * @param reqVO + * @return + */ + public DataApiResVO delete (DataApiReqVO reqVO) { + return send(reqVO, HttpMethod.DELETE); + } + + /** + * 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다. + * + * @param reqVO + * @param method + * @return + */ + public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) { + + DataApiResVO resVO = null; + + try { + //----------------------------------- + // 입력값 검증작업 + //----------------------------------- + resVO = DataApiInterface.checkReqCommonParams(reqVO); + if(resVO != null) return resVO; + if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다."); + + //----------------------------------- + // 폼 파라메터 생성 작업 + //----------------------------------- + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + MultiValueMap
- * @Class Name : SampleDataApiService.java - * - * @Description : RESTful API 호출 샘플 - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -public interface SampleDataApiService { - - public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception; - -} +package nlib.sample.service; + +import nlib.restful.service.DataApiReqVO; +import nlib.restful.service.DataApiResVO; + +/** + *
+ * @Class Name : SampleDataApiService.java + * + * @Description : RESTful API 호출 샘플 + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 6. 22. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 6. 22. + * @version 1.0 + * + */ +public interface SampleDataApiService { + + public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception; + +} diff --git a/src/main/java/nlib/sample/service/impl/SampleDataApiDAO.java b/src/main/java/nlib/sample/service/impl/SampleDataApiDAO.java index d3f48a58..43c3b769 100644 --- a/src/main/java/nlib/sample/service/impl/SampleDataApiDAO.java +++ b/src/main/java/nlib/sample/service/impl/SampleDataApiDAO.java @@ -1,47 +1,47 @@ -package nlib.sample.service.impl; - -import org.springframework.stereotype.Repository; - -import nlib.restful.DataApi; -import nlib.restful.service.DataApiReqVO; -import nlib.restful.service.DataApiResVO; - -/** - *
- * @Class Name : SampleDataApiDAO.java - * - * @Description : RESTful API 호출 샘플 - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -@Repository("sampleDataApiDAO") -public class SampleDataApiDAO extends DataApi { - - /** - * 주 자원의 URI - */ - public static final String RESOURCE_URI = "/uac/service/exports"; - - public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception { - - // URI가 다른 경우, 해당 URI 설정 - reqVO.setReqUrl(RESOURCE_URI); - - return get(reqVO); - } - -} +package nlib.sample.service.impl; + +import org.springframework.stereotype.Repository; + +import nlib.restful.DataApi; +import nlib.restful.service.DataApiReqVO; +import nlib.restful.service.DataApiResVO; + +/** + *
+ * @Class Name : SampleDataApiDAO.java + * + * @Description : RESTful API 호출 샘플 + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 6. 22. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 6. 22. + * @version 1.0 + * + */ +@Repository("sampleDataApiDAO") +public class SampleDataApiDAO extends DataApi { + + /** + * 주 자원의 URI + */ + public static final String RESOURCE_URI = "/uac/service/exports"; + + public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception { + + // URI가 다른 경우, 해당 URI 설정 + reqVO.setReqUrl(RESOURCE_URI); + + return get(reqVO); + } + +} diff --git a/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java b/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java index 10d87081..ccf9ee1a 100644 --- a/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java +++ b/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java @@ -1,44 +1,44 @@ -package nlib.sample.service.impl; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; - -import nlib.restful.service.DataApiReqVO; -import nlib.restful.service.DataApiResVO; -import nlib.sample.service.SampleDataApiService; - -/** - *
- * @Class Name : SampleDataApiServiceImpl.java - * - * @Description : RESTful API 호출 샘플 - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -@Service("sampleDataApiService") -public class SampleDataApiServiceImpl implements SampleDataApiService { - - /** SampleDataApiDAO */ - @Resource(name = "sampleDataApiDAO") - private SampleDataApiDAO sampleDataApiDAO; - - public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception { - return sampleDataApiDAO.getSampleInfo(reqVO); - } - -} +package nlib.sample.service.impl; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; + +import nlib.restful.service.DataApiReqVO; +import nlib.restful.service.DataApiResVO; +import nlib.sample.service.SampleDataApiService; + +/** + *
+ * @Class Name : SampleDataApiServiceImpl.java + * + * @Description : RESTful API 호출 샘플 + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 6. 22. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 6. 22. + * @version 1.0 + * + */ +@Service("sampleDataApiService") +public class SampleDataApiServiceImpl implements SampleDataApiService { + + /** SampleDataApiDAO */ + @Resource(name = "sampleDataApiDAO") + private SampleDataApiDAO sampleDataApiDAO; + + public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception { + return sampleDataApiDAO.getSampleInfo(reqVO); + } + +} diff --git a/src/main/java/nlib/sample/web/SampleDataApiController.java b/src/main/java/nlib/sample/web/SampleDataApiController.java index b8a9cca4..96c8fd09 100644 --- a/src/main/java/nlib/sample/web/SampleDataApiController.java +++ b/src/main/java/nlib/sample/web/SampleDataApiController.java @@ -1,85 +1,85 @@ -package nlib.sample.web; - -import java.util.Map; - -import javax.annotation.Resource; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import nlib.restful.service.DataApiReqVO; -import nlib.restful.service.DataApiResVO; -import nlib.sample.service.SampleDataApiService; - -/** - *
- * @Class Name : SampleDataApiController.java - * - * @Description : RESTful API 호출 샘플 - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -@Controller -public class SampleDataApiController { - - /** SampleDataApiService */ - @Resource(name = "sampleDataApiService") - private SampleDataApiService sampleDataApiService; - - - /* DataApi 접속 서버 정보 */ - @Value("#{properties['dataapi.server.ip']}") - private String dataapiServerIp; - - @Value("#{properties['dataapi.server.port']}") - private String dataapiServerPort; - - @Value("#{properties['dataapi.server.protocol']}") - private String dataapiServerProtocol; - - - @RequestMapping("/sample/getSampleInfoForm.do") - public String getSampleInfoForm(ModelMap model) throws Exception { - - model.addAttribute("serverProtocol", dataapiServerIp); - model.addAttribute("serverIp", dataapiServerPort); - model.addAttribute("serverPort", dataapiServerProtocol); - return "nlib/sample/getSampleInfoForm"; - } - - @RequestMapping("/sample/getSampleInfo.do") - public String getSampleInfo(@RequestParam Map
+ * @Class Name : SampleDataApiController.java + * + * @Description : RESTful API 호출 샘플 + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 6. 22. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 6. 22. + * @version 1.0 + * + */ +@Controller +public class SampleDataApiController { + + /** SampleDataApiService */ + @Resource(name = "sampleDataApiService") + private SampleDataApiService sampleDataApiService; + + + /* DataApi 접속 서버 정보 */ + @Value("#{properties['dataapi.server.ip']}") + private String dataapiServerIp; + + @Value("#{properties['dataapi.server.port']}") + private String dataapiServerPort; + + @Value("#{properties['dataapi.server.protocol']}") + private String dataapiServerProtocol; + + + @RequestMapping("/sample/getSampleInfoForm.do") + public String getSampleInfoForm(ModelMap model) throws Exception { + + model.addAttribute("serverProtocol", dataapiServerIp); + model.addAttribute("serverIp", dataapiServerPort); + model.addAttribute("serverPort", dataapiServerProtocol); + return "nlib/sample/getSampleInfoForm"; + } + + @RequestMapping("/sample/getSampleInfo.do") + public String getSampleInfo(@RequestParam Map
- * @Class Name : SampleEncoderController.java - * - * @Description : 비밀번호 등 인코딩값 조회/생성 - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 7. 8. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 7. 8. - * @version 1.0 - * - */ -@Controller -public class SampleEncoderController { - - private static final Logger log = LoggerFactory.getLogger(SampleEncoderController.class); - - /** 암호화서비스 */ - @Resource(name = "egovEnvCryptoService") - EgovEnvCryptoService cryptoService; - - @Resource(name = "egovEnvPasswordEncoderService") - EgovPasswordEncoder egovPasswordEncoder; - - - @Resource(name = "ariaCrypto") - AriaCrypto ariaCrypto; - - @Value("#{properties['dataapi.server.ip']}") - private String dataapiServerIp; - - @RequestMapping("/sample/password/getSampleEncoder.do") - public String getSampleInfoForm(ModelMap model - , @RequestParam(required=false) String hash - , @RequestParam(required=false) String plainText - , @RequestParam(required=false) String key - ) throws Exception { - - String msg = null; - String encodedText = null; - String decodedText = null; - - if(StringUtil.isEmpty(hash)) { - msg = "암호화 알고리즘을 선택하여 주시기 바랍니다."; - } else if(StringUtil.isEmpty(plainText)) { - msg = "암호화할 문자열을 입력하여 주시기 바랍니다."; - } else { - - log.debug("암호화 처리 시작 =" + plainText + "="); - - if("sha-256".equals(hash)) { - encodedText = egovPasswordEncoder.encryptPassword(plainText); - } else if("aria".equals(hash)) { - - if(StringUtil.isEmpty(key)) encodedText = ariaCrypto.encode(plainText); - else encodedText = ariaCrypto.encode(plainText, key); - - log.debug(" Aria plainText=" + plainText); - log.debug(" Aria encodedText=" + encodedText); - - if(StringUtil.isEmpty(key)) decodedText = ariaCrypto.decode(encodedText); - else decodedText = ariaCrypto.decode(encodedText, key); - - log.debug(" Aria after decoding, decodedText=" + decodedText); - } else { - msg = "암호화 알고리즘이 적합하지 않습니다."; - } - } - - model.addAttribute("msg", msg); - model.addAttribute("hash", hash); - model.addAttribute("plainText", plainText); - model.addAttribute("encodedText", encodedText); - model.addAttribute("decodedText", decodedText); - model.addAttribute("key", key); - - return "nlib/sample/getSampleEncoder"; - } - -} +package nlib.sample.web; + +import javax.annotation.Resource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import egovframework.rte.fdl.cryptography.EgovEnvCryptoService; +import egovframework.rte.fdl.cryptography.EgovPasswordEncoder; +import egovframework.rte.fdl.cryptography.impl.EgovARIACryptoServiceImpl; +import nlib.cmm.crypto.AriaCrypto; +import nlib.util.StringUtil; + +/** + *
+ * @Class Name : SampleEncoderController.java + * + * @Description : 비밀번호 등 인코딩값 조회/생성 + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 7. 8. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 7. 8. + * @version 1.0 + * + */ +@Controller +public class SampleEncoderController { + + private static final Logger log = LoggerFactory.getLogger(SampleEncoderController.class); + + /** 암호화서비스 */ + @Resource(name = "egovEnvCryptoService") + EgovEnvCryptoService cryptoService; + + @Resource(name = "egovEnvPasswordEncoderService") + EgovPasswordEncoder egovPasswordEncoder; + + + @Resource(name = "ariaCrypto") + AriaCrypto ariaCrypto; + + @Value("#{properties['dataapi.server.ip']}") + private String dataapiServerIp; + + @RequestMapping("/sample/password/getSampleEncoder.do") + public String getSampleInfoForm(ModelMap model + , @RequestParam(required=false) String hash + , @RequestParam(required=false) String plainText + , @RequestParam(required=false) String key + ) throws Exception { + + String msg = null; + String encodedText = null; + String decodedText = null; + + if(StringUtil.isEmpty(hash)) { + msg = "암호화 알고리즘을 선택하여 주시기 바랍니다."; + } else if(StringUtil.isEmpty(plainText)) { + msg = "암호화할 문자열을 입력하여 주시기 바랍니다."; + } else { + + log.debug("암호화 처리 시작 =" + plainText + "="); + + if("sha-256".equals(hash)) { + encodedText = egovPasswordEncoder.encryptPassword(plainText); + } else if("aria".equals(hash)) { + + if(StringUtil.isEmpty(key)) encodedText = ariaCrypto.encode(plainText); + else encodedText = ariaCrypto.encode(plainText, key); + + log.debug(" Aria plainText=" + plainText); + log.debug(" Aria encodedText=" + encodedText); + + if(StringUtil.isEmpty(key)) decodedText = ariaCrypto.decode(encodedText); + else decodedText = ariaCrypto.decode(encodedText, key); + + log.debug(" Aria after decoding, decodedText=" + decodedText); + } else { + msg = "암호화 알고리즘이 적합하지 않습니다."; + } + } + + model.addAttribute("msg", msg); + model.addAttribute("hash", hash); + model.addAttribute("plainText", plainText); + model.addAttribute("encodedText", encodedText); + model.addAttribute("decodedText", decodedText); + model.addAttribute("key", key); + + return "nlib/sample/getSampleEncoder"; + } + +}