diff --git a/libs/INICrypto_v4.2.10.jar b/libs/INICrypto_v4.2.10.jar new file mode 100644 index 0000000..60e7fb8 Binary files /dev/null and b/libs/INICrypto_v4.2.10.jar differ diff --git a/libs/INISAFECore_v2.2.50.jar b/libs/INISAFECore_v2.2.50.jar new file mode 100644 index 0000000..4b4fba5 Binary files /dev/null and b/libs/INISAFECore_v2.2.50.jar differ diff --git a/libs/INISAFENet_v7.2.65_NS.jar b/libs/INISAFENet_v7.2.65_NS.jar new file mode 100644 index 0000000..d4e6a63 Binary files /dev/null and b/libs/INISAFENet_v7.2.65_NS.jar differ diff --git a/libs/INISAFEPKI_v1.1.50.jar b/libs/INISAFEPKI_v1.1.50.jar new file mode 100644 index 0000000..fcb1be3 Binary files /dev/null and b/libs/INISAFEPKI_v1.1.50.jar differ diff --git a/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJDecrypt.java b/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJDecrypt.java new file mode 100644 index 0000000..aa16dc4 --- /dev/null +++ b/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJDecrypt.java @@ -0,0 +1,58 @@ +package com.eactive.eai.transformer.function.crypto; + +import java.util.Stack; + +import org.nfunk.jep.ParseException; +import org.nfunk.jep.function.PostfixMathCommand; + +import com.eactive.eai.common.property.PropManager; +import com.initech.inisafenet.KeyFixManager; + +public class IniSafeNetKJDecrypt extends PostfixMathCommand { + public IniSafeNetKJDecrypt() { + numberOfParameters = 1; + } + + public void run(Stack inStack) throws ParseException { + checkStack(inStack); + + Object param = inStack.pop(); + byte[] value = null; + + KeyFixManager keyMgr = null; + byte[] decData = null; + + PropManager propManager = PropManager.getInstance(); + String sConf = propManager.getProperty("IniSafeNet","properties.path"); + String iniSafeKey = propManager.getProperty("IniSafeNet","key.value"); + + if (param instanceof String) { + value = ((String) param).getBytes(); + } else if (param instanceof byte[]) { + value = (byte[]) param; + } else if (param instanceof Double) { + if (((Double) param).doubleValue() == Math.round(((Double) param).doubleValue())) { + value = new Long(Math.round(((Double) param).doubleValue())).toString().getBytes(); + } else { + value =((Number) param).toString().getBytes(); + } + } else if (param instanceof Number) { + value = ((Number) param).toString().getBytes(); + } else if (param == null) { + inStack.push(null); + return; + } else { + throw new ParseException("Function의 파라미터 인수가 byte[] 또는 String이 아닙니다. : " + param); + } + + try { + keyMgr = new KeyFixManager(sConf); + decData = keyMgr.decrypt(iniSafeKey, value); + inStack.push(decData); + } catch (Exception e) { + //throw new ExecutionException(e.getMessage(), parameters, e); + throw new ParseException(e.getMessage(), e); + } + } +} + diff --git a/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJEncrypt.java b/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJEncrypt.java index 17d436c..77666b3 100644 --- a/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJEncrypt.java +++ b/src/main/java/com/eactive/eai/transformer/function/crypto/IniSafeNetKJEncrypt.java @@ -1,35 +1,30 @@ package com.eactive.eai.transformer.function.crypto; -// not completed source jwhong + import java.util.Stack; import org.nfunk.jep.ParseException; import org.nfunk.jep.function.PostfixMathCommand; import com.eactive.eai.common.property.PropManager; - -import java.nio.charset.StandardCharsets; - -import com.eactive.eai.common.seed.SeedKJ; -import com.eactive.eai.common.seed.SeedCipher; -import org.apache.commons.lang3.StringUtils; -import java.util.Base64; +import com.initech.inisafenet.KeyFixManager; public class IniSafeNetKJEncrypt extends PostfixMathCommand { public IniSafeNetKJEncrypt() { - numberOfParameters = 2; + numberOfParameters = 1; } public void run(Stack inStack) throws ParseException { checkStack(inStack); - // USER FUNCTION에서 Parameter 에서 가져옴 - Object param2 = inStack.pop(); - String param2Str = String.valueOf(param2); // null 안전 처리 - String encryptKey = StringUtils.leftPad(param2Str, 16, '0'); - Object param = inStack.pop(); - byte[] value = null; + + KeyFixManager keyMgr = null; + byte[] encData = null; + + PropManager propManager = PropManager.getInstance(); + String sConf = propManager.getProperty("IniSafeNet","properties.path"); + String iniSafeKey = propManager.getProperty("IniSafeNet","key.value"); if (param instanceof String) { value = ((String) param).getBytes(); @@ -49,11 +44,11 @@ public class IniSafeNetKJEncrypt extends PostfixMathCommand { } else { throw new ParseException("Function의 파라미터 인수가 byte[] 또는 String이 아닙니다. : " + param); } - + try { - String encryptedData = SeedKJ.encrypt(new String(value, StandardCharsets.UTF_8), encryptKey); - - inStack.push(encryptedData); + keyMgr = new KeyFixManager(sConf); + encData = keyMgr.encrypt(iniSafeKey, value); + inStack.push(encData); } catch (Exception e) { //throw new ExecutionException(e.getMessage(), parameters, e); throw new ParseException(e.getMessage(), e);