Return-Path: X-Original-To: apmail-cxf-dev-archive@www.apache.org Delivered-To: apmail-cxf-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93FE2984D for ; Sat, 19 Nov 2011 00:11:25 +0000 (UTC) Received: (qmail 54871 invoked by uid 500); 19 Nov 2011 00:11:25 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 54826 invoked by uid 500); 19 Nov 2011 00:11:25 -0000 Mailing-List: contact dev-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list dev@cxf.apache.org Received: (qmail 54818 invoked by uid 99); 19 Nov 2011 00:11:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2011 00:11:25 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bimargulies@gmail.com designates 74.125.82.49 as permitted sender) Received: from [74.125.82.49] (HELO mail-ww0-f49.google.com) (74.125.82.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2011 00:11:20 +0000 Received: by wwe32 with SMTP id 32so5239050wwe.6 for ; Fri, 18 Nov 2011 16:10:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=4zqLGzc9dx+oy84jW+PYe0ahIyAHLwpbi2RLKYM5A64=; b=aO6b34coHuFfSoa1JKg91LeRx5Y1A6QHFkae/KXhlkosmHV9Ti2wiXpImJIqbg1Abv iqGVSmR/CVd9AqzQVD5eyT12k+RfeXxyWmG6ZM9gVLThsrGwB0yJTJZWLBkhEhsHqPA2 HvotvRVBkacbaJVoq/RaOXwJqJyNA+wSE24zA= MIME-Version: 1.0 Received: by 10.180.103.170 with SMTP id fx10mr5236909wib.56.1321661459206; Fri, 18 Nov 2011 16:10:59 -0800 (PST) Received: by 10.180.100.100 with HTTP; Fri, 18 Nov 2011 16:10:59 -0800 (PST) In-Reply-To: <4EC68C48.4050000@gmail.com> References: <4EB7E6BA.9010608@gmail.com> <4EB8002B.10700@gmail.com> <1320975010157-4982973.post@n5.nabble.com> <4EBCFC80.50700@gmail.com> <1321040778763-4985376.post@n5.nabble.com> <4EBFF75E.4000608@gmail.com> <1321551597689-5001897.post@n5.nabble.com> <4EC68C48.4050000@gmail.com> Date: Fri, 18 Nov 2011 19:10:59 -0500 Message-ID: Subject: Re: CORS From: Benson Margulies To: dev@cxf.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable OK, but attaching it to a JIRA still gives is clear provenance and we can find it a home later. On Fri, Nov 18, 2011 at 11:48 AM, Sergey Beryozkin w= rote: > Hi Benson > On 18/11/11 00:25, Benson Margulies wrote: >> >> Serg, >> >> To contribute code, it's preferred, if possible, to attach it to a JIRA. >> > I was thinking of simply documenting it for a start as I'm not sure where= to > add this code to. I guess I'd like it to go to a sep module but at this > stage creating a module for keeping two simple filters may be a bit early= . > We can have another extension package added for a start to the rs fronten= d, > and move it elsewhere, but I'm a bit cautious about it too as the fronten= d > module is becoming quite monolitic and it will need to be split in time t= oo, > so I'm thinking that may be we just doc it and users will simply copy & > paste the simple code, same way we started with JSONP code fragments. > > > Sergey > >> --benson >> >> >> On Thu, Nov 17, 2011 at 12:39 PM, sergkorney =C2= =A0wrote: >>> >>> here it is: >>> >>> public class JaxrsCorsInputFilter implements RequestHandler { >>> >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0final static String HEADER_ORIGIN =3D "origi= n"; >>> >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0@Context >>> =C2=A0 =C2=A0private HttpHeaders headers; >>> >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0private List =C2=A0allowedOrigins; >>> >>> =C2=A0 =C2=A0public void setAllowedOrigins(List =C2=A0allowedOr= igins) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0this.allowedOrig= ins =3D allowedOrigins; >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0@Override >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0public Response handleRequest(Message m, Cla= ssResourceInfo >>> resourceClass) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0if ("OPTIONS".equals(m.get(Message.HTTP_REQU= EST_METHOD))) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0OperationResourc= eInfo opResInfo =3D >>> m.getExchange().get(OperationResourceInfo.class); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (opResInfo != =3D null) { // OPTIONS method defined in >>> service bean >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0return null; // continue handling >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return Response.status(Status.= SERVICE_UNAVAILABLE).build(); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0List =C2=A0values =3D headers.getReq= uestHeader(HEADER_ORIGIN); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0if (values !=3D null ) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0boolean allowed = =3D true; >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (allowedOrigi= ns !=3D null) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0allowed =3D allowedOrigins.containsAll(values); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (allowed) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m.getExchange().= put(HEADER_ORIGIN, values); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null; >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>> >>> } >>> >>> >>> -- >>> View this message in context: >>> http://cxf.547215.n5.nabble.com/CORS-tp4970153p5001897.html >>> Sent from the cxf-dev mailing list archive at Nabble.com. >>> > > > -- > Sergey Beryozkin > > http://sberyozkin.blogspot.com > > Talend Community Coders > http://coders.talend.com/ >