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<AccessTokenGrantHandler> 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<String, String>
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();
}
}