HMAC처리를 위한 수정
This commit is contained in:
@@ -25,6 +25,8 @@ import com.eactive.eai.common.stdmessage.STDMsgInfoAddOnVO;
|
||||
|
||||
|
||||
public class ApiRequestBodyFilter extends OncePerRequestFilter {
|
||||
|
||||
static final String KJB_ROOTLESS_ARRAY = "{ \"KJB_ROOTLESS_ARRAY\" : ";
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
@@ -57,9 +59,8 @@ public class ApiRequestBodyFilter extends OncePerRequestFilter {
|
||||
Object json = JSONValue.parse(bodyStr);
|
||||
|
||||
if (json instanceof JSONArray) {
|
||||
JSONObject wrap = new JSONObject();
|
||||
wrap.put("KJB_ROOTLESS_ARRAY", json);
|
||||
finalBody = wrap.toJSONString().getBytes(encoding);
|
||||
bodyStr = KJB_ROOTLESS_ARRAY + bodyStr + "}";
|
||||
finalBody = bodyStr.getBytes(encoding);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class ApiResponseAdvice implements ResponseBodyAdvice<Object> {
|
||||
|
||||
static final String KJB_ROOTLESS_ARRAY = "{ \"KJB_ROOTLESS_ARRAY\" : ";
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
@@ -34,16 +36,16 @@ public class ApiResponseAdvice implements ResponseBodyAdvice<Object> {
|
||||
}
|
||||
|
||||
String removeRootlessArrayKeyFormResponseBody(String body) {
|
||||
try {
|
||||
Object root = JSONValue.parse(body);
|
||||
|
||||
if (root instanceof JSONObject && ((JSONObject) root).containsKey("KJB_ROOTLESS_ARRAY")) {
|
||||
JSONArray jsonArray = (JSONArray) ((JSONObject) root).get("KJB_ROOTLESS_ARRAY");
|
||||
return jsonArray.toJSONString();
|
||||
} else {
|
||||
return body;
|
||||
if (body.startsWith(KJB_ROOTLESS_ARRAY)) {
|
||||
body = body.substring(KJB_ROOTLESS_ARRAY.length());
|
||||
|
||||
if (body.endsWith("}")) {
|
||||
body = body.substring(0, body.length() - 1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
return body;
|
||||
} else {
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user