cxf git commit: [CXF-6561] Removing catch blocks from ResourceOwnerGramtHandler
Repository: cxf Updated Branches: refs/heads/3.0.x-fixes fa6136f83 -> 3ce7b636f [CXF-6561] Removing catch blocks from ResourceOwnerGramtHandler Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3ce7b636 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3ce7b636 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3ce7b636 Branch: refs/heads/3.0.x-fixes Commit: 3ce7b636f10a48cff703a24a3f13a65093b57259 Parents: fa6136f Author: Sergey Beryozkin Authored: Fri Aug 28 13:27:50 2015 +0100 Committer: Sergey Beryozkin Committed: Fri Aug 28 13:29:15 2015 +0100 -- .../grants/owner/ResourceOwnerGrantHandler.java| 17 - .../oauth2/services/AccessTokenService.java| 15 +++ 2 files changed, 15 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/3ce7b636/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java -- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java index f15fc7f..19e0f6b 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java @@ -47,20 +47,11 @@ public class ResourceOwnerGrantHandler extends AbstractGrantHandler { throw new OAuthServiceException( new OAuthError(OAuthConstants.INVALID_REQUEST)); } -UserSubject subject = null; -try { -subject = loginHandler.createSubject(ownerName, ownerPassword); -if (subject == null) { -throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); -} -} catch (OAuthServiceException ex) { -throw ex; -} catch (RuntimeException ex) { -throw new OAuthServiceException(OAuthConstants.INVALID_GRANT, ex); +UserSubject subject = loginHandler.createSubject(ownerName, ownerPassword); +if (subject == null) { +throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); } -return doCreateAccessToken(client, - subject, - params); +return doCreateAccessToken(client, subject, params); } public ResourceOwnerLoginHandler getLoginHandler() { http://git-wip-us.apache.org/repos/asf/cxf/blob/3ce7b636/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java -- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java index af94464..8af601a 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java @@ -28,6 +28,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -99,8 +100,8 @@ public class AccessTokenService extends AbstractTokenService { checkAudience(params); } catch (OAuthServiceException ex) { return super.createErrorResponseFromBean(ex.getError()); -} - +} + // Find the grant handler AccessTokenGrantHandler handler = findGrantHandler(params); if (handler == null) { @@ -111,8 +112,14 @@ public class AccessTokenService extends AbstractTokenService { ServerAccessToken serverToken = null; try { serverToken = handler.createAccessToken(client, params); -} catch (OAuthServiceException ex) { -return handleException(ex, OAuthConstants.INVALID_GRANT); +} catch (WebApplicationException ex) { +throw ex; +} catch (RuntimeException ex) { +// This is done to bypass a Check-Style +// restriction on a number of return statements +
cxf git commit: [CXF-6561] Removing catch blocks from ResourceOwnerGramtHandler
Repository: cxf Updated Branches: refs/heads/master d322272a5 -> 3c0681f2d [CXF-6561] Removing catch blocks from ResourceOwnerGramtHandler Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3c0681f2 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3c0681f2 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3c0681f2 Branch: refs/heads/master Commit: 3c0681f2d546d096c8ce63f11a4920a37e1ac428 Parents: d322272 Author: Sergey Beryozkin Authored: Fri Aug 28 13:27:50 2015 +0100 Committer: Sergey Beryozkin Committed: Fri Aug 28 13:27:50 2015 +0100 -- .../grants/owner/ResourceOwnerGrantHandler.java| 17 - .../oauth2/services/AccessTokenService.java| 15 +++ 2 files changed, 15 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/3c0681f2/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java -- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java index f15fc7f..19e0f6b 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerGrantHandler.java @@ -47,20 +47,11 @@ public class ResourceOwnerGrantHandler extends AbstractGrantHandler { throw new OAuthServiceException( new OAuthError(OAuthConstants.INVALID_REQUEST)); } -UserSubject subject = null; -try { -subject = loginHandler.createSubject(ownerName, ownerPassword); -if (subject == null) { -throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); -} -} catch (OAuthServiceException ex) { -throw ex; -} catch (RuntimeException ex) { -throw new OAuthServiceException(OAuthConstants.INVALID_GRANT, ex); +UserSubject subject = loginHandler.createSubject(ownerName, ownerPassword); +if (subject == null) { +throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); } -return doCreateAccessToken(client, - subject, - params); +return doCreateAccessToken(client, subject, params); } public ResourceOwnerLoginHandler getLoginHandler() { http://git-wip-us.apache.org/repos/asf/cxf/blob/3c0681f2/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java -- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java index af94464..8af601a 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java @@ -28,6 +28,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -99,8 +100,8 @@ public class AccessTokenService extends AbstractTokenService { checkAudience(params); } catch (OAuthServiceException ex) { return super.createErrorResponseFromBean(ex.getError()); -} - +} + // Find the grant handler AccessTokenGrantHandler handler = findGrantHandler(params); if (handler == null) { @@ -111,8 +112,14 @@ public class AccessTokenService extends AbstractTokenService { ServerAccessToken serverToken = null; try { serverToken = handler.createAccessToken(client, params); -} catch (OAuthServiceException ex) { -return handleException(ex, OAuthConstants.INVALID_GRANT); +} catch (WebApplicationException ex) { +throw ex; +} catch (RuntimeException ex) { +// This is done to bypass a Check-Style +// restriction on a number of return statements +OAuthSe