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