Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1733ADA56 for ; Tue, 17 Jul 2012 11:30:39 +0000 (UTC) Received: (qmail 84949 invoked by uid 500); 17 Jul 2012 11:30:39 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 84888 invoked by uid 500); 17 Jul 2012 11:30:38 -0000 Mailing-List: contact commits-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 commits@cxf.apache.org Received: (qmail 84878 invoked by uid 99); 17 Jul 2012 11:30:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 11:30:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 11:30:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AD9D02388962; Tue, 17 Jul 2012 11:30:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1362449 - in /cxf/branches/2.6.x-fixes: ./ rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java Date: Tue, 17 Jul 2012 11:30:14 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120717113014.AD9D02388962@eris.apache.org> Author: sergeyb Date: Tue Jul 17 11:30:14 2012 New Revision: 1362449 URL: http://svn.apache.org/viewvc?rev=1362449&view=rev Log: Merged revisions 1362448 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1362448 | sergeyb | 2012-07-17 12:27:55 +0100 (Tue, 17 Jul 2012) | 1 line [CXF-4427] Optionally reporting the custom error details ........ Modified: cxf/branches/2.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/trunk:r1362448 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java?rev=1362449&r1=1362448&r2=1362449&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java (original) +++ cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java Tue Jul 17 11:30:14 2012 @@ -53,11 +53,16 @@ import org.apache.cxf.rs.security.oauth2 public class AccessTokenService extends AbstractOAuthService { private List grantHandlers = Collections.emptyList(); private boolean writeOptionalParameters = true; + private boolean writeCustomErrors; public void setWriteOptionalParameters(boolean write) { writeOptionalParameters = write; } + public void setWriteCustomErrors(boolean write) { + writeCustomErrors = write; + } + /** * Sets the list of optional grant handlers * @param handlers the grant handlers @@ -90,7 +95,11 @@ public class AccessTokenService extends try { serverToken = handler.createAccessToken(client, params); } catch (OAuthServiceException ex) { - // the error response is to be returned next + OAuthError customError = ex.getError(); + if (writeCustomErrors && customError != null) { + return createErrorResponseFromBean(customError); + } + } if (serverToken == null) { return createErrorResponse(params, OAuthConstants.INVALID_GRANT); @@ -201,7 +210,10 @@ public class AccessTokenService extends protected Response createErrorResponse(MultivaluedMap params, String error) { - OAuthError oauthError = new OAuthError(error); - return Response.status(400).entity(oauthError).build(); + return createErrorResponseFromBean(new OAuthError(error)); + } + + protected Response createErrorResponseFromBean(OAuthError errorBean) { + return Response.status(400).entity(errorBean).build(); } }