복호화 에러메시지 추가
This commit is contained in:
@@ -346,7 +346,7 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
|
|
||||||
// jwhong decrypt
|
// jwhong decrypt
|
||||||
|
|
||||||
private String doPreDecryption(String eaiBody, Properties transactionProp, HttpServletRequest request) {
|
private String doPreDecryption(String eaiBody, Properties transactionProp, HttpServletRequest request) throws Exception {
|
||||||
String decryptAlgorithm = transactionProp.getProperty(ENCRYPT_ALGORITHM, "");
|
String decryptAlgorithm = transactionProp.getProperty(ENCRYPT_ALGORITHM, "");
|
||||||
String xElinkClientId = transactionProp.getProperty(HEADER_NAME_CLIENT_ID, ""); // 이 값이 OAuth의 client id 값이다 . http header 에 포함되어 온다. jwhong
|
String xElinkClientId = transactionProp.getProperty(HEADER_NAME_CLIENT_ID, ""); // 이 값이 OAuth의 client id 값이다 . http header 에 포함되어 온다. jwhong
|
||||||
String encryptBaseKeyType = transactionProp.getProperty(ENCRYPT_BASE_TYPE);
|
String encryptBaseKeyType = transactionProp.getProperty(ENCRYPT_BASE_TYPE);
|
||||||
@@ -381,6 +381,11 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
byte[] decryptedMessage = null;
|
byte[] decryptedMessage = null;
|
||||||
decryptedMessage = doInboundPreDecrypt(eaiBody, decryptAlgorithm,clientSecret,secretAES256Iv, secretAES256Key );
|
decryptedMessage = doInboundPreDecrypt(eaiBody, decryptAlgorithm,clientSecret,secretAES256Iv, secretAES256Key );
|
||||||
|
|
||||||
|
if (decryptedMessage == null) {
|
||||||
|
throw new Exception("[HttpClient5AdapterServiceRest] Decrypt Error : Invalid encrypted message");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String resultMessage = new String(decryptedMessage, StandardCharsets.UTF_8 );
|
String resultMessage = new String(decryptedMessage, StandardCharsets.UTF_8 );
|
||||||
return resultMessage;
|
return resultMessage;
|
||||||
//return new String(decryptedMessage, StandardCharsets.UTF_8 );
|
//return new String(decryptedMessage, StandardCharsets.UTF_8 );
|
||||||
@@ -453,25 +458,28 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private byte[] doInboundPreDecrypt(String eaiStringBody, String decryptAlgorithm, String clientSecretKey, String secretAES256Iv, String secretAES256Key) {
|
private byte[] doInboundPreDecrypt(String eaiStringBody, String decryptAlgorithm, String clientSecretKey, String secretAES256Iv, String secretAES256Key) throws Exception {
|
||||||
|
|
||||||
byte[] decryptedMessage = null;
|
byte[] decryptedMessage = null;
|
||||||
//String eaiStringBody = new String(eaiBody, StandardCharsets.UTF_8);
|
//String eaiStringBody = new String(eaiBody, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
eaiStringBody = extractBodyMsg(decryptAlgorithm, eaiStringBody);
|
eaiStringBody = extractBodyMsg(decryptAlgorithm, eaiStringBody);
|
||||||
|
|
||||||
|
if (eaiStringBody == null) {
|
||||||
|
throw new Exception("[HttpClient5AdapterServiceRest] Cannot decrypt Error : input is plain text");
|
||||||
|
}
|
||||||
|
|
||||||
//test source
|
//test source
|
||||||
//System.out.println("eaiBody 바이트 배열 길이: " + eaiBody.length);
|
logger.debug("Base64 문자열: " + eaiStringBody);
|
||||||
System.out.println("Base64 문자열: " + eaiStringBody);
|
logger.debug("Base64 문자열 길이: " + eaiStringBody.length());
|
||||||
System.out.println("Base64 문자열 길이: " + eaiStringBody.length());
|
logger.debug("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
||||||
System.out.println("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
|
||||||
|
|
||||||
// Base64 디코딩 테스트
|
// Base64 디코딩 테스트
|
||||||
try {
|
try {
|
||||||
byte[] decoded = Base64.getDecoder().decode(eaiStringBody);
|
byte[] decoded = Base64.getDecoder().decode(eaiStringBody);
|
||||||
System.out.println("디코딩 성공, 길이: " + decoded.length);
|
logger.debug("디코딩 성공, 길이: " + decoded.length);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
System.out.println("Base64 디코딩 실패: " + e.getMessage());
|
logger.debug("Base64 디코딩 실패: " + e.getMessage());
|
||||||
}
|
}
|
||||||
// end test source
|
// end test source
|
||||||
|
|
||||||
@@ -586,12 +594,12 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
try {
|
try {
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
JSONObject jsonObject = (JSONObject) parser.parse(eaiStringBody);
|
JSONObject jsonObject = (JSONObject) parser.parse(eaiStringBody);
|
||||||
decryptedBodyMessage = (String) jsonObject.get(decryptedJsonKey);
|
decryptedBodyMessage = (String) jsonObject.get(decryptedJsonKey);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("HttpClient5AdapterServiceRest] extractBodyMsg error : " + e.getMessage());
|
logger.error("HttpClient5AdapterServiceRest] extractBodyMsg error : " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return decryptedBodyMessage;
|
return decryptedBodyMessage;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -602,17 +610,16 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
//String eaiStringBody = new String(eaiBody, StandardCharsets.UTF_8);
|
//String eaiStringBody = new String(eaiBody, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//test source
|
//test source
|
||||||
//System.out.println("eaiBody 바이트 배열 길이: " + eaiBody.length);
|
logger.debug("Base64 문자열: " + eaiStringBody);
|
||||||
System.out.println("Base64 문자열: " + eaiStringBody);
|
logger.debug("Base64 문자열 길이: " + eaiStringBody.length());
|
||||||
System.out.println("Base64 문자열 길이: " + eaiStringBody.length());
|
logger.debug("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
||||||
System.out.println("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
|
||||||
|
|
||||||
// Base64 디코딩 테스트
|
// Base64 디코딩 테스트
|
||||||
try {
|
try {
|
||||||
byte[] decoded = Base64.getDecoder().decode(eaiStringBody);
|
byte[] decoded = Base64.getDecoder().decode(eaiStringBody);
|
||||||
System.out.println("디코딩 성공, 길이: " + decoded.length);
|
logger.debug("디코딩 성공, 길이: " + decoded.length);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
System.out.println("Base64 디코딩 실패: " + e.getMessage());
|
logger.debug("Base64 디코딩 실패: " + e.getMessage());
|
||||||
}
|
}
|
||||||
// end test source
|
// end test source
|
||||||
|
|
||||||
@@ -705,7 +712,7 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Token is: " + Token);
|
logger.debug("Token is: " + Token);
|
||||||
return Token;
|
return Token;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -721,7 +728,7 @@ public class ApiAdapterService extends HttpAdapterServiceSupport {
|
|||||||
tokenClientId = "";
|
tokenClientId = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Token Client ID: " + tokenClientId);
|
logger.debug("Token Client ID: " + tokenClientId);
|
||||||
return tokenClientId;
|
return tokenClientId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user