Inbound adapter POST FILTER HMAC_SHA256 에러발생시 적용
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
package com.eactive.eai.adapter.controller;
|
package com.eactive.eai.adapter.controller;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
// jwhong
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -25,6 +28,8 @@ import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
|
|||||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||||
import com.eactive.eai.adapter.http.dynamic.HttpDynamicInAdapterManager;
|
import com.eactive.eai.adapter.http.dynamic.HttpDynamicInAdapterManager;
|
||||||
import com.eactive.eai.adapter.http.dynamic.HttpDynamicInAdapterUri;
|
import com.eactive.eai.adapter.http.dynamic.HttpDynamicInAdapterUri;
|
||||||
|
import com.eactive.eai.adapter.http.dynamic.filter.HttpAdapterFilter;
|
||||||
|
import com.eactive.eai.adapter.http.dynamic.filter.HttpAdapterFilterFactoryKjb;
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.JwtAuthException;
|
import com.eactive.eai.adapter.http.dynamic.filter.JwtAuthException;
|
||||||
import com.eactive.eai.adapter.service.ApiAdapterService;
|
import com.eactive.eai.adapter.service.ApiAdapterService;
|
||||||
import com.eactive.eai.common.TransactionContextKeys;
|
import com.eactive.eai.common.TransactionContextKeys;
|
||||||
@@ -40,11 +45,6 @@ import com.eactive.eai.common.util.MessageUtil;
|
|||||||
import com.eactive.eai.common.util.UUIDGenerator;
|
import com.eactive.eai.common.util.UUIDGenerator;
|
||||||
import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
||||||
|
|
||||||
// jwhong
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class ApiAdapterController implements HttpAdapterServiceKey {
|
public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||||
static Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
static Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
||||||
@@ -166,16 +166,7 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
|||||||
if (encryptAsyncAckApply) {
|
if (encryptAsyncAckApply) {
|
||||||
responseBody = service.doPostEncryption(responseBody, transactionProp, servletRequest);
|
responseBody = service.doPostEncryption(responseBody, transactionProp, servletRequest);
|
||||||
}
|
}
|
||||||
// In 으로 들어온 http header를 ack 줄때 다시 넘겨줌 jwhong, 특히 kakaobank.
|
|
||||||
/*
|
|
||||||
Enumeration<String> headerNames = servletRequest.getHeaderNames();
|
|
||||||
while (headerNames.hasMoreElements()) {
|
|
||||||
String headerName = headerNames.nextElement();
|
|
||||||
String headerValue = servletRequest.getHeader(headerName);
|
|
||||||
servletResponse.setHeader(headerName, headerValue);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
responseEntity = ResponseEntity.status(httpStatus).contentType(mediaType).body(responseBody);
|
responseEntity = ResponseEntity.status(httpStatus).contentType(mediaType).body(responseBody);
|
||||||
// jwhong
|
// jwhong
|
||||||
} else {
|
} else {
|
||||||
@@ -196,22 +187,43 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (HttpStatusException e) {
|
|
||||||
logger.warn("ApiAdapterController] " + adapterGroupName + "-" + adapterName + ">>" + e.getMessage());
|
|
||||||
String errorMsg = MessageUtil.makeErrorMessageByMessageType(adptMsgType, encode,
|
|
||||||
MessageUtil.ERROR_CODE_AP_ERROR, e.getMessage(), errorResponseFormat);
|
|
||||||
responseEntity = ResponseEntity.status(e.getStatus()).contentType(mediaType).body(errorMsg);
|
|
||||||
} catch (JwtAuthException e) {
|
|
||||||
logger.error(adapterGroupName + "-" + adapterName + ">>" + e.getMessage(), e);
|
|
||||||
String errorMsg = MessageUtil.makeErrorMessageByMessageType(adptMsgType, encode,
|
|
||||||
MessageUtil.ERROR_CODE_AUTH_FAIL, e.getMessage(), errorResponseFormat);
|
|
||||||
responseEntity = ResponseEntity.status(HttpStatus.UNAUTHORIZED).contentType(mediaType).body(errorMsg);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
|
||||||
logger.error(adapterGroupName + "-" + adapterName + ">>" + e.getMessage(), e);
|
logger.error(adapterGroupName + "-" + adapterName + ">>" + e.getMessage(), e);
|
||||||
String errorMsg = MessageUtil.makeErrorMessageByMessageType(adptMsgType, encode,
|
|
||||||
MessageUtil.ERROR_CODE_AP_ERROR, e.getMessage(), errorResponseFormat);
|
String errorMsg = null;
|
||||||
responseEntity = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).contentType(mediaType)
|
|
||||||
.body(errorMsg);
|
if( e instanceof HttpStatusException ) {
|
||||||
|
logger.warn("ApiAdapterController] " + adapterGroupName + "-" + adapterName + ">>" + e.getMessage());
|
||||||
|
HttpStatusException e1 = (HttpStatusException) e;
|
||||||
|
errorMsg = MessageUtil.makeErrorMessageByMessageType(adptMsgType, encode,
|
||||||
|
MessageUtil.ERROR_CODE_AP_ERROR, e1.getMessage(), errorResponseFormat);
|
||||||
|
responseEntity = ResponseEntity.status(e1.getStatus()).contentType(mediaType).body(errorMsg);
|
||||||
|
}
|
||||||
|
else if( e instanceof JwtAuthException )
|
||||||
|
{
|
||||||
|
logger.error(adapterGroupName + "-" + adapterName + ">>" + e.getMessage(), e);
|
||||||
|
errorMsg = MessageUtil.makeErrorMessageByMessageType(adptMsgType, encode,
|
||||||
|
MessageUtil.ERROR_CODE_AUTH_FAIL, e.getMessage(), errorResponseFormat);
|
||||||
|
responseEntity = ResponseEntity.status(HttpStatus.UNAUTHORIZED).contentType(mediaType).body(errorMsg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.error(adapterGroupName + "-" + adapterName + ">>" + e.getMessage(), e);
|
||||||
|
errorMsg = MessageUtil.makeErrorMessageByMessageType(adptMsgType, encode,
|
||||||
|
MessageUtil.ERROR_CODE_AP_ERROR, e.getMessage(), errorResponseFormat);
|
||||||
|
responseEntity = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).contentType(mediaType)
|
||||||
|
.body(errorMsg);
|
||||||
|
}
|
||||||
|
String postFilterNames = httpProp.getProperty("POST_FILTERS","");
|
||||||
|
|
||||||
|
if( postFilterNames.contains("HMAC_SHA256") ) {
|
||||||
|
HttpAdapterFilter filter = HttpAdapterFilterFactoryKjb.createFilter("HMAC_SHA256");
|
||||||
|
filter.doPostFilter(adapterGrpName, postFilterNames, errorMsg, transactionProp, servletRequest, servletResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
/**
|
/**
|
||||||
* 로깅 인터셉터에 데이터를 전달하기 위한 처리 이미 거래처리가 끝나서 영향도가 없을만한 servletRequest에 Attribute로 전달
|
* 로깅 인터셉터에 데이터를 전달하기 위한 처리 이미 거래처리가 끝나서 영향도가 없을만한 servletRequest에 Attribute로 전달
|
||||||
|
|||||||
Reference in New Issue
Block a user