@Test public void testGenerateHtmlHeaders1() throws XRd4JException { ConsumerMember consumer = new ConsumerMember("FI_PILOT", "GOV", "0245437-2", "ConsumerService"); ProducerMember producer = new ProducerMember("FI_PILOT", "GOV", "1019125-0", "Demo2Service", "getOrganizationList", "v1"); ServiceRequest request = new ServiceRequest(consumer, producer, "12345"); request.setUserId("test-user"); Map<String, String> headers = ProviderGatewayUtil.generateHttpHeaders(request, this.map.get("FI_PILOT.GOV.1019125-0.Demo2Service.getOrganizationList.v1")); assertEquals("FI_PILOT.GOV.0245437-2.ConsumerService", headers.get(Constants.XRD_HEADER_CLIENT)); assertEquals("FI_PILOT.GOV.1019125-0.Demo2Service.getOrganizationList.v1", headers.get(Constants.XRD_HEADER_SERVICE)); assertEquals("12345", headers.get(Constants.XRD_HEADER_MESSAGE_ID)); assertEquals("test-user", headers.get(Constants.XRD_HEADER_USER_ID)); assertEquals(null, headers.get(Constants.HTTP_HEADER_CONTENT_TYPE)); assertEquals(null, headers.get(Constants.HTTP_HEADER_ACCEPT)); }
public static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint) { log.info("Generate HTTP headers."); Map<String, String> headers = new HashMap<>(); if (endpoint.isSendXrdHeaders()) { log.debug("Generate X-Road specific headers."); headers.put(Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); headers.put(Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); headers.put(Constants.XRD_HEADER_MESSAGE_ID, request.getId()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_MESSAGE_ID, request.getId()); if (request.getUserId() != null && !request.getUserId().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_USER_ID, request.getUserId()); headers.put(Constants.XRD_HEADER_USER_ID, request.getUserId()); } } else { log.debug("Generation of X-Road specific headers is disabled."); } if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); headers.put(Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); } if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); headers.put(Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); } log.info("HTTP headers were succesfully generated."); return headers; }
ProviderGatewayUtil { public static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint) { log.info("Generate HTTP headers."); Map<String, String> headers = new HashMap<>(); if (endpoint.isSendXrdHeaders()) { log.debug("Generate X-Road specific headers."); headers.put(Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); headers.put(Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); headers.put(Constants.XRD_HEADER_MESSAGE_ID, request.getId()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_MESSAGE_ID, request.getId()); if (request.getUserId() != null && !request.getUserId().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_USER_ID, request.getUserId()); headers.put(Constants.XRD_HEADER_USER_ID, request.getUserId()); } } else { log.debug("Generation of X-Road specific headers is disabled."); } if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); headers.put(Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); } if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); headers.put(Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); } log.info("HTTP headers were succesfully generated."); return headers; } }
ProviderGatewayUtil { public static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint) { log.info("Generate HTTP headers."); Map<String, String> headers = new HashMap<>(); if (endpoint.isSendXrdHeaders()) { log.debug("Generate X-Road specific headers."); headers.put(Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); headers.put(Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); headers.put(Constants.XRD_HEADER_MESSAGE_ID, request.getId()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_MESSAGE_ID, request.getId()); if (request.getUserId() != null && !request.getUserId().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_USER_ID, request.getUserId()); headers.put(Constants.XRD_HEADER_USER_ID, request.getUserId()); } } else { log.debug("Generation of X-Road specific headers is disabled."); } if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); headers.put(Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); } if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); headers.put(Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); } log.info("HTTP headers were succesfully generated."); return headers; } private  ProviderGatewayUtil(); }
ProviderGatewayUtil { public static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint) { log.info("Generate HTTP headers."); Map<String, String> headers = new HashMap<>(); if (endpoint.isSendXrdHeaders()) { log.debug("Generate X-Road specific headers."); headers.put(Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); headers.put(Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); headers.put(Constants.XRD_HEADER_MESSAGE_ID, request.getId()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_MESSAGE_ID, request.getId()); if (request.getUserId() != null && !request.getUserId().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_USER_ID, request.getUserId()); headers.put(Constants.XRD_HEADER_USER_ID, request.getUserId()); } } else { log.debug("Generation of X-Road specific headers is disabled."); } if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); headers.put(Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); } if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); headers.put(Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); } log.info("HTTP headers were succesfully generated."); return headers; } private  ProviderGatewayUtil(); static Map<String, ProviderEndpoint> extractProviders(Properties endpoints, Properties gatewayProperties); static void extractEndpoints(String key, Properties endpoints, ProviderEndpoint endpoint); static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint); static String fromJSONToXML(String data); static String getRequestBody(Map<String, List<String>> params); static void filterRequestParameters(ServiceRequest request, ProviderEndpoint endpoint); static boolean checkPrivateKeyProperties(Properties props, Map<String, ProviderEndpoint> endpoints); }
ProviderGatewayUtil { public static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint) { log.info("Generate HTTP headers."); Map<String, String> headers = new HashMap<>(); if (endpoint.isSendXrdHeaders()) { log.debug("Generate X-Road specific headers."); headers.put(Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); headers.put(Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); headers.put(Constants.XRD_HEADER_MESSAGE_ID, request.getId()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_CLIENT, request.getConsumer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_SERVICE, request.getProducer().toString()); log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_MESSAGE_ID, request.getId()); if (request.getUserId() != null && !request.getUserId().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.XRD_HEADER_USER_ID, request.getUserId()); headers.put(Constants.XRD_HEADER_USER_ID, request.getUserId()); } } else { log.debug("Generation of X-Road specific headers is disabled."); } if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); headers.put(Constants.HTTP_HEADER_CONTENT_TYPE, endpoint.getContentType()); } if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) { log.debug(Constants.LOG_STRING_FOR_HEADERS, Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); headers.put(Constants.HTTP_HEADER_ACCEPT, endpoint.getAccept()); } log.info("HTTP headers were succesfully generated."); return headers; } private  ProviderGatewayUtil(); static Map<String, ProviderEndpoint> extractProviders(Properties endpoints, Properties gatewayProperties); static void extractEndpoints(String key, Properties endpoints, ProviderEndpoint endpoint); static Map<String, String> generateHttpHeaders(ServiceRequest request, ProviderEndpoint endpoint); static String fromJSONToXML(String data); static String getRequestBody(Map<String, List<String>> params); static void filterRequestParameters(ServiceRequest request, ProviderEndpoint endpoint); static boolean checkPrivateKeyProperties(Properties props, Map<String, ProviderEndpoint> endpoints);  }