|
|
|
@@ -367,7 +367,9 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
case POST:
|
|
|
|
|
// assignPostBody(dataObject, contentType, vo.getEncode(), method);
|
|
|
|
|
//assignPostBody(dataContent, contentType, vo.getEncode(), method); // jwhong commnet
|
|
|
|
|
assignPostBody(dataContent, contentType, vo.getEncode(), method, vo.getAdapterName(), auth);
|
|
|
|
|
// KJBank API 추적정보를 Header에 제공. jwhong
|
|
|
|
|
String inboundToken= assignRequestKJHeaders(method, prop, tempProp );
|
|
|
|
|
assignPostBody(dataContent, contentType, vo.getEncode(), method, vo.getAdapterName(), auth, inboundToken);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
@@ -385,7 +387,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
assignRequestHeaders(method, httpHeader);
|
|
|
|
|
|
|
|
|
|
// KJBank API 추적정보를 Header에 제공. jwhong
|
|
|
|
|
assignRequestKJHeaders(method, prop, tempProp );
|
|
|
|
|
//assignRequestKJHeaders(method, prop, tempProp );
|
|
|
|
|
|
|
|
|
|
int status = -1;
|
|
|
|
|
|
|
|
|
@@ -799,26 +801,48 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* KJBank Target System으로 요청 보낼때 header에 clientId(업체정보), APIM거래추적자(UUID), 최초 요청시간 을 보낸다. jwhong
|
|
|
|
|
* KJBank Target System으로 요청 보낼때 header에 clientId(업체정보), APIM거래추적자(UUID), 최초 요청시간, guid 추가해서 보낸다. jwhong
|
|
|
|
|
*/
|
|
|
|
|
private void assignRequestKJHeaders(HttpUriRequestBase method, Properties prop, Properties tempProp) {
|
|
|
|
|
private String assignRequestKJHeaders(HttpUriRequestBase method, Properties prop, Properties tempProp){
|
|
|
|
|
|
|
|
|
|
//weblogic 에서는 tempProp.get 이 property로 return 해어 아래처럼 수정함. ClassCastException 발생함.
|
|
|
|
|
//Properties inboundHeaders = (Properties) tempProp.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
|
|
|
|
Properties inboundHeaders = null;
|
|
|
|
|
String authorization ="";
|
|
|
|
|
try {
|
|
|
|
|
Object headerObj = tempProp.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
|
|
|
|
if (headerObj instanceof Properties) { //tomcat
|
|
|
|
|
inboundHeaders = (Properties) headerObj;
|
|
|
|
|
for ( String k : inboundHeaders.stringPropertyNames()) {
|
|
|
|
|
if(k.equalsIgnoreCase("authorization")) {
|
|
|
|
|
authorization = inboundHeaders.getProperty(k);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (headerObj instanceof String) { //weblogic
|
|
|
|
|
inboundHeaders = new Properties();
|
|
|
|
|
inboundHeaders.load(new StringReader((String) headerObj));
|
|
|
|
|
String str = (String) headerObj;
|
|
|
|
|
str = str.substring(1, str.length() - 1);
|
|
|
|
|
// 2. key=value 쌍 분리
|
|
|
|
|
String[] entries = str.split(",");
|
|
|
|
|
// map에 담기
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
for (String entry : entries) {
|
|
|
|
|
String[] kv = entry.split("=", 2);
|
|
|
|
|
if (kv.length == 2) {
|
|
|
|
|
map.put(kv[0].trim(), kv[1].trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (String k : map.keySet()) {
|
|
|
|
|
if (k.equalsIgnoreCase("authorization")) {
|
|
|
|
|
authorization = map.get(k);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String authorization = inboundHeaders.getProperty("authorization");
|
|
|
|
|
String jwtToken = "";
|
|
|
|
|
|
|
|
|
|
if (authorization != null && authorization.startsWith("Bearer ")) {
|
|
|
|
@@ -832,22 +856,20 @@ 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);
|
|
|
|
|
logger.debug(key + " = " + value);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* GUID */
|
|
|
|
|
String guid = tempProp.getProperty(TransactionContextKeys.GUID, "");
|
|
|
|
|
method.setHeader("guid", guid);
|
|
|
|
|
|
|
|
|
|
/* 최초요청시간 */
|
|
|
|
|
String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
|
|
|
|
method.setHeader("receivedTimestamp", receivedTimestamp);
|
|
|
|
|
|
|
|
|
|
return jwtToken;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth) {
|
|
|
|
|
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth, String inboundToken) {
|
|
|
|
|
if (eaiBody == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@@ -868,7 +890,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
} else {
|
|
|
|
|
ContentType contentTypeObj = ContentType.create(contentType, charset);
|
|
|
|
|
|
|
|
|
|
String eaiBodyMessage = doOutboundPreFilter(eaiBody, adapterName, niceAuth); // jwhong
|
|
|
|
|
String eaiBodyMessage = doOutboundPreFilter(eaiBody, adapterName, niceAuth, inboundToken); // jwhong
|
|
|
|
|
StringEntity entity = new StringEntity(eaiBodyMessage, contentTypeObj);
|
|
|
|
|
// 요청 본문을 StringEntity 객체로 생성
|
|
|
|
|
//StringEntity entity = new StringEntity(eaiBody.toString(), contentTypeObj);
|
|
|
|
@@ -879,27 +901,32 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// from here by jwhong
|
|
|
|
|
private String doOutboundPreFilter(Object eaiBody, String adapterName, String niceAuth) {
|
|
|
|
|
private String doOutboundPreFilter(Object eaiBody, String adapterName, String niceAuth, String inboundToken) {
|
|
|
|
|
|
|
|
|
|
Properties properties = AdapterPropManager.getInstance().getProperties(adapterName); // jwhong
|
|
|
|
|
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM",""); // jwhong
|
|
|
|
|
//String encryptBaseKeyType = properties.getProperty("ENCRYPT_BASE_TYPE");
|
|
|
|
|
String encryptBaseKeyType = properties.getProperty("ENCRYPT_BASE_TYPE");
|
|
|
|
|
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로 사용된다.
|
|
|
|
|
// outbound 알림결과는 SecretKey, NICE-auth, Token을 사용한다.
|
|
|
|
|
// 참고로 inbound encrypt 에는 Token 또는 SecretKey 가 암호화 key로 사용된다.
|
|
|
|
|
// 여기에 NICE-auth 뭔지 파악하여 logic 추가해야 한다.
|
|
|
|
|
OAuth2Manager manager = OAuth2Manager.getInstance();
|
|
|
|
|
ClientDetails clientDetail = manager.getClientDeatilsStore().get(encryptClientId);
|
|
|
|
|
String clientSecret = "";
|
|
|
|
|
if ( clientDetail != null ) { // not null 이라는 것은 APIM Oauth Server에 등록된 client ID 이다.
|
|
|
|
|
// 이건 KJBank로 Outbound 나가는 것임
|
|
|
|
|
clientSecret = clientDetail.getClientSecret();
|
|
|
|
|
} else { // 그럼 업체로 Outbound 나가는것은, 업체에서 사용하는 secretkey를 사용한다.
|
|
|
|
|
clientSecret = encryptClientId;
|
|
|
|
|
// 여기에 NICE-auth logic 추가함 .
|
|
|
|
|
String clientSecret = "";
|
|
|
|
|
if ("TOKEN".equalsIgnoreCase(encryptBaseKeyType)) {
|
|
|
|
|
clientSecret = inboundToken;
|
|
|
|
|
} else if ( "SECRETKEY".equalsIgnoreCase(encryptBaseKeyType)) {
|
|
|
|
|
OAuth2Manager manager = OAuth2Manager.getInstance();
|
|
|
|
|
ClientDetails clientDetail = manager.getClientDeatilsStore().get(encryptClientId);
|
|
|
|
|
if ( clientDetail != null ) { // not null 이라는 것은 APIM Oauth Server에 등록된 client ID 이다.
|
|
|
|
|
// 업체가 우리 OAuth 를 사용하는 경우임
|
|
|
|
|
clientSecret = clientDetail.getClientSecret();
|
|
|
|
|
} else { // 이경우는 우리 OAuth를 사용안하는 경우임, 업체에서 사용하는 secretkey를 사용한다.
|
|
|
|
|
clientSecret = encryptClientId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Nice-auth , token 값을 substring 해서 사용한다. 나이스 지키미는 adapter token에서 추출된 token을 사용한다.
|
|
|
|
@@ -910,6 +937,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
// 여기서 SECRETY인지 nice-auth 인지 check 하여 clientSecret 값을 정하는 logic 추가하여 넘겨야한다.
|
|
|
|
|
|
|
|
|
|
String responseMessage = doOutboundPreEncrypt(eaiBody, encryptAlgorithm, clientSecret, encryptAES256Iv, encryptAES256Key, certPath);
|
|
|
|
|
logger.debug("outbound pre encrypte value is :"+responseMessage);
|
|
|
|
|
return responseMessage;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -924,6 +952,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
case "AES":
|
|
|
|
|
encryptedMessage = encrypt(eaiBody.toString()); // encrypt by jwhong
|
|
|
|
|
break;
|
|
|
|
|
case "AES128":
|
|
|
|
|
case "AES128-TOSS":
|
|
|
|
|
try {
|
|
|
|
|
String key = clientSecretKey.substring(22,38);
|
|
|
|
@@ -1089,6 +1118,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
case "AES":
|
|
|
|
|
decryptedMessage = decrypt(eaiBody); // encrypt by jwhong
|
|
|
|
|
break;
|
|
|
|
|
case "AES128":
|
|
|
|
|
case "AES128-TOSS":
|
|
|
|
|
try {
|
|
|
|
|
String key128 = clientSecretKey.substring(22,38);
|
|
|
|
@@ -1199,6 +1229,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|
|
|
|
String jsonKey = "";
|
|
|
|
|
|
|
|
|
|
switch (Algorithm) {
|
|
|
|
|
case "AES128":
|
|
|
|
|
case "AES128-TOSS":
|
|
|
|
|
jsonKey = "preScreeningRequest";
|
|
|
|
|
break;
|
|
|
|
|