| | |
| | | * @param param |
| | | */ |
| | | public static void createSign(Map<String, String> headers, HttpMethod httpMethod, String url, String param) { |
| | | String appId = headers.get(CommonConstant.HTTP_APP_ID); |
| | | String appId = headers.get(CommonConstant.APP_ID); |
| | | if (StringUtil.isEmpty(appId)) { |
| | | appId = headers.get(CommonConstant.APP_ID); |
| | | appId = headers.get(CommonConstant.HTTP_APP_ID); |
| | | } |
| | | String transactionId = headers.get(CommonConstant.HTTP_TRANSACTION_ID); |
| | | String transactionId = headers.get(CommonConstant.TRANSACTION_ID); |
| | | if (StringUtil.isEmpty(transactionId)) { |
| | | transactionId = headers.get(CommonConstant.TRANSACTION_ID); |
| | | transactionId = headers.get(CommonConstant.HTTP_TRANSACTION_ID); |
| | | } |
| | | String requestTime = headers.get(CommonConstant.HTTP_REQ_TIME); |
| | | String requestTime = headers.get(CommonConstant.REQUEST_TIME); |
| | | if (StringUtil.isEmpty(transactionId)) { |
| | | requestTime = headers.get(CommonConstant.REQUEST_TIME); |
| | | requestTime = headers.get(CommonConstant.HTTP_REQ_TIME); |
| | | } |
| | | |
| | | List<AppRoute> appRoutes = AppRouteCache.getAppRoute(appId); |
| | |
| | | if (!headers.containsKey(CommonConstant.HTTP_REQ_TIME)) { |
| | | headers.put(CommonConstant.HTTP_REQ_TIME, DateUtil.getNowDefault()); |
| | | } |
| | | if (!headers.containsKey(CommonConstant.HTTP_SIGN)) { |
| | | headers.put(CommonConstant.HTTP_SIGN, ""); |
| | | } |
| | | |
| | | if (url.indexOf("?") > -1) { |
| | | url = url.substring(0, url.indexOf("?")); |
| | |
| | | if (HttpMethod.GET == httpMethod) { |
| | | headers.put("REQUEST_URL", "http://127.0.0.1:8008/" + url + mapToUrlParam(JSONObject.parseObject(param))); |
| | | } |
| | | AuthenticationFactory.createSign(headers,httpMethod,headers.get("REQUEST_URL"),param); |
| | | |
| | | try { |
| | | responseEntity = apiServiceSMOImpl.service(param, headers); |
| | | } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下 |
| | |
| | | if (!headers.containsKey(CommonConstant.HTTP_REQ_TIME)) { |
| | | headers.put(CommonConstant.HTTP_REQ_TIME, DateUtil.getNowDefault()); |
| | | } |
| | | if (!headers.containsKey(CommonConstant.HTTP_SIGN)) { |
| | | headers.put(CommonConstant.HTTP_SIGN, ""); |
| | | } |
| | | |
| | | if (url.indexOf("?") > -1) { |
| | | url = url.substring(0, url.indexOf("?")); |
| | |
| | | if (HttpMethod.GET == httpMethod) { |
| | | headers.put("REQUEST_URL", "http://127.0.0.1:8008/" + url + mapToUrlParam(JSONObject.parseObject(param))); |
| | | } |
| | | AuthenticationFactory.createSign(headers,httpMethod,headers.get("REQUEST_URL"),param); |
| | | |
| | | try { |
| | | responseEntity = apiServiceSMOImpl.service(param, headers); |
| | | } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下 |