Starting with a dynamic registration service test, more to follow

Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f6293b0c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f6293b0c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f6293b0c

Branch: refs/heads/3.1.x-fixes
Commit: f6293b0cbfd682a17d0f9549622cace14c68287a
Parents: d345b60
Author: Sergey Beryozkin <[email protected]>
Authored: Fri Sep 23 12:48:59 2016 +0100
Committer: Sergey Beryozkin <[email protected]>
Committed: Fri Sep 23 12:52:33 2016 +0100

----------------------------------------------------------------------
 .../rs/security/oauth2/services/DynamicRegistrationService.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f6293b0c/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
----------------------------------------------------------------------
diff --git 
a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
 
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
index a0d6bc7..78b971d 100644
--- 
a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
+++ 
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
@@ -80,7 +80,7 @@ public class DynamicRegistrationService extends 
AbstractOAuthService {
         String[] authParts = 
AuthorizationUtils.getAuthorizationParts(getMessageContext(), 
                              
Collections.singleton(OAuthConstants.BEARER_AUTHORIZATION_SCHEME));
         if (authParts.length != 2 || !authParts[1].equals(accessToken)) {
-            throw ExceptionUtils.toForbiddenException(null, null);
+            throw ExceptionUtils.toNotAuthorizedException(null, null);
         }
     }
 
@@ -141,6 +141,9 @@ public class DynamicRegistrationService extends 
AbstractOAuthService {
     
     protected Client readClient(String clientId) {
         Client c = clientProvider.getClient(clientId);
+        if (c == null) {
+            throw ExceptionUtils.toNotAuthorizedException(null, null);
+        }
         String regAccessToken = 
c.getProperties().get(ClientRegistrationResponse.REG_ACCESS_TOKEN);
         // Or check OAuthDataProvider.getAccessToken
         // if OAuthDataProvider.createAccessToken was used

Reply via email to