public Response handleRequest(Message m, ClassResourceInfo resourceClass) { OperationResourceInfo opResInfo = m.getExchange().get(OperationResourceInfo.class); CrossOriginResourceSharing annotation = opResInfo == null ? null : getAnnotation(opResInfo.getAnnotatedMethod(), CrossOriginResourceSharing.class); if ("OPTIONS".equals(m.get(Message.HTTP_REQUEST_METHOD))) { return preflightRequest(m, annotation, opResInfo, resourceClass); } return simpleRequest(m, annotation); }
private Response simpleRequest(Message m, Method resourceMethod) { CrossOriginResourceSharing ann = getAnnotation(resourceMethod, CrossOriginResourceSharing.class); List<String> headerOriginValues = getHeaderValues(CorsHeaderConstants.HEADER_ORIGIN, true); // 5.1.1 there has to be an origin if (headerOriginValues == null || headerOriginValues.isEmpty()) { return null; } // 5.1.2 check all the origins if (!effectiveAllowOrigins(ann, headerOriginValues)) { return null; } // handle 5.1.3 setAllowOriginAndCredentials(m, ann, headerOriginValues); // 5.1.4 List<String> effectiveExposeHeaders = effectiveExposeHeaders(ann); if (effectiveExposeHeaders != null && effectiveExposeHeaders.size() != 0) { m.getExchange().put(CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS, effectiveExposeHeaders); } // note what kind of processing we're doing. m.getExchange().put(CrossOriginResourceSharingFilter.class.getName(), SIMPLE_REQUEST); return null; }
private Response simpleRequest(Message m, Method resourceMethod) { CrossOriginResourceSharing ann = getAnnotation(resourceMethod, CrossOriginResourceSharing.class); List<String> headerOriginValues = getHeaderValues(CorsHeaderConstants.HEADER_ORIGIN, true); // 5.1.1 there has to be an origin if (headerOriginValues == null || headerOriginValues.isEmpty()) { return null; } // 5.1.2 check all the origins if (!effectiveAllowOrigins(ann, headerOriginValues)) { return null; } // handle 5.1.3 setAllowOriginAndCredentials(m, ann, headerOriginValues); // 5.1.4 List<String> effectiveExposeHeaders = effectiveExposeHeaders(ann); if (effectiveExposeHeaders != null && effectiveExposeHeaders.size() != 0) { m.getExchange().put(CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS, effectiveExposeHeaders); } // note what kind of processing we're doing. m.getExchange().put(CrossOriginResourceSharingFilter.class.getName(), SIMPLE_REQUEST); return null; }
Method optionsMethod = getResourceMethod(m, "OPTIONS"); if (optionsMethod != null) { preflightAnnotation = getAnnotation(optionsMethod, LocalPreflight.class); CrossOriginResourceSharing ann = getAnnotation(method, CrossOriginResourceSharing.class);
: getAnnotation(opResInfo.getAnnotatedMethod(), LocalPreflight.class); if (preflightAnnotation != null || defaultOptionsMethodsHandlePreflight) { m.put(LOCAL_PREFLIGHT, "true"); CrossOriginResourceSharing ann = getAnnotation(method, CrossOriginResourceSharing.class); ann = ann == null ? corsAnn : ann;
Method optionsMethod = getResourceMethod(m, "OPTIONS"); if (optionsMethod != null) { preflightAnnotation = getAnnotation(optionsMethod, LocalPreflight.class); CrossOriginResourceSharing ann = getAnnotation(method, CrossOriginResourceSharing.class);