클린파킹 properties.conf파일 내용 암복호화 처리 추가
parent
921a163f3e
commit
0c598051ef
@ -0,0 +1,56 @@
|
||||
package externalsystem.cleanparking;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import cokr.xit.base.crypto.bean.XitAria;
|
||||
|
||||
public class ConfUtil {
|
||||
|
||||
public static String read(String filePath) {
|
||||
|
||||
XitAria xa = new XitAria("xit-aria");
|
||||
|
||||
String ret = "";
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
|
||||
String line;
|
||||
// 파일의 각 줄을 읽어와 화면에 출력합니다.
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String decLine = xa.decrypt(line);
|
||||
ret += decLine;
|
||||
ret += "\n";
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// 파일이 존재하지 않거나 읽기 오류가 발생하면 예외를 처리합니다.
|
||||
System.err.println("파일을 읽는 중 오류가 발생했습니다: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String enc(String filePath) {
|
||||
|
||||
XitAria xa = new XitAria("xit-aria");
|
||||
|
||||
String ret = "";
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
|
||||
String line;
|
||||
// 파일의 각 줄을 읽어와 화면에 출력합니다.
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String encLine = xa.encrypt(line);
|
||||
ret += encLine;
|
||||
ret += "\n";
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// 파일이 존재하지 않거나 읽기 오류가 발생하면 예외를 처리합니다.
|
||||
System.err.println("파일을 읽는 중 오류가 발생했습니다: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package externalsystem.cleanparking.web;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import cokr.xit.foundation.web.AbstractController;
|
||||
import externalsystem.cleanparking.ConfUtil;
|
||||
@Controller
|
||||
@RequestMapping(name="클린파킹", value="/cleanparking")
|
||||
public class CpController extends AbstractController {
|
||||
|
||||
|
||||
@RequestMapping(name="설정읽기", value="/confRead")
|
||||
@ResponseBody
|
||||
public String confRead(HttpServletRequest req, @RequestBody HashMap<String, Object> map) {
|
||||
String returnStr = "";
|
||||
|
||||
|
||||
String filePath = map.get("filePath").toString();
|
||||
String dec = ConfUtil.read(filePath);
|
||||
System.out.println(dec);
|
||||
|
||||
returnStr = dec;
|
||||
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
@RequestMapping(name="설정암호화", value="/confEnc")
|
||||
@ResponseBody
|
||||
public String confEnc(HttpServletRequest req, @RequestBody HashMap<String, Object> map) {
|
||||
String returnStr = "";
|
||||
|
||||
|
||||
String filePath = map.get("filePath").toString();
|
||||
String dec = ConfUtil.enc(filePath);
|
||||
System.out.println(dec);
|
||||
|
||||
returnStr = dec;
|
||||
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
{
|
||||
"enabled": true,
|
||||
"cryptoDefs": [
|
||||
{
|
||||
"name": "xit-aria",
|
||||
"class": "cokr.xit.base.crypto.bean.XitAria",
|
||||
"settings": {
|
||||
"charset": "EUC-KR",
|
||||
"key": "Copyright (c) 2015 - (주)엑스아이티"
|
||||
}
|
||||
}
|
||||
],
|
||||
"targetValues": [
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue