You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2015/08/27 18:39:13 UTC

[1/3] cxf git commit: [CXF-6561, CXF-6562] Checking a null subject in ResourceOwnerGrantHandler, patch from Karl von Randow applied with minor updates, This closes #83

Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes dbfbbbbf2 -> e525c7701


[CXF-6561, CXF-6562] Checking a null subject in ResourceOwnerGrantHandler, patch from Karl von Randow applied with minor updates, This closes #83


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

Branch: refs/heads/3.0.x-fixes
Commit: e525c7701c9665d8bd37dbc39694b22f330b9a60
Parents: b097710
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Aug 27 17:28:04 2015 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Aug 27 17:38:38 2015 +0100

----------------------------------------------------------------------
 .../grants/owner/ResourceOwnerGrantHandler.java     | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e525c770/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 d7f6c33..58718b8 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,13 +47,17 @@ public class ResourceOwnerGrantHandler extends AbstractGrantHandler {
             throw new OAuthServiceException(
                  new OAuthError(OAuthConstants.INVALID_REQUEST));
         }
-        
-        UserSubject subject = loginHandler.createSubject(ownerName, ownerPassword);
-        
-        if (subject == null) {
-            throw new OAuthServiceException(OAuthConstants.INVALID_GRANT);
+        UserSubject subject = null;
+        try {
+            subject = loginHandler.createSubject(ownerName, ownerPassword);
+            if (subject == null) {
+                throw new OAuthServiceException(OAuthConstants.INVALID_GRANT);
+            }
+        } catch (OAuthServiceException ex) { 
+            throw ex;
+        } catch (Exception ex) { 
+            throw new OAuthServiceException(OAuthConstants.INVALID_GRANT, ex);
         }
-        
         return doCreateAccessToken(client, 
                                    subject,
                                    params);


[3/3] cxf git commit: [CXF-6561] ResourceOwnerGrantHandler: handle null result from loginHandler

Posted by se...@apache.org.
[CXF-6561] ResourceOwnerGrantHandler: handle null result from loginHandler

Document that ResourceOwnerLoginHandler should return null in the event that the user credentials are not valid.

There is no need to catch a RuntimeException, or any Exception, as only RuntimeExceptions (or Errors) can be thrown by the createSubject method as it has no declared exceptions.


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

Branch: refs/heads/3.0.x-fixes
Commit: 5d878329c22083618b0f2505e3b02aee170de032
Parents: dbfbbbb
Author: Karl von Randow <ka...@cactuslab.com>
Authored: Thu Aug 27 11:45:06 2015 +1200
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Aug 27 17:38:38 2015 +0100

----------------------------------------------------------------------
 .../oauth2/grants/owner/ResourceOwnerGrantHandler.java   | 11 ++++-------
 .../oauth2/grants/owner/ResourceOwnerLoginHandler.java   |  8 ++++++++
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5d878329/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 8b2e160..875823b 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
@@ -48,13 +48,10 @@ public class ResourceOwnerGrantHandler extends AbstractGrantHandler {
                  new OAuthError(OAuthConstants.INVALID_REQUEST));
         }
         
-        UserSubject subject = null;
-        try {
-            subject = loginHandler.createSubject(ownerName, ownerPassword);
-        } catch (RuntimeException ex) { 
-            throw ex;
-        } catch (Exception 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, 

http://git-wip-us.apache.org/repos/asf/cxf/blob/5d878329/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerLoginHandler.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerLoginHandler.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerLoginHandler.java
index 8eebfe2..8d63d69 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerLoginHandler.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/owner/ResourceOwnerLoginHandler.java
@@ -21,5 +21,13 @@ package org.apache.cxf.rs.security.oauth2.grants.owner;
 import org.apache.cxf.rs.security.oauth2.common.UserSubject;
 
 public interface ResourceOwnerLoginHandler {
+    
+    /**
+     * Create a {@link UserSubject} for the name and password parameters, or return null if the name and password
+     * are invalid.
+     * @param name
+     * @param password
+     * @return A {@link UserSubject} representing the user, or null.
+     */
     UserSubject createSubject(String name, String password);
 }


[2/3] cxf git commit: [CXF-6562] ResourceOwnerGrantHandler: add getter for loginHandler

Posted by se...@apache.org.
[CXF-6562] ResourceOwnerGrantHandler: add getter for loginHandler


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

Branch: refs/heads/3.0.x-fixes
Commit: b097710655628000edfe4bcc6d935c1dc68a53fa
Parents: 5d87832
Author: Karl von Randow <ka...@cactuslab.com>
Authored: Thu Aug 27 11:47:36 2015 +1200
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Aug 27 17:38:38 2015 +0100

----------------------------------------------------------------------
 .../security/oauth2/grants/owner/ResourceOwnerGrantHandler.java  | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b0977106/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 875823b..d7f6c33 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
@@ -58,6 +58,10 @@ public class ResourceOwnerGrantHandler extends AbstractGrantHandler {
                                    subject,
                                    params);
     }
+    
+    public ResourceOwnerLoginHandler getLoginHandler() {
+        return this.loginHandler;
+    }
 
     public void setLoginHandler(ResourceOwnerLoginHandler loginHandler) {
         this.loginHandler = loginHandler;