Merge
This commit is contained in:
+39
-27
@@ -7,10 +7,12 @@ import java.net.ConnectException;
|
|||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -51,8 +53,6 @@ import org.springframework.security.oauth2.provider.ClientDetails;
|
|||||||
import org.springframework.web.util.UriComponents;
|
import org.springframework.web.util.UriComponents;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
|
||||||
import com.eactive.eai.adapter.AdapterManager;
|
|
||||||
import com.eactive.eai.adapter.AdapterPropManager;
|
import com.eactive.eai.adapter.AdapterPropManager;
|
||||||
import com.eactive.eai.adapter.http.HttpMemoryLogger;
|
import com.eactive.eai.adapter.http.HttpMemoryLogger;
|
||||||
import com.eactive.eai.adapter.http.HttpMethodType;
|
import com.eactive.eai.adapter.http.HttpMethodType;
|
||||||
@@ -60,12 +60,6 @@ import com.eactive.eai.adapter.http.client.HttpClient5AdapterServiceSupport;
|
|||||||
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
|
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
|
||||||
import com.eactive.eai.adapter.http.client.HttpClientAdapterVO;
|
import com.eactive.eai.adapter.http.client.HttpClientAdapterVO;
|
||||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.AdapterAllowIPListFilter;
|
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.ApiAuthFilter;
|
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.HttpAdapterFilter;
|
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.HttpAdapterFilterType;
|
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.IpWhiteListFilter;
|
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.JwtAuthFilter;
|
|
||||||
import com.eactive.eai.common.TransactionContextKeys;
|
import com.eactive.eai.common.TransactionContextKeys;
|
||||||
import com.eactive.eai.common.authoutbound.AccessTokenManagerByDB;
|
import com.eactive.eai.common.authoutbound.AccessTokenManagerByDB;
|
||||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||||
@@ -91,8 +85,8 @@ import com.kjbank.encrypt.exchange.crypto.AES256GCMCipher;
|
|||||||
import com.kjbank.encrypt.exchange.crypto.ECDHESA256Cipher;
|
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;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. 기능 : EAI HTTP OutBound 용 어댑터로 수동 시스템의 HTTP 웹 컴포넌트를 GET/POST 방식으로 호출할 수 있는
|
* 1. 기능 : EAI HTTP OutBound 용 어댑터로 수동 시스템의 HTTP 웹 컴포넌트를 GET/POST 방식으로 호출할 수 있는
|
||||||
@@ -303,6 +297,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
// OAuth2AccessToken check 부분을 뒤에서 여기로 위치를 옮김, 나이스지키미 암호화 KEY를 얻기 위해서. JWHONG
|
// OAuth2AccessToken check 부분을 뒤에서 여기로 위치를 옮김, 나이스지키미 암호화 KEY를 얻기 위해서. JWHONG
|
||||||
OAuth2AccessTokenVO accessToken = null;
|
OAuth2AccessTokenVO accessToken = null;
|
||||||
String auth ="";
|
String auth ="";
|
||||||
|
Date currentDate = new Date();
|
||||||
if (useAdapterToken) {
|
if (useAdapterToken) {
|
||||||
AccessTokenManagerByDB tokenManager = AccessTokenManagerByDB.getInstance();
|
AccessTokenManagerByDB tokenManager = AccessTokenManagerByDB.getInstance();
|
||||||
accessToken = (OAuth2AccessTokenVO) tokenManager.getAccessTokenVO(vo.getAdapterGroupName());
|
accessToken = (OAuth2AccessTokenVO) tokenManager.getAccessTokenVO(vo.getAdapterGroupName());
|
||||||
@@ -327,8 +322,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
if ( niceToken == null || niceToken == "") {
|
if ( niceToken == null || niceToken == "") {
|
||||||
throw new Exception("NiceOn Token is empty, TOKEN failed to be issued, TOKEN = [" + niceToken + "]");
|
throw new Exception("NiceOn Token is empty, TOKEN failed to be issued, TOKEN = [" + niceToken + "]");
|
||||||
}
|
}
|
||||||
String clientId = accessToken.getClientId(); // HttpClientAccessTokenServiceWithBase64NiceOn 서 넣어줌
|
String clientId = accessToken.getClientId(); // HttpClientAccessTokenServiceWithBase64NiceOn 서 넣어줌
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = currentDate.getTime() / 1000;
|
||||||
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
||||||
logger.debug("HttpClientAdapterServiceRest] NiceOn auth = [" + auth + "]");
|
logger.debug("HttpClientAdapterServiceRest] NiceOn auth = [" + auth + "]");
|
||||||
auth = Base64.getEncoder().encodeToString(auth.getBytes("UTF-8"));
|
auth = Base64.getEncoder().encodeToString(auth.getBytes("UTF-8"));
|
||||||
@@ -341,7 +336,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
|
|
||||||
if (logger.isDebug()) {
|
if (logger.isDebug()) {
|
||||||
logger.debug("HttpClientAdapterServiceRest] SEND (" + vo.getAdapterGroupName()
|
logger.debug("HttpClientAdapterServiceRest] SEND (" + vo.getAdapterGroupName()
|
||||||
+ ") RequestHeader [Authorization=" + method.getHeader("Authorization") + "]");
|
+ ") RequestHeader [" + method.getHeader("Authorization").getName() + ": " + method.getHeader("Authorization").getValue() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,8 +371,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
// assignPostBody(dataObject, contentType, vo.getEncode(), method);
|
// assignPostBody(dataObject, contentType, vo.getEncode(), method);
|
||||||
//assignPostBody(dataContent, contentType, vo.getEncode(), method); // jwhong commnet
|
//assignPostBody(dataContent, contentType, vo.getEncode(), method); // jwhong commnet
|
||||||
// KJBank API 추적정보를 Header에 제공. jwhong
|
// KJBank API 추적정보를 Header에 제공. jwhong
|
||||||
// String inboundToken= assignRequestKJHeaders(method, prop, tempProp ); Filter에서 처리함.
|
// String inboundToken= assignRequestKJHeaders(method, prop, tempProp );
|
||||||
assignPostBody(dataContent, contentType, vo.getEncode(), method, vo.getAdapterName(), auth, inboundToken);
|
assignPostBody(dataContent, contentType, vo.getEncode(), method, vo.getAdapterName(), auth, inboundToken, currentDate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -392,7 +387,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
|
|
||||||
// 전달 header 셋팅
|
// 전달 header 셋팅
|
||||||
// Adapter 레벨 header 보다 data로 넘어온 httpHeader를 우선 적용(header명이 같다면 덮어씀)
|
// Adapter 레벨 header 보다 data로 넘어온 httpHeader를 우선 적용(header명이 같다면 덮어씀)
|
||||||
assignRequestHeaders(method, httpHeader);
|
assignRequestHeaders(method, httpHeader);
|
||||||
|
|
||||||
// KJBank API 추적정보를 Header에 제공. jwhong
|
// KJBank API 추적정보를 Header에 제공. jwhong
|
||||||
//assignRequestKJHeaders(method, prop, tempProp );
|
//assignRequestKJHeaders(method, prop, tempProp );
|
||||||
@@ -730,7 +725,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
private void setNiceOnAuthHeaders(HttpUriRequestBase method, String auth) throws Exception {
|
private void setNiceOnAuthHeaders(HttpUriRequestBase method, String auth) throws Exception {
|
||||||
method.setHeader("Authorization",
|
method.setHeader("Authorization",
|
||||||
String.format("%s %s", AccessTokenVO.BEARER_TYPE, auth)); // 나이스지키미 format임
|
String.format("%s %s", AccessTokenVO.BEARER_TYPE, auth)); // 나이스지키미 format임
|
||||||
method.setHeader("ProductID", "2303345072");
|
String productId = PropManager.getInstance().getProperty("NiceOnProperty","productId.value");
|
||||||
|
method.setHeader("ProductID", productId);
|
||||||
//method.setHeader("Authorization",
|
//method.setHeader("Authorization",
|
||||||
// String.format("%s %s", AccessTokenVO.BEARER_TYPE, accessToken.getAccessToken()));
|
// String.format("%s %s", AccessTokenVO.BEARER_TYPE, accessToken.getAccessToken()));
|
||||||
}
|
}
|
||||||
@@ -946,7 +942,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth, String inboundToken) {
|
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth, String inboundToken, Date currentDate) {
|
||||||
if (eaiBody == null) {
|
if (eaiBody == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -967,7 +963,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
} else {
|
} else {
|
||||||
ContentType contentTypeObj = ContentType.create(contentType, charset);
|
ContentType contentTypeObj = ContentType.create(contentType, charset);
|
||||||
|
|
||||||
String eaiBodyMessage = doOutboundPreFilter(eaiBody, adapterName, niceAuth, inboundToken); // jwhong
|
String eaiBodyMessage = doOutboundPreFilter(eaiBody, adapterName, niceAuth, inboundToken, currentDate); // jwhong
|
||||||
StringEntity entity = new StringEntity(eaiBodyMessage, contentTypeObj);
|
StringEntity entity = new StringEntity(eaiBodyMessage, contentTypeObj);
|
||||||
// 요청 본문을 StringEntity 객체로 생성
|
// 요청 본문을 StringEntity 객체로 생성
|
||||||
//StringEntity entity = new StringEntity(eaiBody.toString(), contentTypeObj);
|
//StringEntity entity = new StringEntity(eaiBody.toString(), contentTypeObj);
|
||||||
@@ -978,7 +974,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// from here by jwhong
|
// from here by jwhong
|
||||||
private String doOutboundPreFilter(Object eaiBody, String adapterName, String niceAuth, String inboundToken) {
|
private String doOutboundPreFilter(Object eaiBody, String adapterName, String niceAuth, String inboundToken, Date currentDate) {
|
||||||
|
|
||||||
Properties properties = AdapterPropManager.getInstance().getProperties(adapterName); // jwhong
|
Properties properties = AdapterPropManager.getInstance().getProperties(adapterName); // jwhong
|
||||||
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM",""); // jwhong
|
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM",""); // jwhong
|
||||||
@@ -1013,12 +1009,12 @@ 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, certPath);
|
String responseMessage = doOutboundPreEncrypt(eaiBody, encryptAlgorithm, clientSecret, encryptAES256Iv, encryptAES256Key, certPath, currentDate);
|
||||||
logger.debug("outbound pre encrypte value is :"+responseMessage);
|
logger.debug("outbound pre encrypte value is :"+responseMessage);
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
|
|
||||||
}
|
}
|
||||||
private String doOutboundPreEncrypt(Object eaiBody, String encryptAlgorithm, String clientSecretKey, String encryptAES256Iv, String encryptAES256Key, String certPath ) {
|
private String doOutboundPreEncrypt(Object eaiBody, String encryptAlgorithm, String clientSecretKey, String encryptAES256Iv, String encryptAES256Key, String certPath, Date currentDate) {
|
||||||
|
|
||||||
String encryptedMessage = "";
|
String encryptedMessage = "";
|
||||||
String encryptedJsonKey = "";
|
String encryptedJsonKey = "";
|
||||||
@@ -1121,11 +1117,27 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
if (encryptAlgorithm.equals("AES256-NICEON")) {
|
||||||
map.put(encryptedJsonKey, encryptedMessage);
|
String goodsCls = PropManager.getInstance().getProperty("NiceOnProperty","goods.cls.value");
|
||||||
JSONObject json = new JSONObject();
|
Map<String, Object> map = new HashMap<>();
|
||||||
json.putAll(map);
|
SimpleDateFormat sdfDateTime =new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
return json.toJSONString();
|
map.put("req_dtm", sdfDateTime.format(currentDate));
|
||||||
|
map.put("goods_cls", goodsCls);
|
||||||
|
map.put(encryptedJsonKey, encryptedMessage);
|
||||||
|
JSONObject dataBody = new JSONObject();
|
||||||
|
dataBody.putAll(map);
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("dataBody", dataBody);
|
||||||
|
return json.toJSONString();
|
||||||
|
} else {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put(encryptedJsonKey, encryptedMessage);
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.putAll(map);
|
||||||
|
return json.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
//return encryptedMessage;
|
//return encryptedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1323,7 +1335,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
jsonKey = "encryptedData";
|
jsonKey = "encryptedData";
|
||||||
break;
|
break;
|
||||||
case "AES256-NICEON":
|
case "AES256-NICEON":
|
||||||
jsonKey = "preScreeningRequest";
|
jsonKey = "enc_data";
|
||||||
break;
|
break;
|
||||||
case "AES256GCM":
|
case "AES256GCM":
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user