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.nimbusds.jwt.SignedJWT;
|
||||
import com.kjbank.encrypt.exchange.crypto.AES256GCMCipher;
|
||||
import com.kjbank.encrypt.exchange.crypto.ECDHESA256Cipher;
|
||||
import com.eactive.eai.authserver.service.OAuth2Manager;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -442,7 +443,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
// 역기서 responseMessage를 decryption 해야 하나 by jwhong
|
||||
|
||||
responseMessageOri = EntityUtils.toByteArray(response.getEntity());
|
||||
System.out.println("responseMessageOri 바이트 배열 길이: " + responseMessageOri.length);
|
||||
logger.debug("[responseMessageOri 바이트 배열 길이 ]" + responseMessageOri.length);
|
||||
|
||||
responseMessage = doOutboundPostFilter(responseMessageOri, encryptAlgorithm, vo.getAdapterName(), accessToken); // jwhong
|
||||
// 여기까지
|
||||
@@ -738,7 +739,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
tokenClientId = "";
|
||||
}
|
||||
|
||||
System.out.println("Token Client ID: " + tokenClientId);
|
||||
logger.debug("[ NICE Token Client ID ]" + tokenClientId);
|
||||
return tokenClientId;
|
||||
|
||||
}
|
||||
@@ -822,7 +823,6 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
|
||||
if (authorization != null && authorization.startsWith("Bearer ")) {
|
||||
jwtToken = authorization.substring(7); // "Bearer " 이후의 JWT만 추출
|
||||
//System.out.println("JWT Token: " + jwtToken);
|
||||
}
|
||||
|
||||
/* 업체정보 */
|
||||
@@ -832,14 +832,16 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
/* APIM 거래추적자 */
|
||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID, "");
|
||||
method.setHeader("traceId", uuid);
|
||||
|
||||
/* 최초요청시간 */
|
||||
|
||||
/*
|
||||
Set<String> keys = tempProp.stringPropertyNames();
|
||||
for (String key : keys) {
|
||||
String value = tempProp.getProperty(key);
|
||||
System.out.println(key + " = " + value);
|
||||
logger.debug(key + " = " + value);
|
||||
}
|
||||
*/
|
||||
|
||||
/* 최초요청시간 */
|
||||
String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
||||
method.setHeader("receivedTimestamp", receivedTimestamp);
|
||||
}
|
||||
@@ -885,6 +887,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
String encryptClientId = properties.getProperty("ENCRYPT_CLIENT_ID");
|
||||
String encryptAES256Iv = properties.getProperty("ENCRYPT_AES256_IV");
|
||||
String encryptAES256Key = properties.getProperty("ENCRYPT_AES256_KEY");
|
||||
String certPath = properties.getProperty("ENCRYPT_CERT_PATH");
|
||||
|
||||
// outbound encrypt 는 SecretKey 또는 NICE-auth 가 암호화 key로 사용된다.
|
||||
// 참고로 inbound encrypt 에는 Token 또는 SecretKey 가 암호화 key로 사용된다.
|
||||
@@ -906,11 +909,11 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
|
||||
// 여기서 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;
|
||||
|
||||
}
|
||||
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 encryptedJsonKey = "";
|
||||
@@ -985,6 +988,27 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
logger.error("HttpClientAdapterServiceRest] AES256GCM Encryption error=" + e.getMessage());
|
||||
}
|
||||
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:
|
||||
encryptedMessage = eaiBody.toString();
|
||||
return encryptedMessage;
|
||||
@@ -1040,22 +1064,24 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
try {
|
||||
eaiStringBody = extractBodyMsg(decryptAlgorithm, eaiStringBody);
|
||||
} catch (ParseException e) {
|
||||
System.out.println("JSON 파싱 오류 발생 : " +e.getMessage());
|
||||
logger.debug("[JSON 파싱 오류 발생 : ]" +e.getMessage());
|
||||
return eaiBody;
|
||||
}
|
||||
|
||||
//test source
|
||||
System.out.println("eaiBody 바이트 배열 길이: " + eaiBody.length);
|
||||
System.out.println("Base64 문자열: " + eaiStringBody);
|
||||
System.out.println("Base64 문자열 길이: " + eaiStringBody.length());
|
||||
System.out.println("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
||||
/*
|
||||
logger.debug("eaiBody 바이트 배열 길이: " + eaiBody.length);
|
||||
logger.debug("Base64 문자열: " + eaiStringBody);
|
||||
logger.debug("Base64 문자열 길이: " + eaiStringBody.length());
|
||||
logger.debug("Base64 문자열 끝: " + eaiStringBody.substring(eaiStringBody.length() - 10));
|
||||
*/
|
||||
|
||||
// Base64 디코딩 테스트
|
||||
try {
|
||||
byte[] decoded = Base64.getDecoder().decode(eaiStringBody);
|
||||
System.out.println("디코딩 성공, 길이: " + decoded.length);
|
||||
logger.debug("[디코딩 성공, 길이: ]" + decoded.length);
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Base64 디코딩 실패: " + e.getMessage());
|
||||
logger.debug("[Base64 디코딩 실패: ]" + e.getMessage());
|
||||
}
|
||||
// end test source
|
||||
|
||||
|
||||
@@ -224,4 +224,12 @@ public class STDMessageDAO extends BaseDAO {
|
||||
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