Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 28702 invoked from network); 25 Aug 2010 22:25:40 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Aug 2010 22:25:40 -0000 Received: (qmail 73182 invoked by uid 500); 25 Aug 2010 22:25:39 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 73029 invoked by uid 500); 25 Aug 2010 22:25:39 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 73021 invoked by uid 99); 25 Aug 2010 22:25:38 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Aug 2010 22:25:38 +0000 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=FREEMAIL_FROM,SPF_HELO_PASS,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: 216.139.236.158 is neither permitted nor denied by domain of griggsrl@gmail.com) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Aug 2010 22:25:17 +0000 Received: from sam.nabble.com ([192.168.236.26]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1OoOOu-0001qD-KQ for users@cxf.apache.org; Wed, 25 Aug 2010 15:24:56 -0700 Date: Wed, 25 Aug 2010 15:24:56 -0700 (PDT) From: kettch To: users@cxf.apache.org Message-ID: <1282775096625-2653453.post@n5.nabble.com> Subject: Moving from Axis to CXF MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I've got an Axis webservice that I've been charged with moving to CXF. The one thing that is confounding me is how to get the authentication info. For example, this is the existing snippet in the Axis version: MessageContext mc = MessageContext.getCurrentContext(); try { authenticator.authenticate(mc.getUsername(),mc.getPassword()); ... operation=mc.getOperation().getName(); } catch(Exception e){ logger.warn("User authentication error - " + mc.getUsername()); throw new AxisFault(new QName(""),"User Authentication Error", "getUser",new Element[]{}); } Now as far as I've been able to find online, the "new" version should look like: @Resource private WebServiceContext context; // In the class definition .... MessageContext mc = context.getMessageContext(); AuthorizationPolicy policy = (AuthorizationPolicy)mc.get(AuthorizationPolicy.class); try { authenticator.authenticate(policy.getUsername(),policy.getPassword()); ... operation = ((QName)mc.get(Message.WSDL_OPERATION)).toString(); } catch(Exception e){ logger.warn("User authentication error - " + mc.getUsername()); throw new AxisFault(new QName(""),"User Authentication Error", "getUser",new Element[]{}); } But I am getting an exception thrown when getting the AuthorizationPolicy like this: AuthorizationPolicy policy = (AuthorizationPolicy)mc.get(AuthorizationPolicy.class); saying that "java.lang.Class cannot be cast to java.lang.String". All of the examples I've seen online have the exact same code...what am I doing wrong? I'm new to CXF so I'm sure it's something stupid. I'm using CXF 2.2.10. -- View this message in context: http://cxf.547215.n5.nabble.com/Moving-from-Axis-to-CXF-tp2653453p2653453.html Sent from the cxf-user mailing list archive at Nabble.com.