From 2b6927f890cac7c2a9e8c740f7aed8bb6ea276fe Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Fri, 19 Jan 2024 13:38:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=94=EB=B3=B5=ED=98=B8=ED=99=94=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90=20=EA=B4=80=EB=A0=A8=20=EC=86=8C=EC=8A=A4/?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +++ .../java/cokr/xit/fims/EncryptionConfig.java | 43 ------------ .../xit/fims/payer/dao/PayerEncryptor.java | 66 ------------------- src/main/resources/xit-crypto.conf | 19 ++++++ 4 files changed, 29 insertions(+), 109 deletions(-) delete mode 100644 src/main/java/cokr/xit/fims/EncryptionConfig.java delete mode 100644 src/main/java/cokr/xit/fims/payer/dao/PayerEncryptor.java create mode 100644 src/main/resources/xit-crypto.conf diff --git a/pom.xml b/pom.xml index aa5d2e86..03acb64a 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,16 @@ xit-disabled-parking 23.04.01-SNAPSHOT + + org.egovframe.rte + org.egovframe.rte.fdl.crypto + 4.1.0 + + + cokr.xit.base + xit-crypto + 23.04.01-SNAPSHOT + org.mariadb.jdbc diff --git a/src/main/java/cokr/xit/fims/EncryptionConfig.java b/src/main/java/cokr/xit/fims/EncryptionConfig.java deleted file mode 100644 index 8975a08e..00000000 --- a/src/main/java/cokr/xit/fims/EncryptionConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -package cokr.xit.fims; - -import javax.annotation.Resource; - -import org.apache.ibatis.session.defaults.DefaultSqlSessionFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import cokr.xit.fims.payer.dao.PayerEncryptor; -import cokr.xit.foundation.data.ARIA; -import cokr.xit.foundation.data.paging.EncryptionSupport; - -@Configuration -public class EncryptionConfig { - @Resource(name = "sqlSession") - private DefaultSqlSessionFactory sqlSessionFactory; - - @Bean - ARIA encryptor() { - return new ARIA() - .setKey("Copyright (c) 2015 - (주)엑스아이티") - .setAlgorithm("SHA-256"); - } - - @Bean - PayerEncryptor payerEncryptor() { - PayerEncryptor bean = new PayerEncryptor(); - bean.setARIA(encryptor()); - return bean; - } - - @Bean - EncryptionSupport encryptionSupport() { - EncryptionSupport support = new EncryptionSupport(); - support.setEncryptor(encryptor()); - support.setEnabled(true); - support.setAdaptors(payerEncryptor()); - - sqlSessionFactory.getConfiguration().addInterceptor(support); - - return support; - } -} \ No newline at end of file diff --git a/src/main/java/cokr/xit/fims/payer/dao/PayerEncryptor.java b/src/main/java/cokr/xit/fims/payer/dao/PayerEncryptor.java deleted file mode 100644 index b0d25708..00000000 --- a/src/main/java/cokr/xit/fims/payer/dao/PayerEncryptor.java +++ /dev/null @@ -1,66 +0,0 @@ -package cokr.xit.fims.payer.dao; - -import java.util.Map; -import java.util.regex.Pattern; - -import cokr.xit.fims.payer.Payer; -import cokr.xit.fims.payer.PayerQuery; -import cokr.xit.foundation.data.paging.EncryptionSupport; - -public class PayerEncryptor extends EncryptionSupport.Adaptor { - private static final Pattern rtpyrNoPattern = Pattern.compile("\\d*"); - - @Override - public boolean supports(Object obj) { - return obj instanceof Map - || obj instanceof Payer - || obj instanceof PayerQuery; - } - - @Override - public boolean isEncrypted(String str) { - return !rtpyrNoPattern.matcher(str).matches(); - } - - @Override - public PayerEncryptor encrypt() { - if (obj instanceof Payer) { - Payer payer = (Payer)obj; - encrypt(payer::getRtpyrNo, payer::setRtpyrNo); - } else if (obj instanceof PayerQuery) { - PayerQuery req = (PayerQuery)obj; - encrypt(req::getRtpyrNo, req::setRtpyrNo); - } else if (obj instanceof Map) { - String key = "RTPYR_NO"; - Map map = (Map)obj; - if (map.containsKey(key)) { - encrypt( - () -> (String)map.get(key), - (v) -> map.put(key, v) - ); - } - } - return this; - } - - @Override - public PayerEncryptor decrypt() { - if (obj instanceof Payer) { - Payer payer = (Payer)obj; - decrypt(payer::getRtpyrNo, payer::setRtpyrNo); - } else if (obj instanceof PayerQuery) { - PayerQuery req = (PayerQuery)obj; - decrypt(req::getRtpyrNo, req::setRtpyrNo); - } else if (obj instanceof Map) { - String key = "RTPYR_NO"; - Map map = (Map)obj; - if (map.containsKey(key)) { - decrypt( - () -> (String)map.get(key), - (v) -> map.put(key, v) - ); - } - } - return this; - } -} \ No newline at end of file diff --git a/src/main/resources/xit-crypto.conf b/src/main/resources/xit-crypto.conf new file mode 100644 index 00000000..0e5c4cb4 --- /dev/null +++ b/src/main/resources/xit-crypto.conf @@ -0,0 +1,19 @@ +{ "enabled": true, + "cryptoDefs": [ + { "name": "aria", + "class": "cokr.xit.base.crypto.bean.ARIA", + "settings": { + "key": "Copyright (c) 2015 - (주)엑스아이티", + "algorithm": "SHA-256", + "blockSize": 1024 + } + } + ], + "targetValues": [ + { "name": "주민등록번호", + "mapKeys": ["RTPYR_NO"], + "objectProperties": ["rtpyrNo"], + "cryptoDefs": ["aria"] + } + ] +} \ No newline at end of file