여러수정 20251204
This commit is contained in:
+61
-30
@@ -367,7 +367,9 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
case POST:
|
case POST:
|
||||||
// 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
|
||||||
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -385,7 +387,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
assignRequestHeaders(method, httpHeader);
|
assignRequestHeaders(method, httpHeader);
|
||||||
|
|
||||||
// KJBank API 추적정보를 Header에 제공. jwhong
|
// KJBank API 추적정보를 Header에 제공. jwhong
|
||||||
assignRequestKJHeaders(method, prop, tempProp );
|
//assignRequestKJHeaders(method, prop, tempProp );
|
||||||
|
|
||||||
int status = -1;
|
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 발생함.
|
//weblogic 에서는 tempProp.get 이 property로 return 해어 아래처럼 수정함. ClassCastException 발생함.
|
||||||
//Properties inboundHeaders = (Properties) tempProp.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
//Properties inboundHeaders = (Properties) tempProp.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
||||||
Properties inboundHeaders = null;
|
Properties inboundHeaders = null;
|
||||||
|
String authorization ="";
|
||||||
try {
|
try {
|
||||||
Object headerObj = tempProp.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
Object headerObj = tempProp.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
||||||
if (headerObj instanceof Properties) { //tomcat
|
if (headerObj instanceof Properties) { //tomcat
|
||||||
inboundHeaders = (Properties) headerObj;
|
inboundHeaders = (Properties) headerObj;
|
||||||
|
for ( String k : inboundHeaders.stringPropertyNames()) {
|
||||||
|
if(k.equalsIgnoreCase("authorization")) {
|
||||||
|
authorization = inboundHeaders.getProperty(k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (headerObj instanceof String) { //weblogic
|
} else if (headerObj instanceof String) { //weblogic
|
||||||
inboundHeaders = new Properties();
|
String str = (String) headerObj;
|
||||||
inboundHeaders.load(new StringReader((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();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
String authorization = inboundHeaders.getProperty("authorization");
|
|
||||||
String jwtToken = "";
|
String jwtToken = "";
|
||||||
|
|
||||||
if (authorization != null && authorization.startsWith("Bearer ")) {
|
if (authorization != null && authorization.startsWith("Bearer ")) {
|
||||||
@@ -832,22 +856,20 @@ 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);
|
||||||
|
|
||||||
/*
|
/* GUID */
|
||||||
Set<String> keys = tempProp.stringPropertyNames();
|
String guid = tempProp.getProperty(TransactionContextKeys.GUID, "");
|
||||||
for (String key : keys) {
|
method.setHeader("guid", guid);
|
||||||
String value = tempProp.getProperty(key);
|
|
||||||
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);
|
||||||
|
|
||||||
|
return jwtToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@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) {
|
if (eaiBody == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -868,7 +890,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); // jwhong
|
String eaiBodyMessage = doOutboundPreFilter(eaiBody, adapterName, niceAuth, inboundToken); // 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);
|
||||||
@@ -879,27 +901,32 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// from here by jwhong
|
// 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
|
Properties properties = AdapterPropManager.getInstance().getProperties(adapterName); // jwhong
|
||||||
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM",""); // 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 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");
|
String certPath = properties.getProperty("ENCRYPT_CERT_PATH");
|
||||||
|
|
||||||
// outbound encrypt 는 SecretKey 또는 NICE-auth 가 암호화 key로 사용된다.
|
// outbound encrypt 는 SecretKey 또는 NICE-auth 가 암호화 key로 사용된다.
|
||||||
|
// outbound 알림결과는 SecretKey, NICE-auth, Token을 사용한다.
|
||||||
// 참고로 inbound encrypt 에는 Token 또는 SecretKey 가 암호화 key로 사용된다.
|
// 참고로 inbound encrypt 에는 Token 또는 SecretKey 가 암호화 key로 사용된다.
|
||||||
// 여기에 NICE-auth 뭔지 파악하여 logic 추가해야 한다.
|
// 여기에 NICE-auth logic 추가함 .
|
||||||
OAuth2Manager manager = OAuth2Manager.getInstance();
|
String clientSecret = "";
|
||||||
ClientDetails clientDetail = manager.getClientDeatilsStore().get(encryptClientId);
|
if ("TOKEN".equalsIgnoreCase(encryptBaseKeyType)) {
|
||||||
String clientSecret = "";
|
clientSecret = inboundToken;
|
||||||
if ( clientDetail != null ) { // not null 이라는 것은 APIM Oauth Server에 등록된 client ID 이다.
|
} else if ( "SECRETKEY".equalsIgnoreCase(encryptBaseKeyType)) {
|
||||||
// 이건 KJBank로 Outbound 나가는 것임
|
OAuth2Manager manager = OAuth2Manager.getInstance();
|
||||||
clientSecret = clientDetail.getClientSecret();
|
ClientDetails clientDetail = manager.getClientDeatilsStore().get(encryptClientId);
|
||||||
} else { // 그럼 업체로 Outbound 나가는것은, 업체에서 사용하는 secretkey를 사용한다.
|
if ( clientDetail != null ) { // not null 이라는 것은 APIM Oauth Server에 등록된 client ID 이다.
|
||||||
clientSecret = encryptClientId;
|
// 업체가 우리 OAuth 를 사용하는 경우임
|
||||||
|
clientSecret = clientDetail.getClientSecret();
|
||||||
|
} else { // 이경우는 우리 OAuth를 사용안하는 경우임, 업체에서 사용하는 secretkey를 사용한다.
|
||||||
|
clientSecret = encryptClientId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nice-auth , token 값을 substring 해서 사용한다. 나이스 지키미는 adapter token에서 추출된 token을 사용한다.
|
// Nice-auth , token 값을 substring 해서 사용한다. 나이스 지키미는 adapter token에서 추출된 token을 사용한다.
|
||||||
@@ -910,6 +937,7 @@ 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);
|
||||||
|
logger.debug("outbound pre encrypte value is :"+responseMessage);
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -924,6 +952,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
case "AES":
|
case "AES":
|
||||||
encryptedMessage = encrypt(eaiBody.toString()); // encrypt by jwhong
|
encryptedMessage = encrypt(eaiBody.toString()); // encrypt by jwhong
|
||||||
break;
|
break;
|
||||||
|
case "AES128":
|
||||||
case "AES128-TOSS":
|
case "AES128-TOSS":
|
||||||
try {
|
try {
|
||||||
String key = clientSecretKey.substring(22,38);
|
String key = clientSecretKey.substring(22,38);
|
||||||
@@ -1089,6 +1118,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
case "AES":
|
case "AES":
|
||||||
decryptedMessage = decrypt(eaiBody); // encrypt by jwhong
|
decryptedMessage = decrypt(eaiBody); // encrypt by jwhong
|
||||||
break;
|
break;
|
||||||
|
case "AES128":
|
||||||
case "AES128-TOSS":
|
case "AES128-TOSS":
|
||||||
try {
|
try {
|
||||||
String key128 = clientSecretKey.substring(22,38);
|
String key128 = clientSecretKey.substring(22,38);
|
||||||
@@ -1199,6 +1229,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
String jsonKey = "";
|
String jsonKey = "";
|
||||||
|
|
||||||
switch (Algorithm) {
|
switch (Algorithm) {
|
||||||
|
case "AES128":
|
||||||
case "AES128-TOSS":
|
case "AES128-TOSS":
|
||||||
jsonKey = "preScreeningRequest";
|
jsonKey = "preScreeningRequest";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ public interface HttpAdapterServiceKey {
|
|||||||
static final String ENCRYPT_AES256_IV = "ENCRYPT_AES256_IV"; // jwhong
|
static final String ENCRYPT_AES256_IV = "ENCRYPT_AES256_IV"; // jwhong
|
||||||
static final String ENCRYPT_AES256_KEY = "ENCRYPT_AES256_KEY"; // jwhong
|
static final String ENCRYPT_AES256_KEY = "ENCRYPT_AES256_KEY"; // jwhong
|
||||||
static final String INBOUND_REQUESTED_TIME = "INBOUND_REQUESTED_TIME"; // jwhong
|
static final String INBOUND_REQUESTED_TIME = "INBOUND_REQUESTED_TIME"; // jwhong
|
||||||
|
static final String GUID = "GUID"; // jwhong
|
||||||
|
static final String API_SERVICE_CODE = "API_SERVICE_CODE"; // jwhong
|
||||||
|
|
||||||
//응답 처리 용 표준 전문 오브젝트
|
//응답 처리 용 표준 전문 오브젝트
|
||||||
static final String STANDARD_MESSAGE_OBJECT = "STANDARD_MESSAGE_OBJECT";
|
static final String STANDARD_MESSAGE_OBJECT = "STANDARD_MESSAGE_OBJECT";
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ public class HttpDynamicInAdapterManager implements Lifecycle {
|
|||||||
|
|
||||||
private static HttpDynamicInAdapterManager instance = new HttpDynamicInAdapterManager();
|
private static HttpDynamicInAdapterManager instance = new HttpDynamicInAdapterManager();
|
||||||
|
|
||||||
private ConcurrentHashMap<String, HttpDynamicInAdapterUri> adptUriMap = new ConcurrentHashMap<String, HttpDynamicInAdapterUri>();
|
//private ConcurrentHashMap<String, HttpDynamicInAdapterUri> adptUriMap = new ConcurrentHashMap<String, HttpDynamicInAdapterUri>();
|
||||||
|
public ConcurrentHashMap<String, HttpDynamicInAdapterUri> adptUriMap = new ConcurrentHashMap<String, HttpDynamicInAdapterUri>();
|
||||||
|
|
||||||
|
|
||||||
public static HttpDynamicInAdapterManager getInstance() {
|
public static HttpDynamicInAdapterManager getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,6 +440,7 @@ public class RESTProcess extends HTTPProcess {
|
|||||||
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_REMOTE_ADDR);
|
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_REMOTE_ADDR);
|
||||||
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_SCHEME);
|
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_SCHEME);
|
||||||
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_REQUESTED_TIME); // jwhong
|
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_REQUESTED_TIME); // jwhong
|
||||||
|
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.GUID); // jwhong
|
||||||
|
|
||||||
String svcName = getServiceId(this.reqEaiMsg);
|
String svcName = getServiceId(this.reqEaiMsg);
|
||||||
if (svcName == null) {
|
if (svcName == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user