RequestUtil { public static List<String> getCORSRequestedHeaders( final ContainerRequestContext request) { MultivaluedMap<String, String> headers = request.getHeaders(); String rawHeaders = headers .getFirst(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS); if (Strings.isNullOrEmpty(rawHeaders)) { return Collections.emptyList(); } return Arrays.stream(rawHeaders.split(",")) .map(String::trim) .map(String::toLowerCase) .filter(s -> !Strings.isNullOrEmpty(s)) .collect(Collectors.toList()); } private  RequestUtil(); static String getCORSRequestedMethod(
            final ContainerRequestContext request); static List<String> getCORSRequestedHeaders(
            final ContainerRequestContext request); static URI getOrigin(final ContainerRequestContext request); static URI getReferer(final ContainerRequestContext request); static URI getHost(final ContainerRequestContext request); static URI getForwardedHost(
            final ContainerRequestContext request); static Boolean isCrossOriginRequest(
            final ContainerRequestContext request);  }
@Test public void testCorsRequestedHeaders() throws Exception { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "One, TWO , " + "Three, Four,,Five"); ContainerRequestContext mockContext = buildContext( "https: headers ); List<String> reqHeaders = RequestUtil.getCORSRequestedHeaders(mockContext); assertEquals(5, reqHeaders.size()); assertTrue(reqHeaders.contains("one")); assertTrue(reqHeaders.contains("two")); assertTrue(reqHeaders.contains("three")); assertTrue(reqHeaders.contains("four")); assertTrue(reqHeaders.contains("five")); }
@Test public void testCorsRequestedEmptyHeaders() throws Exception { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); ContainerRequestContext mockContext = buildContext( "https: headers ); List<String> reqHeaders = RequestUtil.getCORSRequestedHeaders(mockContext); assertEquals(0, reqHeaders.size()); }