Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a515d0f8b0 | |||
| b389ef2962 | |||
| c15e52d205 | |||
| 2829d4362c | |||
| 5a9225e93e | |||
| 815a064cd9 |
+22
-2
@@ -11,7 +11,9 @@ import java.security.KeyStoreException;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.UnrecoverableKeyException;
|
import java.security.UnrecoverableKeyException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -30,6 +32,7 @@ import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuil
|
|||||||
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
|
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
|
||||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
||||||
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
|
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
|
||||||
|
import org.apache.hc.core5.http.Header;
|
||||||
import org.apache.hc.core5.http.HttpRequest;
|
import org.apache.hc.core5.http.HttpRequest;
|
||||||
import org.apache.hc.core5.http.HttpRequestInterceptor;
|
import org.apache.hc.core5.http.HttpRequestInterceptor;
|
||||||
import org.apache.hc.core5.http.HttpResponseInterceptor;
|
import org.apache.hc.core5.http.HttpResponseInterceptor;
|
||||||
@@ -40,6 +43,7 @@ import com.eactive.eai.adapter.AdapterManager;
|
|||||||
import com.eactive.eai.adapter.Keys;
|
import com.eactive.eai.adapter.Keys;
|
||||||
import com.eactive.eai.adapter.http.secure.HttpClient5SSLContextFactory;
|
import com.eactive.eai.adapter.http.secure.HttpClient5SSLContextFactory;
|
||||||
import com.eactive.eai.common.TransactionContextKeys;
|
import com.eactive.eai.common.TransactionContextKeys;
|
||||||
|
import com.eactive.eai.common.logger.HttpAdapterExtraHeaderVo;
|
||||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||||
import com.eactive.eai.common.property.PropManager;
|
import com.eactive.eai.common.property.PropManager;
|
||||||
import com.eactive.eai.common.server.EAIServerManager;
|
import com.eactive.eai.common.server.EAIServerManager;
|
||||||
@@ -416,8 +420,24 @@ public abstract class HttpClient5AdapterServiceSupport implements HttpClientAdap
|
|||||||
logProcessNo = 200;
|
logProcessNo = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpAdapterExtraLogUtil.insertHttpAdapterExtraLog(uuid, logProcessNo,
|
Header[] headers = request.getHeaders();
|
||||||
contextAdapterGroupName, contextAdapterName, request.getHeaders(), url, request.getMethod());
|
List<HttpAdapterExtraHeaderVo> headerVoList = null;
|
||||||
|
if ( headers != null && headers.length != 0 ) {
|
||||||
|
headerVoList = HttpAdapterExtraLogUtil.convertHeaderToListOfHttpAdapterExtraHeaderVo(headers);
|
||||||
|
} else {
|
||||||
|
headerVoList = new ArrayList<HttpAdapterExtraHeaderVo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
String trimedPostBody = (String) context.getAttribute(HttpAdapterExtraLogUtil.BODY_FIELD_NAME);
|
||||||
|
if(StringUtils.isNotEmpty(trimedPostBody)) {
|
||||||
|
HttpAdapterExtraHeaderVo vo = new HttpAdapterExtraHeaderVo();
|
||||||
|
vo.setName(HttpAdapterExtraLogUtil.BODY_FIELD_NAME);
|
||||||
|
vo.setValue(trimedPostBody);
|
||||||
|
headerVoList.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpAdapterExtraLogUtil.insertHttpAdapterExtraLog(uuid, logProcessNo,
|
||||||
|
contextAdapterGroupName, contextAdapterName, headerVoList, url, request.getMethod(), 0);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-17
@@ -6,6 +6,7 @@ import java.math.BigDecimal;
|
|||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -65,7 +66,9 @@ import com.eactive.eai.common.exception.ExceptionUtil;
|
|||||||
import com.eactive.eai.common.message.MessageType;
|
import com.eactive.eai.common.message.MessageType;
|
||||||
import com.eactive.eai.common.property.PropManager;
|
import com.eactive.eai.common.property.PropManager;
|
||||||
import com.eactive.eai.common.util.CommonLib;
|
import com.eactive.eai.common.util.CommonLib;
|
||||||
|
import com.eactive.eai.common.util.HttpAdapterExtraLogUtil;
|
||||||
import com.eactive.eai.common.util.JacksonUtil;
|
import com.eactive.eai.common.util.JacksonUtil;
|
||||||
|
import com.eactive.eai.common.util.RestSendBodyLogUtils;
|
||||||
import com.eactive.eai.common.util.TxFileLogger;
|
import com.eactive.eai.common.util.TxFileLogger;
|
||||||
import com.eactive.eai.common.util.XMLUtils;
|
import com.eactive.eai.common.util.XMLUtils;
|
||||||
import com.eactive.eai.util.JsonPathUtil;
|
import com.eactive.eai.util.JsonPathUtil;
|
||||||
@@ -363,23 +366,12 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
configureHttpClient(requestConfigBuilder, vo, method);
|
configureHttpClient(requestConfigBuilder, vo, method);
|
||||||
assignFilterHeaders(method, tempProp); // OutBound PreFilter에서 설정한 Header내용 설정.
|
assignFilterHeaders(method, tempProp); // OutBound PreFilter에서 설정한 Header내용 설정.
|
||||||
|
|
||||||
|
String postBody = "";
|
||||||
|
|
||||||
switch (HttpMethodType.getValue(rmethod)) {
|
switch (HttpMethodType.getValue(rmethod)) {
|
||||||
case GET:
|
case GET:
|
||||||
case DELETE:
|
case DELETE:
|
||||||
HashMap<String, String> h = getParameters(dataObject);
|
assignGetParam(dataObject, uri, method);
|
||||||
URIBuilder uriBuilder = new URIBuilder(uri);
|
|
||||||
for (Map.Entry<String, String> entry : h.entrySet()) {
|
|
||||||
uriBuilder.addParameter(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
URI fullUri = uriBuilder.build();
|
|
||||||
if (method instanceof HttpGet) {
|
|
||||||
((HttpGet) method).setUri(fullUri);
|
|
||||||
} else if (method instanceof HttpDelete) {
|
|
||||||
((HttpDelete) method).setUri(fullUri);
|
|
||||||
}
|
|
||||||
if (logger.isDebug()) {
|
|
||||||
logger.debug("HttpClientAdapterServiceRest] (get Method) QueryString = [" + fullUri.getQuery() + "]");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PUT:
|
case PUT:
|
||||||
case POST:
|
case POST:
|
||||||
@@ -388,13 +380,14 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
//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 );
|
// String inboundToken= assignRequestKJHeaders(method, prop, tempProp );
|
||||||
assignPostBody(dataObject, mimeType, charset, method, chunked);
|
postBody = assignPostBody(dataObject, mimeType, charset, method, chunked);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("HttpClientAdapterServiceRest] Request URI : " + method.getRequestUri());
|
||||||
logger.debug("HttpClientAdapterServiceRest] SEND (" + vo.getAdapterGroupName() + ") method.getParams()=["
|
logger.debug("HttpClientAdapterServiceRest] SEND (" + vo.getAdapterGroupName() + ") method.getParams()=["
|
||||||
+ method.getEntity() + "] ");
|
+ method.getEntity() + "] ");
|
||||||
}
|
}
|
||||||
@@ -403,7 +396,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
|
|
||||||
// 전달 header 셋팅
|
// 전달 header 셋팅
|
||||||
// Adapter 레벨 header 보다 data로 넘어온 httpHeader를 우선 적용(header명이 같다면 덮어씀)
|
// Adapter 레벨 header 보다 data로 넘어온 httpHeader를 우선 적용(header명이 같다면 덮어씀)
|
||||||
assignRequestHeaders(method, httpHeader, prop);
|
assignRequestHeaders(method, httpHeader, prop, tempProp);
|
||||||
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
@@ -447,6 +440,11 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
context.setAttribute(HttpClientAdapterServiceKey.LOG_PROCESS_NO, logProcessNo);
|
context.setAttribute(HttpClientAdapterServiceKey.LOG_PROCESS_NO, logProcessNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (RestSendBodyLogUtils.isBodyLoggingApi(tempProp.getProperty("API_SERVICE_CODE"))) {
|
||||||
|
String trimmedBody = RestSendBodyLogUtils.getBodyByMaxSize(postBody);
|
||||||
|
context.setAttribute(HttpAdapterExtraLogUtil.BODY_FIELD_NAME, trimmedBody);
|
||||||
|
}
|
||||||
|
|
||||||
// encrypt algorithm type 추출 from adapter property jwhong
|
// encrypt algorithm type 추출 from adapter property jwhong
|
||||||
// Properties properties = AdapterPropManager.getInstance().getProperties(vo.getAdapterName()); // jwhong
|
// Properties properties = AdapterPropManager.getInstance().getProperties(vo.getAdapterName()); // jwhong
|
||||||
// String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM"); // jwhong
|
// String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM"); // jwhong
|
||||||
@@ -716,6 +714,24 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assignGetParam(Object dataObject, String uri, HttpUriRequestBase method)
|
||||||
|
throws Exception, URISyntaxException {
|
||||||
|
HashMap<String, String> h = getParameters(dataObject);
|
||||||
|
URIBuilder uriBuilder = new URIBuilder(uri);
|
||||||
|
for (Map.Entry<String, String> entry : h.entrySet()) {
|
||||||
|
uriBuilder.addParameter(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
URI fullUri = uriBuilder.build();
|
||||||
|
if (method instanceof HttpGet) {
|
||||||
|
((HttpGet) method).setUri(fullUri);
|
||||||
|
} else if (method instanceof HttpDelete) {
|
||||||
|
((HttpDelete) method).setUri(fullUri);
|
||||||
|
}
|
||||||
|
if (logger.isDebug()) {
|
||||||
|
logger.debug("HttpClientAdapterServiceRest] (get Method) QueryString = [" + fullUri.getQuery() + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void assignOutboundPropertyMap(Properties tempProp, int status, String responseString,
|
private void assignOutboundPropertyMap(Properties tempProp, int status, String responseString,
|
||||||
Properties responseHeaderProp) {
|
Properties responseHeaderProp) {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
@@ -852,6 +868,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setAuthHeaders(HttpUriRequestBase method, String authorization, String authorizationHeaderName) throws Exception {
|
protected void setAuthHeaders(HttpUriRequestBase method, String authorization, String authorizationHeaderName) throws Exception {
|
||||||
|
if(StringUtils.isEmpty(authorizationHeaderName))
|
||||||
|
authorizationHeaderName = "Authorization";
|
||||||
method.setHeader(authorizationHeaderName,
|
method.setHeader(authorizationHeaderName,
|
||||||
String.format("%s", authorization));
|
String.format("%s", authorization));
|
||||||
}
|
}
|
||||||
@@ -896,7 +914,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assignRequestHeaders(HttpUriRequestBase method, Object httpHeader, Properties prop) {
|
protected void assignRequestHeaders(HttpUriRequestBase method, Object httpHeader, Properties prop, Properties tempProp) {
|
||||||
if (httpHeader != null) {
|
if (httpHeader != null) {
|
||||||
if ( httpHeader instanceof ObjectNode) {
|
if ( httpHeader instanceof ObjectNode) {
|
||||||
ObjectNode objectNode = (ObjectNode) httpHeader;
|
ObjectNode objectNode = (ObjectNode) httpHeader;
|
||||||
|
|||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package com.eactive.eai.adapter.http.client.impl.filter;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
|
|
||||||
|
public class DebugLoggerOutFilter implements HttpClientAdapterFilter, HttpAdapterServiceKey {
|
||||||
|
protected static Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doPreFilter(String adptGrpName, String adptName, Properties prop, Object message, Properties tempProp)
|
||||||
|
throws Exception {
|
||||||
|
logger.debug("Outbound Filter SND adptGrpName : {}", adptGrpName);
|
||||||
|
logger.debug("Outbound Filter SND adptName : {}", adptName);
|
||||||
|
logger.debug("Outbound Filter SND prop : {}", prop);
|
||||||
|
logger.debug("Outbound Filter SND message : {}", message);
|
||||||
|
logger.debug("Outbound Filter SND tempProp : {}", tempProp);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doPostFilter(String adptGrpName, String adptName, Properties prop, Object message,
|
||||||
|
Properties tempProp) throws Exception {
|
||||||
|
logger.debug("Outbound Filter RCV adptGrpName : {}", adptGrpName);
|
||||||
|
logger.debug("Outbound Filter RCV adptName : {}", adptName);
|
||||||
|
logger.debug("Outbound Filter RCV prop : {}", prop);
|
||||||
|
logger.debug("Outbound Filter RCV message : {}", message);
|
||||||
|
logger.debug("Outbound Filter RCV tempProp : {}", tempProp);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-3
@@ -22,10 +22,10 @@ import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
|||||||
import com.eactive.eai.inbound.error.InboundErrorKeys;
|
import com.eactive.eai.inbound.error.InboundErrorKeys;
|
||||||
import com.eactive.eai.util.HexaConverter;
|
import com.eactive.eai.util.HexaConverter;
|
||||||
|
|
||||||
public class UnkownMessageLogUtils {
|
public class UnknownMessageLogUtils {
|
||||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||||
|
|
||||||
private UnkownMessageLogUtils() {
|
private UnknownMessageLogUtils() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class UnkownMessageLogUtils {
|
|||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append(errorMsg).append("\n").append("Remote Addr : ").append(request.getRemoteAddr()).append("\n").append("Request URI : ")
|
sb.append(errorMsg).append("\n").append("Remote Addr : ").append(request.getRemoteAddr()).append("\n").append("Request URI : ")
|
||||||
.append(request.getRequestURI()).append("\n").append("clientId=").append(clientId).append(",hexClientId=").append(hexClientId).append(",txProp=").append(prop).append("\n").append("Exception : ").append(e.getMessage());
|
.append(request.getRequestURI()).append("\n").append("clientId=").append(clientId).append(",hexClientId=").append(hexClientId).append(",txProp=").append(prop).append("\n").append("Exception : ").append(e.getMessage());
|
||||||
UnkownMessageLogUtils.logUnknownMessage(txId, adptGrpName, adptName,
|
UnknownMessageLogUtils.logUnknownMessage(txId, adptGrpName, adptName,
|
||||||
"", "", false, errCode, sb.toString(), System.currentTimeMillis(),
|
"", "", false, errCode, sb.toString(), System.currentTimeMillis(),
|
||||||
serverName, InboundErrorKeys.IN_UNKNOWN, message);
|
serverName, InboundErrorKeys.IN_UNKNOWN, message);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.eactive.eai.adapter.http.dynamic.filter;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
|
|
||||||
|
public class DebugLoggerInFilter implements HttpAdapterFilter {
|
||||||
|
protected static Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doPreFilter(String adptGrpName, String adptName, Object message, Properties prop,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
logger.debug("Inbound Filter RCV adptGrpName : {}", adptGrpName);
|
||||||
|
logger.debug("Inbound Filter RCV adptName : {}", adptName);
|
||||||
|
logger.debug("Inbound Filter RCV message : {}", message);
|
||||||
|
logger.debug("Inbound Filter RCV prop : {}", prop);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doPostFilter(String adptGrpName, String adptName, Object resultMessage, Properties prop,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
logger.debug("Inbound Filter SND adptGrpName : {}", adptGrpName);
|
||||||
|
logger.debug("Inbound Filter SND adptName : {}", adptName);
|
||||||
|
logger.debug("Inbound Filter SND resultMessage : {}", resultMessage);
|
||||||
|
logger.debug("Inbound Filter SND prop : {}", prop);
|
||||||
|
return resultMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+7
-3
@@ -31,7 +31,7 @@ import com.eactive.eai.adapter.http.HttpMemoryLogger;
|
|||||||
import com.eactive.eai.adapter.http.HttpStatusException;
|
import com.eactive.eai.adapter.http.HttpStatusException;
|
||||||
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
|
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
|
||||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceSupport;
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceSupport;
|
||||||
import com.eactive.eai.adapter.http.dynamic.UnkownMessageLogUtils;
|
import com.eactive.eai.adapter.http.dynamic.UnknownMessageLogUtils;
|
||||||
import com.eactive.eai.common.TransactionContextKeys;
|
import com.eactive.eai.common.TransactionContextKeys;
|
||||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||||
import com.eactive.eai.common.util.CommonLib;
|
import com.eactive.eai.common.util.CommonLib;
|
||||||
@@ -213,6 +213,10 @@ public class HttpAdapterServiceStandard extends HttpAdapterServiceSupport
|
|||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
|
String apiInternalErrorCode = prop.getProperty("API_INTERNAL_ERROR_CODE", "");
|
||||||
|
if(StringUtils.isNotEmpty(apiInternalErrorCode))
|
||||||
|
response.setStatus(500);
|
||||||
|
|
||||||
byte[] responseBytes = null;
|
byte[] responseBytes = null;
|
||||||
String responseData = "";
|
String responseData = "";
|
||||||
if (RESPONSE_TYPE_ASYNC.equals(responseType)){
|
if (RESPONSE_TYPE_ASYNC.equals(responseType)){
|
||||||
@@ -337,10 +341,10 @@ public class HttpAdapterServiceStandard extends HttpAdapterServiceSupport
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
UnkownMessageLogUtils.logUnkownMessage(adptGrpName, adptName, requestBytes != null ? new String(requestBytes, encode) : null, prop, request, response,
|
UnknownMessageLogUtils.logUnkownMessage(adptGrpName, adptName, requestBytes != null ? new String(requestBytes, encode) : null, prop, request, response,
|
||||||
"RECEAIIRP202", e);
|
"RECEAIIRP202", e);
|
||||||
} catch (UnsupportedEncodingException e1) {
|
} catch (UnsupportedEncodingException e1) {
|
||||||
UnkownMessageLogUtils.logUnkownMessage(adptGrpName, adptName, requestBytes != null ? new String(requestBytes) : null, prop, request, response,
|
UnknownMessageLogUtils.logUnkownMessage(adptGrpName, adptName, requestBytes != null ? new String(requestBytes) : null, prop, request, response,
|
||||||
"RECEAIIRP202", e);
|
"RECEAIIRP202", e);
|
||||||
}
|
}
|
||||||
if (traceLevel >= 3){
|
if (traceLevel >= 3){
|
||||||
|
|||||||
@@ -240,33 +240,32 @@ public class AccessTokenManagerByDB implements Lifecycle {
|
|||||||
|
|
||||||
SessionManager.getInstance().getOutboundAccessToken(adapterGroupName, new Function<AccessTokenVO, AccessTokenVO>() {
|
SessionManager.getInstance().getOutboundAccessToken(adapterGroupName, new Function<AccessTokenVO, AccessTokenVO>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccessTokenVO apply(AccessTokenVO accessToken) {
|
public AccessTokenVO apply(AccessTokenVO accessToken) {
|
||||||
|
long intervalTime = System.currentTimeMillis() + (credential.getIntervalSec() * 1000);
|
||||||
long intervalTime = System.currentTimeMillis() + (credential.getIntervalSec() * 1000);
|
// // 토큰이 없거나, 다음 스케줄 시간 전에 만료될 경우 재발급
|
||||||
// // 토큰이 없거나, 다음 스케줄 시간 전에 만료될 경우 재발급
|
if (accessToken == null) {
|
||||||
if (accessToken == null) {
|
logger.debug("Token not exists for adapter group: {}", adapterGroupName);
|
||||||
return issueToken(credential);
|
return issueToken(credential);
|
||||||
} else if(accessToken.getExpiration() != null) {
|
} else if(accessToken.getExpiration() != null) {
|
||||||
// 토큰이 있고 만료시간이 설정 된 경우
|
// 토큰이 있고 만료시간이 설정 된 경우
|
||||||
if(accessToken.getExpiration().before(new Date(intervalTime))){
|
if(accessToken.getExpiration().before(new Date(intervalTime))){
|
||||||
// 다음 스케줄 전에 토큰이 만료되는 경우 재발급
|
// 다음 스케줄 전에 토큰이 만료되는 경우 재발급
|
||||||
return issueToken(credential);
|
logger.debug("Token expired : {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
||||||
|
return issueToken(credential);
|
||||||
|
} else {
|
||||||
|
// 토큰이 아직 유효한 경우
|
||||||
|
logger.debug("Token still valid until next schedule for adapter group: {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 토큰이 아직 유효한 경우
|
//토큰이 있지만 만료 시간이 없는 경우
|
||||||
logger.debug("Token still valid until next schedule for adapter group: {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
logger.debug("Token exists but expiration time is null for adapter group: {}", adapterGroupName);
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//토큰이 있지만 만료 시간이 없는 경우
|
|
||||||
logger.debug("Token exists but expiration time is null for adapter group: {}", adapterGroupName);
|
|
||||||
return accessToken;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Token issuance completed for adapter group: {}", adapterGroupName);
|
logger.debug("Token issuance completed for adapter group: {}", adapterGroupName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Token issuance failed for adapter group: {}", adapterGroupName, e);
|
logger.error("Token issuance failed for adapter group: {}", adapterGroupName, e);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.eactive.eai.common.exception;
|
package com.eactive.eai.common.exception;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.json.simple.JSONValue;
|
|
||||||
|
|
||||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||||
import com.eactive.eai.adapter.AdapterManager;
|
import com.eactive.eai.adapter.AdapterManager;
|
||||||
@@ -60,6 +60,9 @@ public class ExceptionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EAIMessage handle(EAIMessage eaiMessage) {
|
public static EAIMessage handle(EAIMessage eaiMessage) {
|
||||||
|
Properties prop = eaiMessage.getCallProp();
|
||||||
|
prop.setProperty("API_INTERNAL_ERROR_CODE", eaiMessage.getRspErrCd());
|
||||||
|
|
||||||
String inAdapterGroupName = eaiMessage.getSngSysItfTp();
|
String inAdapterGroupName = eaiMessage.getSngSysItfTp();
|
||||||
AdapterManager manager = AdapterManager.getInstance();
|
AdapterManager manager = AdapterManager.getInstance();
|
||||||
AdapterGroupVO group = manager.getAdapterGroupVO(inAdapterGroupName);
|
AdapterGroupVO group = manager.getAdapterGroupVO(inAdapterGroupName);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.eactive.eai.common.logger;
|
package com.eactive.eai.common.logger;
|
||||||
|
|
||||||
import com.eactive.eai.common.logger.mapper.HttpAdapterExtraLogMapper;
|
import com.eactive.eai.common.logger.mapper.HttpAdapterExtraLogMapper;
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
|
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -10,7 +11,9 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class HttpLoggingService {
|
public class HttpLoggingService {
|
||||||
|
|
||||||
@Autowired
|
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private HttpAdapterExtraLogMapper mapper;
|
private HttpAdapterExtraLogMapper mapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -24,6 +27,7 @@ public class HttpLoggingService {
|
|||||||
if (EAIDBLogControl.isEnable()) {
|
if (EAIDBLogControl.isEnable()) {
|
||||||
try {
|
try {
|
||||||
dbLogger.save(httpAdapterExtraLog);
|
dbLogger.save(httpAdapterExtraLog);
|
||||||
|
logger.debug("inserted to DB");
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
String message = e.getMessage();
|
String message = e.getMessage();
|
||||||
// 오류 메시지 추가 - Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
|
// 오류 메시지 추가 - Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
|
||||||
@@ -33,9 +37,11 @@ public class HttpLoggingService {
|
|||||||
EAIDBLogControl.setEnable(false);
|
EAIDBLogControl.setEnable(false);
|
||||||
}
|
}
|
||||||
fileLogger.writeFileLog(httpAdapterExtraLog);
|
fileLogger.writeFileLog(httpAdapterExtraLog);
|
||||||
|
logger.debug("wrote to File");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileLogger.writeFileLog(httpAdapterExtraLog);
|
fileLogger.writeFileLog(httpAdapterExtraLog);
|
||||||
|
logger.debug("wrote to File");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,25 @@ package com.eactive.eai.common.util;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.hc.core5.http.Header;
|
||||||
|
|
||||||
import com.eactive.eai.common.logger.HttpAdapterExtraHeaderVo;
|
import com.eactive.eai.common.logger.HttpAdapterExtraHeaderVo;
|
||||||
import com.eactive.eai.common.logger.HttpAdapterExtraLogVo;
|
import com.eactive.eai.common.logger.HttpAdapterExtraLogVo;
|
||||||
import com.eactive.eai.common.logger.HttpLoggingService;
|
import com.eactive.eai.common.logger.HttpLoggingService;
|
||||||
import com.eactive.eai.common.logger.async.AsyncHttpLoggingPoolManager;
|
import com.eactive.eai.common.logger.async.AsyncHttpLoggingPoolManager;
|
||||||
import com.eactive.eai.env.ElinkConfig;
|
import com.eactive.eai.env.ElinkConfig;
|
||||||
import org.apache.hc.core5.http.Header;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
|
|
||||||
public class HttpAdapterExtraLogUtil {
|
public class HttpAdapterExtraLogUtil {
|
||||||
|
public static final int MAX_HEADER_VALUE_SIZE = 400;
|
||||||
|
public static final String BODY_FIELD_NAME = "eapim-adapter-send-body";
|
||||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||||
|
|
||||||
public static boolean isHttpHeaderMode() {
|
public static boolean isHttpHeaderMode() {
|
||||||
@@ -62,14 +63,19 @@ public class HttpAdapterExtraLogUtil {
|
|||||||
httpAdapterExtraLogVo.setHttpMethod(httpMethod);
|
httpAdapterExtraLogVo.setHttpMethod(httpMethod);
|
||||||
|
|
||||||
for (HttpAdapterExtraHeaderVo httpAdapterExtraHeaderVo : headerVoList) {
|
for (HttpAdapterExtraHeaderVo httpAdapterExtraHeaderVo : headerVoList) {
|
||||||
|
// String name = httpAdapterExtraHeaderVo.getName();
|
||||||
|
// if(StringUtils.isNotBlank(name) && "authorization".equals(name.toLowerCase())) {
|
||||||
|
// httpAdapterExtraHeaderVo.setValue("{hidden}");
|
||||||
|
// }
|
||||||
String value = httpAdapterExtraHeaderVo.getValue();
|
String value = httpAdapterExtraHeaderVo.getValue();
|
||||||
|
if(StringUtils.isNotBlank(value) && value.length() > MAX_HEADER_VALUE_SIZE) {
|
||||||
if (value == null) {
|
value = value.substring(0, 400) + "...";
|
||||||
httpAdapterExtraHeaderVo.setValue(" ");
|
httpAdapterExtraHeaderVo.setValue(value);
|
||||||
}
|
}else if(value == null){
|
||||||
|
httpAdapterExtraHeaderVo.setValue(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
httpAdapterExtraLogVo.setHeaderList(headerVoList);
|
httpAdapterExtraLogVo.setHeaderList(headerVoList);
|
||||||
httpAdapterExtraLogVo.setHttpStatus(httpStatus);
|
httpAdapterExtraLogVo.setHttpStatus(httpStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.eactive.eai.common.util;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.eactive.eai.common.property.PropManager;
|
||||||
|
import com.eactive.eai.common.util.HttpAdapterExtraLogUtil;
|
||||||
|
|
||||||
|
public class RestSendBodyLogUtils {
|
||||||
|
|
||||||
|
private static final String PROP_LOG_MAX_DATA_SIZE = "log.max.data.size";
|
||||||
|
private static final String PROP_GROUP = "RestSendBodyLog";
|
||||||
|
|
||||||
|
private RestSendBodyLogUtils() {
|
||||||
|
throw new IllegalStateException("Utility class");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ID 별 어댑터 body 로그 남기는 지 여부
|
||||||
|
*
|
||||||
|
* @param apiId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isBodyLoggingApi(String apiId) {
|
||||||
|
if (StringUtils.isEmpty(apiId))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String logging = PropManager.getInstance().getProperty(PROP_GROUP, apiId, "N");
|
||||||
|
return StringUtils.equals("Y", logging);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* body 로그에 남길 만큼 자르기
|
||||||
|
*
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getBodyByMaxSize(String body) {
|
||||||
|
String maxDataSize = PropManager.getInstance().getProperty(PROP_GROUP, PROP_LOG_MAX_DATA_SIZE);
|
||||||
|
int imaxDataSize = HttpAdapterExtraLogUtil.MAX_HEADER_VALUE_SIZE;
|
||||||
|
if (maxDataSize != null)
|
||||||
|
imaxDataSize = Integer.parseInt(maxDataSize);
|
||||||
|
|
||||||
|
if (body.length() > imaxDataSize)
|
||||||
|
return StringUtils.substring(body, 0, imaxDataSize) + "...";
|
||||||
|
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -98,6 +98,10 @@ public class RESTProcess extends HTTPProcess {
|
|||||||
this.timeout = iTimeoutValue * 1000;
|
this.timeout = iTimeoutValue * 1000;
|
||||||
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
||||||
|
|
||||||
|
this.tempProp.put("API_SERVICE_CODE", this.reqEaiMsg.getEAISvcCd());
|
||||||
|
this.tempProp.put("OUT_REQ_EAI_MSG", this.reqEaiMsg);
|
||||||
|
this.tempProp.put("OUT_REQ_STD_MSG", this.reqEaiMsg.getStandardMessage());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// API별 이용
|
// API별 이용
|
||||||
String apiId = reqEaiMsg.getEAISvcCd();
|
String apiId = reqEaiMsg.getEAISvcCd();
|
||||||
|
|||||||
Reference in New Issue
Block a user