adapter객체 못찾오는 부분 수정
This commit is contained in:
+41
-15
@@ -88,6 +88,7 @@ import com.kjbank.encrypt.exchange.crypto.AES256Cipher;
|
|||||||
import com.kjbank.encrypt.exchange.crypto.AESCipher;
|
import com.kjbank.encrypt.exchange.crypto.AESCipher;
|
||||||
import com.nimbusds.jwt.SignedJWT;
|
import com.nimbusds.jwt.SignedJWT;
|
||||||
import com.kjbank.encrypt.exchange.crypto.AES256GCMCipher;
|
import com.kjbank.encrypt.exchange.crypto.AES256GCMCipher;
|
||||||
|
import com.kjbank.encrypt.exchange.crypto.ECDHESA256Cipher;
|
||||||
import com.eactive.eai.authserver.service.OAuth2Manager;
|
import com.eactive.eai.authserver.service.OAuth2Manager;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -442,7 +443,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
// 역기서 responseMessage를 decryption 해야 하나 by jwhong
|
// 역기서 responseMessage를 decryption 해야 하나 by jwhong
|
||||||
|
|
||||||
responseMessageOri = EntityUtils.toByteArray(response.getEntity());
|
responseMessageOri = EntityUtils.toByteArray(response.getEntity());
|
||||||
System.out.println("responseMessageOri 바이트 배열 길이: " + responseMessageOri.length);
|
logger.debug("[responseMessageOri 바이트 배열 길이 ]" + responseMessageOri.length);
|
||||||
|
|
||||||
responseMessage = doOutboundPostFilter(responseMessageOri, encryptAlgorithm, vo.getAdapterName(), accessToken); // jwhong
|
responseMessage = doOutboundPostFilter(responseMessageOri, encryptAlgorithm, vo.getAdapterName(), accessToken); // jwhong
|
||||||
// 여기까지
|
// 여기까지
|
||||||
@@ -738,7 +739,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
tokenClientId = "";
|
tokenClientId = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Token Client ID: " + tokenClientId);
|
logger.debug("[ NICE Token Client ID ]" + tokenClientId);
|
||||||
return tokenClientId;
|
return tokenClientId;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -822,7 +823,6 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
|
|
||||||
if (authorization != null && authorization.startsWith("Bearer ")) {
|
if (authorization != null && authorization.startsWith("Bearer ")) {
|
||||||
jwtToken = authorization.substring(7); // "Bearer " 이후의 JWT만 추출
|
jwtToken = authorization.substring(7); // "Bearer " 이후의 JWT만 추출
|
||||||
//System.out.println("JWT Token: " + jwtToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 업체정보 */
|
/* 업체정보 */
|
||||||
@@ -832,14 +832,16 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
/* APIM 거래추적자 */
|
/* APIM 거래추적자 */
|
||||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID, "");
|
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID, "");
|
||||||
method.setHeader("traceId", uuid);
|
method.setHeader("traceId", uuid);
|
||||||
|
|
||||||
/* 최초요청시간 */
|
/*
|
||||||
Set<String> keys = tempProp.stringPropertyNames();
|
Set<String> keys = tempProp.stringPropertyNames();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
String value = tempProp.getProperty(key);
|
String value = tempProp.getProperty(key);
|
||||||
System.out.println(key + " = " + value);
|
logger.debug(key + " = " + value);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 최초요청시간 */
|
||||||
String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
||||||
method.setHeader("receivedTimestamp", receivedTimestamp);
|
method.setHeader("receivedTimestamp", receivedTimestamp);
|
||||||
}
|
}
|
||||||
@@ -885,6 +887,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
String encryptClientId = properties.getProperty("ENCRYPT_CLIENT_ID");
|
String encryptClientId = properties.getProperty("ENCRYPT_CLIENT_ID");
|
||||||
String encryptAES256Iv = properties.getProperty("ENCRYPT_AES256_IV");
|
String encryptAES256Iv = properties.getProperty("ENCRYPT_AES256_IV");
|
||||||
String encryptAES256Key = properties.getProperty("ENCRYPT_AES256_KEY");
|
String encryptAES256Key = properties.getProperty("ENCRYPT_AES256_KEY");
|
||||||
|
String certPath = properties.getProperty("ENCRYPT_CERT_PATH");
|
||||||
|
|
||||||
// outbound encrypt 는 SecretKey 또는 NICE-auth 가 암호화 key로 사용된다.
|
// outbound encrypt 는 SecretKey 또는 NICE-auth 가 암호화 key로 사용된다.
|
||||||
// 참고로 inbound encrypt 에는 Token 또는 SecretKey 가 암호화 key로 사용된다.
|
// 참고로 inbound encrypt 에는 Token 또는 SecretKey 가 암호화 key로 사용된다.
|
||||||
@@ -906,11 +909,11 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
|
|
||||||
// 여기서 SECRETY인지 nice-auth 인지 check 하여 clientSecret 값을 정하는 logic 추가하여 넘겨야한다.
|
// 여기서 SECRETY인지 nice-auth 인지 check 하여 clientSecret 값을 정하는 logic 추가하여 넘겨야한다.
|
||||||
|
|
||||||
String responseMessage = doOutboundPreEncrypt(eaiBody, encryptAlgorithm, clientSecret, encryptAES256Iv, encryptAES256Key);
|
String responseMessage = doOutboundPreEncrypt(eaiBody, encryptAlgorithm, clientSecret, encryptAES256Iv, encryptAES256Key, certPath);
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
|
|
||||||
}
|
}
|
||||||
private String doOutboundPreEncrypt(Object eaiBody, String encryptAlgorithm, String clientSecretKey, String encryptAES256Iv, String encryptAES256Key ) {
|
private String doOutboundPreEncrypt(Object eaiBody, String encryptAlgorithm, String clientSecretKey, String encryptAES256Iv, String encryptAES256Key, String certPath ) {
|
||||||
|
|
||||||
String encryptedMessage = "";
|
String encryptedMessage = "";
|
||||||
String encryptedJsonKey = "";
|
String encryptedJsonKey = "";
|
||||||
@@ -985,6 +988,27 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
logger.error("HttpClientAdapterServiceRest] AES256GCM Encryption error=" + e.getMessage());
|
logger.error("HttpClientAdapterServiceRest] AES256GCM Encryption error=" + e.getMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "ECDHESA256":
|
||||||
|
try {
|
||||||
|
ECDHESA256Cipher cipher = new ECDHESA256Cipher();
|
||||||
|
|
||||||
|
encryptedMessage = cipher.encrypt(eaiBody.toString());
|
||||||
|
System.out.println("Encrypted JWE: " + encryptedMessage);
|
||||||
|
|
||||||
|
String decrypted = cipher.decrypt(encryptedMessage);
|
||||||
|
System.out.println("Decrypted Payload: " + decrypted);
|
||||||
|
|
||||||
|
//아래 인증서로 테스트
|
||||||
|
ECDHESA256Cipher cipherCert = new ECDHESA256Cipher(certPath);
|
||||||
|
encryptedMessage = cipherCert.encrypt(eaiBody.toString());
|
||||||
|
|
||||||
|
decrypted = cipherCert.decrypt(encryptedMessage);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("HttpClientAdapterServiceRest] AES256GCM Encryption error=" + e.getMessage());
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
encryptedMessage = eaiBody.toString();
|
encryptedMessage = eaiBody.toString();
|
||||||
return encryptedMessage;
|
return encryptedMessage;
|
||||||
@@ -1040,22 +1064,24 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
try {
|
try {
|
||||||
eaiStringBody = extractBodyMsg(decryptAlgorithm, eaiStringBody);
|
eaiStringBody = extractBodyMsg(decryptAlgorithm, eaiStringBody);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
System.out.println("JSON 파싱 오류 발생 : " +e.getMessage());
|
logger.debug("[JSON 파싱 오류 발생 : ]" +e.getMessage());
|
||||||
return eaiBody;
|
return eaiBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
//test source
|
//test source
|
||||||
System.out.println("eaiBody 바이트 배열 길이: " + eaiBody.length);
|
/*
|
||||||
System.out.println("Base64 문자열: " + eaiStringBody);
|
logger.debug("eaiBody 바이트 배열 길이: " + eaiBody.length);
|
||||||
System.out.println("Base64 문자열 길이: " + eaiStringBody.length());
|
logger.debug("Base64 문자열: " + eaiStringBody);
|
||||||
System.out.println("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
logger.debug("Base64 문자열 길이: " + eaiStringBody.length());
|
||||||
|
logger.debug("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
|
||||||
|
|
||||||
|
|||||||
@@ -224,4 +224,12 @@ public class STDMessageDAO extends BaseDAO {
|
|||||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICKE111"));
|
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICKE111"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// jwhong 추가
|
||||||
|
public StandardMessageInfo getSTDMsgByPath(String apiFullPath) throws DAOException {
|
||||||
|
Optional<StandardMessageInfo> optional = standardMessageInfoLoader.findByApiFullPath(apiFullPath);
|
||||||
|
return optional.orElseThrow(() -> new DAOException("해당 full path의 TSEAIHS04 에 데이터가 없습니다."));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user