재커밋
This commit is contained in:
parent
96e122971f
commit
610e6b3a96
@ -1,168 +1,168 @@
|
|||||||
package nlib.restful.service.impl;
|
package nlib.restful.service.impl;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
import nlib.restful.service.DataApiInterface;
|
import nlib.restful.service.DataApiInterface;
|
||||||
import nlib.util.StringUtil;
|
import nlib.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : DataApiRESTful.java
|
* @Class Name : DataApiRESTful.java
|
||||||
*
|
*
|
||||||
* @Description : 통합자료관리시스템에 RESTful API를 통해 질의/응답을 처리한다.
|
* @Description : 통합자료관리시스템에 RESTful API를 통해 질의/응답을 처리한다.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 6. 22.
|
* @since 2021. 6. 22.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DataApiRESTful implements DataApiInterface {
|
public class DataApiRESTful implements DataApiInterface {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(DataApiRESTful.class);
|
private static final Logger log = LoggerFactory.getLogger(DataApiRESTful.class);
|
||||||
|
|
||||||
/* DataApi 접속 서버 정보 */
|
/* DataApi 접속 서버 정보 */
|
||||||
@Value("#{properties['dataapi.server.ip']}")
|
@Value("#{properties['dataapi.server.ip']}")
|
||||||
private String DAPI_SERVER_IP;
|
private String DAPI_SERVER_IP;
|
||||||
|
|
||||||
@Value("#{properties['dataapi.server.port']}")
|
@Value("#{properties['dataapi.server.port']}")
|
||||||
private String DAPI_SERVER_PORT;
|
private String DAPI_SERVER_PORT;
|
||||||
|
|
||||||
@Value("#{properties['dataapi.server.protocol']}")
|
@Value("#{properties['dataapi.server.protocol']}")
|
||||||
private String DAPI_SERVER_PROTOCOL;
|
private String DAPI_SERVER_PROTOCOL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 조회
|
* 조회
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO get(DataApiReqVO reqVO) {
|
public DataApiResVO get(DataApiReqVO reqVO) {
|
||||||
|
|
||||||
return send(reqVO, HttpMethod.GET);
|
return send(reqVO, HttpMethod.GET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 등록
|
* 등록
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO put(DataApiReqVO reqVO) {
|
public DataApiResVO put(DataApiReqVO reqVO) {
|
||||||
return send(reqVO, HttpMethod.PUT);
|
return send(reqVO, HttpMethod.PUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 수정
|
* 수정
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO post(DataApiReqVO reqVO) {
|
public DataApiResVO post(DataApiReqVO reqVO) {
|
||||||
return send(reqVO, HttpMethod.POST);
|
return send(reqVO, HttpMethod.POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 삭제
|
* 삭제
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO delete (DataApiReqVO reqVO) {
|
public DataApiResVO delete (DataApiReqVO reqVO) {
|
||||||
return send(reqVO, HttpMethod.DELETE);
|
return send(reqVO, HttpMethod.DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @param method
|
* @param method
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
|
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
|
||||||
|
|
||||||
DataApiResVO resVO = null;
|
DataApiResVO resVO = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 입력값 검증작업
|
// 입력값 검증작업
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
resVO = DataApiInterface.checkReqCommonParams(reqVO);
|
resVO = DataApiInterface.checkReqCommonParams(reqVO);
|
||||||
if(resVO != null) return resVO;
|
if(resVO != null) return resVO;
|
||||||
if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
|
if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 폼 파라메터 생성 작업
|
// 폼 파라메터 생성 작업
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
MultiValueMap<String, String> parameters = DataApiInterface.makeParamMap(reqVO);
|
MultiValueMap<String, String> parameters = DataApiInterface.makeParamMap(reqVO);
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 요청 처리
|
// 요청 처리
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
String url = DAPI_SERVER_PROTOCOL + "://" + DAPI_SERVER_IP + ("80".equals(DAPI_SERVER_PORT) ? "" : ":" + DAPI_SERVER_PORT) + reqVO.getReqUrl();
|
String url = DAPI_SERVER_PROTOCOL + "://" + DAPI_SERVER_IP + ("80".equals(DAPI_SERVER_PORT) ? "" : ":" + DAPI_SERVER_PORT) + reqVO.getReqUrl();
|
||||||
log.debug("REQ URL : " + reqVO.getReqUrl());
|
log.debug("REQ URL : " + reqVO.getReqUrl());
|
||||||
|
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, method, requestEntity, String.class);
|
ResponseEntity<String> responseEntity = restTemplate.exchange(url, method, requestEntity, String.class);
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 응답 처리
|
// 응답 처리
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
HttpStatus statusCode = responseEntity.getStatusCode();
|
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||||
log.debug("RES StatusCode : " + statusCode);
|
log.debug("RES StatusCode : " + statusCode);
|
||||||
String resultXML = "";
|
String resultXML = "";
|
||||||
resultXML = responseEntity.getBody();
|
resultXML = responseEntity.getBody();
|
||||||
log.debug("RES resultXML : " + resultXML);
|
log.debug("RES resultXML : " + resultXML);
|
||||||
|
|
||||||
// 응답 자료 객체화
|
// 응답 자료 객체화
|
||||||
resVO = DataApiInterface.convertXmlToResVO(resultXML);
|
resVO = DataApiInterface.convertXmlToResVO(resultXML);
|
||||||
|
|
||||||
// 처리결과 코드 확인
|
// 처리결과 코드 확인
|
||||||
if(StringUtil.isEmpty(resVO.getResultCode())) {
|
if(StringUtil.isEmpty(resVO.getResultCode())) {
|
||||||
if (statusCode == HttpStatus.OK) {
|
if (statusCode == HttpStatus.OK) {
|
||||||
resVO.setResultCode("S_HTTP_STATUS_OK");
|
resVO.setResultCode("S_HTTP_STATUS_OK");
|
||||||
resVO.setResultMessage("정상처리되었습니다.");
|
resVO.setResultMessage("정상처리되었습니다.");
|
||||||
} else {
|
} else {
|
||||||
resVO.setResultCode("E_STATUS_CODE_FAIL");
|
resVO.setResultCode("E_STATUS_CODE_FAIL");
|
||||||
resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
|
resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.debug("RES resVO : " + resVO);
|
//log.debug("RES resVO : " + resVO);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return DataApiInterface.makeErrorRes("E_REQ_EXCEPTION", e.toString());
|
return DataApiInterface.makeErrorRes("E_REQ_EXCEPTION", e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return resVO;
|
return resVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,216 +1,216 @@
|
|||||||
package nlib.restful.service.impl;
|
package nlib.restful.service.impl;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||||
|
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
import nlib.restful.service.DataApiServerResponseVO;
|
import nlib.restful.service.DataApiServerResponseVO;
|
||||||
import nlib.restful.service.DataApiInterface;
|
import nlib.restful.service.DataApiInterface;
|
||||||
import nlib.util.StringUtil;
|
import nlib.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : DataApiTempXml.java
|
* @Class Name : DataApiTempXml.java
|
||||||
*
|
*
|
||||||
* @Description : DataAPI의 요청에 대해서 로컬의 테스트용 XML 파일을 읽어서 응답을 처리한다. (자체 선개발 진행용)
|
* @Description : DataAPI의 요청에 대해서 로컬의 테스트용 XML 파일을 읽어서 응답을 처리한다. (자체 선개발 진행용)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 7. 9. KNKIM 최초 생성
|
* @ 2021. 7. 9. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 7. 9.
|
* @since 2021. 7. 9.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DataApiTempXml implements DataApiInterface {
|
public class DataApiTempXml implements DataApiInterface {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(DataApiTempXml.class);
|
private static final Logger log = LoggerFactory.getLogger(DataApiTempXml.class);
|
||||||
|
|
||||||
/* DataApi 접속 서버 정보 */
|
/* DataApi 접속 서버 정보 */
|
||||||
@Value("#{properties['dataapi.temp.xml.path']}")
|
@Value("#{properties['dataapi.temp.xml.path']}")
|
||||||
private String DAPI_TEMP_XML_PATH;
|
private String DAPI_TEMP_XML_PATH;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 조회
|
* 조회
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO get(DataApiReqVO reqVO) {
|
public DataApiResVO get(DataApiReqVO reqVO) {
|
||||||
|
|
||||||
return send(reqVO, HttpMethod.GET);
|
return send(reqVO, HttpMethod.GET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 등록
|
* 등록
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO put(DataApiReqVO reqVO) {
|
public DataApiResVO put(DataApiReqVO reqVO) {
|
||||||
return send(reqVO, HttpMethod.PUT);
|
return send(reqVO, HttpMethod.PUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 수정
|
* 수정
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO post(DataApiReqVO reqVO) {
|
public DataApiResVO post(DataApiReqVO reqVO) {
|
||||||
return send(reqVO, HttpMethod.POST);
|
return send(reqVO, HttpMethod.POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 삭제
|
* 삭제
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO delete (DataApiReqVO reqVO) {
|
public DataApiResVO delete (DataApiReqVO reqVO) {
|
||||||
return send(reqVO, HttpMethod.DELETE);
|
return send(reqVO, HttpMethod.DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @param method
|
* @param method
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
|
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
|
||||||
|
|
||||||
DataApiResVO resVO = null;
|
DataApiResVO resVO = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 입력값 검증작업
|
// 입력값 검증작업
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
resVO = DataApiInterface.checkReqCommonParams(reqVO);
|
resVO = DataApiInterface.checkReqCommonParams(reqVO);
|
||||||
if(resVO != null) return resVO;
|
if(resVO != null) return resVO;
|
||||||
if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
|
if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 폼 파라메터 생성 작업
|
// 폼 파라메터 생성 작업
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
MultiValueMap<String, String> parameters = DataApiInterface.makeParamMap(reqVO);
|
MultiValueMap<String, String> parameters = DataApiInterface.makeParamMap(reqVO);
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// 응답 처리
|
// 응답 처리
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
HttpStatus statusCode = HttpStatus.OK;
|
HttpStatus statusCode = HttpStatus.OK;
|
||||||
String resultXML = getTempDataFromXmlFile(reqVO, method);
|
String resultXML = getTempDataFromXmlFile(reqVO, method);
|
||||||
log.debug("RES resultXML : " + resultXML);
|
log.debug("RES resultXML : " + resultXML);
|
||||||
|
|
||||||
// 응답 자료 객체화
|
// 응답 자료 객체화
|
||||||
resVO = DataApiInterface.convertXmlToResVO(resultXML);
|
resVO = DataApiInterface.convertXmlToResVO(resultXML);
|
||||||
|
|
||||||
// 처리결과 코드 확인
|
// 처리결과 코드 확인
|
||||||
if(StringUtil.isEmpty(resVO.getResultCode())) {
|
if(StringUtil.isEmpty(resVO.getResultCode())) {
|
||||||
if (statusCode == HttpStatus.OK) {
|
if (statusCode == HttpStatus.OK) {
|
||||||
resVO.setResultCode("S_HTTP_STATUS_OK");
|
resVO.setResultCode("S_HTTP_STATUS_OK");
|
||||||
resVO.setResultMessage("정상처리되었습니다.");
|
resVO.setResultMessage("정상처리되었습니다.");
|
||||||
} else {
|
} else {
|
||||||
resVO.setResultCode("E_STATUS_CODE_FAIL");
|
resVO.setResultCode("E_STATUS_CODE_FAIL");
|
||||||
resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
|
resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.debug("RES resVO : " + resVO);
|
//log.debug("RES resVO : " + resVO);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return DataApiInterface.makeErrorRes("E_REQ_EXCEPTION", e.toString());
|
return DataApiInterface.makeErrorRes("E_REQ_EXCEPTION", e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return resVO;
|
return resVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 요청 URI와 메소드를 기반으로 임시 응답 XML 파일을 찾아서 내용을 문자열로 리턴한다.
|
* 요청 URI와 메소드를 기반으로 임시 응답 XML 파일을 찾아서 내용을 문자열로 리턴한다.
|
||||||
*
|
*
|
||||||
* @param reqVO
|
* @param reqVO
|
||||||
* @param method
|
* @param method
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private String getTempDataFromXmlFile(DataApiReqVO reqVO, HttpMethod method) throws Exception {
|
private String getTempDataFromXmlFile(DataApiReqVO reqVO, HttpMethod method) throws Exception {
|
||||||
|
|
||||||
String fileName = reqVO.getReqUrl().substring(1).replaceAll("/", ".");
|
String fileName = reqVO.getReqUrl().substring(1).replaceAll("/", ".");
|
||||||
String xmlPath = DAPI_TEMP_XML_PATH + "/" + fileName + "_" + method.toString().toUpperCase() + ".xml";
|
String xmlPath = DAPI_TEMP_XML_PATH + "/" + fileName + "_" + method.toString().toUpperCase() + ".xml";
|
||||||
String returnXmlStr = null;
|
String returnXmlStr = null;
|
||||||
|
|
||||||
log.info("XML FILE PATH : " + xmlPath);
|
log.info("XML FILE PATH : " + xmlPath);
|
||||||
|
|
||||||
|
|
||||||
DataApiServerResponseVO resVO = null;
|
DataApiServerResponseVO resVO = null;
|
||||||
|
|
||||||
File xmlFile = new File(xmlPath);
|
File xmlFile = new File(xmlPath);
|
||||||
if(!xmlFile.exists()) {
|
if(!xmlFile.exists()) {
|
||||||
resVO = new DataApiServerResponseVO("-20", String.format("%s 파일을 찾을 수 없습니다.",xmlPath));
|
resVO = new DataApiServerResponseVO("-20", String.format("%s 파일을 찾을 수 없습니다.",xmlPath));
|
||||||
XmlMapper mapper = new XmlMapper();
|
XmlMapper mapper = new XmlMapper();
|
||||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resVO == null && !xmlFile.isFile()) {
|
if(resVO == null && !xmlFile.isFile()) {
|
||||||
resVO = new DataApiServerResponseVO("-21", String.format("%s는 파일이어야 합니다.",xmlPath));
|
resVO = new DataApiServerResponseVO("-21", String.format("%s는 파일이어야 합니다.",xmlPath));
|
||||||
XmlMapper mapper = new XmlMapper();
|
XmlMapper mapper = new XmlMapper();
|
||||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resVO == null) {
|
if(resVO == null) {
|
||||||
StringBuilder strBd = new StringBuilder();
|
StringBuilder strBd = new StringBuilder();
|
||||||
|
|
||||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath),StandardCharsets.UTF_8))) {
|
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath),StandardCharsets.UTF_8))) {
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
strBd.append(line + "\n");
|
strBd.append(line + "\n");
|
||||||
}
|
}
|
||||||
returnXmlStr = strBd.toString();
|
returnXmlStr = strBd.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("XML 파일 읽는 중 오류 발생 : " + e.toString());
|
log.error("XML 파일 읽는 중 오류 발생 : " + e.toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
resVO = new DataApiServerResponseVO("-22", String.format("%s 파일을 읽는 중 오류가 발생하였습니다(%s). ",xmlPath, e.toString()));
|
resVO = new DataApiServerResponseVO("-22", String.format("%s 파일을 읽는 중 오류가 발생하였습니다(%s). ",xmlPath, e.toString()));
|
||||||
XmlMapper mapper = new XmlMapper();
|
XmlMapper mapper = new XmlMapper();
|
||||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("RESUTN XML STR : " + returnXmlStr);
|
log.info("RESUTN XML STR : " + returnXmlStr);
|
||||||
return returnXmlStr;
|
return returnXmlStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
package nlib.sample.service;
|
package nlib.sample.service;
|
||||||
|
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : SampleDataApiService.java
|
* @Class Name : SampleDataApiService.java
|
||||||
*
|
*
|
||||||
* @Description : RESTful API 호출 샘플
|
* @Description : RESTful API 호출 샘플
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 6. 22.
|
* @since 2021. 6. 22.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SampleDataApiService {
|
public interface SampleDataApiService {
|
||||||
|
|
||||||
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception;
|
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,47 +1,47 @@
|
|||||||
package nlib.sample.service.impl;
|
package nlib.sample.service.impl;
|
||||||
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import nlib.restful.DataApi;
|
import nlib.restful.DataApi;
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : SampleDataApiDAO.java
|
* @Class Name : SampleDataApiDAO.java
|
||||||
*
|
*
|
||||||
* @Description : RESTful API 호출 샘플
|
* @Description : RESTful API 호출 샘플
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 6. 22.
|
* @since 2021. 6. 22.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Repository("sampleDataApiDAO")
|
@Repository("sampleDataApiDAO")
|
||||||
public class SampleDataApiDAO extends DataApi {
|
public class SampleDataApiDAO extends DataApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 주 자원의 URI
|
* 주 자원의 URI
|
||||||
*/
|
*/
|
||||||
public static final String RESOURCE_URI = "/uac/service/exports";
|
public static final String RESOURCE_URI = "/uac/service/exports";
|
||||||
|
|
||||||
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception {
|
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception {
|
||||||
|
|
||||||
// URI가 다른 경우, 해당 URI 설정
|
// URI가 다른 경우, 해당 URI 설정
|
||||||
reqVO.setReqUrl(RESOURCE_URI);
|
reqVO.setReqUrl(RESOURCE_URI);
|
||||||
|
|
||||||
return get(reqVO);
|
return get(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,44 +1,44 @@
|
|||||||
package nlib.sample.service.impl;
|
package nlib.sample.service.impl;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
import nlib.sample.service.SampleDataApiService;
|
import nlib.sample.service.SampleDataApiService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : SampleDataApiServiceImpl.java
|
* @Class Name : SampleDataApiServiceImpl.java
|
||||||
*
|
*
|
||||||
* @Description : RESTful API 호출 샘플
|
* @Description : RESTful API 호출 샘플
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 6. 22.
|
* @since 2021. 6. 22.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Service("sampleDataApiService")
|
@Service("sampleDataApiService")
|
||||||
public class SampleDataApiServiceImpl implements SampleDataApiService {
|
public class SampleDataApiServiceImpl implements SampleDataApiService {
|
||||||
|
|
||||||
/** SampleDataApiDAO */
|
/** SampleDataApiDAO */
|
||||||
@Resource(name = "sampleDataApiDAO")
|
@Resource(name = "sampleDataApiDAO")
|
||||||
private SampleDataApiDAO sampleDataApiDAO;
|
private SampleDataApiDAO sampleDataApiDAO;
|
||||||
|
|
||||||
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception {
|
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception {
|
||||||
return sampleDataApiDAO.getSampleInfo(reqVO);
|
return sampleDataApiDAO.getSampleInfo(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,85 +1,85 @@
|
|||||||
package nlib.sample.web;
|
package nlib.sample.web;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
import nlib.sample.service.SampleDataApiService;
|
import nlib.sample.service.SampleDataApiService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : SampleDataApiController.java
|
* @Class Name : SampleDataApiController.java
|
||||||
*
|
*
|
||||||
* @Description : RESTful API 호출 샘플
|
* @Description : RESTful API 호출 샘플
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 6. 22.
|
* @since 2021. 6. 22.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleDataApiController {
|
public class SampleDataApiController {
|
||||||
|
|
||||||
/** SampleDataApiService */
|
/** SampleDataApiService */
|
||||||
@Resource(name = "sampleDataApiService")
|
@Resource(name = "sampleDataApiService")
|
||||||
private SampleDataApiService sampleDataApiService;
|
private SampleDataApiService sampleDataApiService;
|
||||||
|
|
||||||
|
|
||||||
/* DataApi 접속 서버 정보 */
|
/* DataApi 접속 서버 정보 */
|
||||||
@Value("#{properties['dataapi.server.ip']}")
|
@Value("#{properties['dataapi.server.ip']}")
|
||||||
private String dataapiServerIp;
|
private String dataapiServerIp;
|
||||||
|
|
||||||
@Value("#{properties['dataapi.server.port']}")
|
@Value("#{properties['dataapi.server.port']}")
|
||||||
private String dataapiServerPort;
|
private String dataapiServerPort;
|
||||||
|
|
||||||
@Value("#{properties['dataapi.server.protocol']}")
|
@Value("#{properties['dataapi.server.protocol']}")
|
||||||
private String dataapiServerProtocol;
|
private String dataapiServerProtocol;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/sample/getSampleInfoForm.do")
|
@RequestMapping("/sample/getSampleInfoForm.do")
|
||||||
public String getSampleInfoForm(ModelMap model) throws Exception {
|
public String getSampleInfoForm(ModelMap model) throws Exception {
|
||||||
|
|
||||||
model.addAttribute("serverProtocol", dataapiServerIp);
|
model.addAttribute("serverProtocol", dataapiServerIp);
|
||||||
model.addAttribute("serverIp", dataapiServerPort);
|
model.addAttribute("serverIp", dataapiServerPort);
|
||||||
model.addAttribute("serverPort", dataapiServerProtocol);
|
model.addAttribute("serverPort", dataapiServerProtocol);
|
||||||
return "nlib/sample/getSampleInfoForm";
|
return "nlib/sample/getSampleInfoForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/sample/getSampleInfo.do")
|
@RequestMapping("/sample/getSampleInfo.do")
|
||||||
public String getSampleInfo(@RequestParam Map<String, Object> commandMap, ModelMap model) throws Exception {
|
public String getSampleInfo(@RequestParam Map<String, Object> commandMap, ModelMap model) throws Exception {
|
||||||
|
|
||||||
String authKey = (String) commandMap.get("authKey");
|
String authKey = (String) commandMap.get("authKey");
|
||||||
String page = (String) commandMap.get("page");
|
String page = (String) commandMap.get("page");
|
||||||
String rows = (String) commandMap.get("rows");
|
String rows = (String) commandMap.get("rows");
|
||||||
|
|
||||||
DataApiReqVO reqVO = new DataApiReqVO();
|
DataApiReqVO reqVO = new DataApiReqVO();
|
||||||
reqVO.setAuthKey(authKey);
|
reqVO.setAuthKey(authKey);
|
||||||
reqVO.setPageNo(page);
|
reqVO.setPageNo(page);
|
||||||
reqVO.setPageRows(rows);
|
reqVO.setPageRows(rows);
|
||||||
|
|
||||||
DataApiResVO resVO = sampleDataApiService.getSampleInfo(reqVO);
|
DataApiResVO resVO = sampleDataApiService.getSampleInfo(reqVO);
|
||||||
model.addAttribute("result", resVO);
|
model.addAttribute("result", resVO);
|
||||||
|
|
||||||
return "nlib/sample/getSampleInfo";
|
return "nlib/sample/getSampleInfo";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,108 +1,108 @@
|
|||||||
package nlib.sample.web;
|
package nlib.sample.web;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import egovframework.rte.fdl.cryptography.EgovEnvCryptoService;
|
import egovframework.rte.fdl.cryptography.EgovEnvCryptoService;
|
||||||
import egovframework.rte.fdl.cryptography.EgovPasswordEncoder;
|
import egovframework.rte.fdl.cryptography.EgovPasswordEncoder;
|
||||||
import egovframework.rte.fdl.cryptography.impl.EgovARIACryptoServiceImpl;
|
import egovframework.rte.fdl.cryptography.impl.EgovARIACryptoServiceImpl;
|
||||||
import nlib.cmm.crypto.AriaCrypto;
|
import nlib.cmm.crypto.AriaCrypto;
|
||||||
import nlib.util.StringUtil;
|
import nlib.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Class Name : SampleEncoderController.java
|
* @Class Name : SampleEncoderController.java
|
||||||
*
|
*
|
||||||
* @Description : 비밀번호 등 인코딩값 조회/생성
|
* @Description : 비밀번호 등 인코딩값 조회/생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 수정일 수정자 수정내용
|
* @ 수정일 수정자 수정내용
|
||||||
* @ ------------ -------- ---------------------------
|
* @ ------------ -------- ---------------------------
|
||||||
* @ 2021. 7. 8. KNKIM 최초 생성
|
* @ 2021. 7. 8. KNKIM 최초 생성
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||||
* @since 2021. 7. 8.
|
* @since 2021. 7. 8.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleEncoderController {
|
public class SampleEncoderController {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SampleEncoderController.class);
|
private static final Logger log = LoggerFactory.getLogger(SampleEncoderController.class);
|
||||||
|
|
||||||
/** 암호화서비스 */
|
/** 암호화서비스 */
|
||||||
@Resource(name = "egovEnvCryptoService")
|
@Resource(name = "egovEnvCryptoService")
|
||||||
EgovEnvCryptoService cryptoService;
|
EgovEnvCryptoService cryptoService;
|
||||||
|
|
||||||
@Resource(name = "egovEnvPasswordEncoderService")
|
@Resource(name = "egovEnvPasswordEncoderService")
|
||||||
EgovPasswordEncoder egovPasswordEncoder;
|
EgovPasswordEncoder egovPasswordEncoder;
|
||||||
|
|
||||||
|
|
||||||
@Resource(name = "ariaCrypto")
|
@Resource(name = "ariaCrypto")
|
||||||
AriaCrypto ariaCrypto;
|
AriaCrypto ariaCrypto;
|
||||||
|
|
||||||
@Value("#{properties['dataapi.server.ip']}")
|
@Value("#{properties['dataapi.server.ip']}")
|
||||||
private String dataapiServerIp;
|
private String dataapiServerIp;
|
||||||
|
|
||||||
@RequestMapping("/sample/password/getSampleEncoder.do")
|
@RequestMapping("/sample/password/getSampleEncoder.do")
|
||||||
public String getSampleInfoForm(ModelMap model
|
public String getSampleInfoForm(ModelMap model
|
||||||
, @RequestParam(required=false) String hash
|
, @RequestParam(required=false) String hash
|
||||||
, @RequestParam(required=false) String plainText
|
, @RequestParam(required=false) String plainText
|
||||||
, @RequestParam(required=false) String key
|
, @RequestParam(required=false) String key
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
String msg = null;
|
String msg = null;
|
||||||
String encodedText = null;
|
String encodedText = null;
|
||||||
String decodedText = null;
|
String decodedText = null;
|
||||||
|
|
||||||
if(StringUtil.isEmpty(hash)) {
|
if(StringUtil.isEmpty(hash)) {
|
||||||
msg = "암호화 알고리즘을 선택하여 주시기 바랍니다.";
|
msg = "암호화 알고리즘을 선택하여 주시기 바랍니다.";
|
||||||
} else if(StringUtil.isEmpty(plainText)) {
|
} else if(StringUtil.isEmpty(plainText)) {
|
||||||
msg = "암호화할 문자열을 입력하여 주시기 바랍니다.";
|
msg = "암호화할 문자열을 입력하여 주시기 바랍니다.";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
log.debug("암호화 처리 시작 =" + plainText + "=");
|
log.debug("암호화 처리 시작 =" + plainText + "=");
|
||||||
|
|
||||||
if("sha-256".equals(hash)) {
|
if("sha-256".equals(hash)) {
|
||||||
encodedText = egovPasswordEncoder.encryptPassword(plainText);
|
encodedText = egovPasswordEncoder.encryptPassword(plainText);
|
||||||
} else if("aria".equals(hash)) {
|
} else if("aria".equals(hash)) {
|
||||||
|
|
||||||
if(StringUtil.isEmpty(key)) encodedText = ariaCrypto.encode(plainText);
|
if(StringUtil.isEmpty(key)) encodedText = ariaCrypto.encode(plainText);
|
||||||
else encodedText = ariaCrypto.encode(plainText, key);
|
else encodedText = ariaCrypto.encode(plainText, key);
|
||||||
|
|
||||||
log.debug(" Aria plainText=" + plainText);
|
log.debug(" Aria plainText=" + plainText);
|
||||||
log.debug(" Aria encodedText=" + encodedText);
|
log.debug(" Aria encodedText=" + encodedText);
|
||||||
|
|
||||||
if(StringUtil.isEmpty(key)) decodedText = ariaCrypto.decode(encodedText);
|
if(StringUtil.isEmpty(key)) decodedText = ariaCrypto.decode(encodedText);
|
||||||
else decodedText = ariaCrypto.decode(encodedText, key);
|
else decodedText = ariaCrypto.decode(encodedText, key);
|
||||||
|
|
||||||
log.debug(" Aria after decoding, decodedText=" + decodedText);
|
log.debug(" Aria after decoding, decodedText=" + decodedText);
|
||||||
} else {
|
} else {
|
||||||
msg = "암호화 알고리즘이 적합하지 않습니다.";
|
msg = "암호화 알고리즘이 적합하지 않습니다.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("msg", msg);
|
model.addAttribute("msg", msg);
|
||||||
model.addAttribute("hash", hash);
|
model.addAttribute("hash", hash);
|
||||||
model.addAttribute("plainText", plainText);
|
model.addAttribute("plainText", plainText);
|
||||||
model.addAttribute("encodedText", encodedText);
|
model.addAttribute("encodedText", encodedText);
|
||||||
model.addAttribute("decodedText", decodedText);
|
model.addAttribute("decodedText", decodedText);
|
||||||
model.addAttribute("key", key);
|
model.addAttribute("key", key);
|
||||||
|
|
||||||
return "nlib/sample/getSampleEncoder";
|
return "nlib/sample/getSampleEncoder";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user