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:28:27 UTC

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

Repository: cxf
Updated Branches:
  refs/heads/master 86a8325cc -> 8c5e1fb7c


[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/e407bc91
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e407bc91
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e407bc91

Branch: refs/heads/master
Commit: e407bc91bb0e48bf6feb6c4b12b3c7ced87a9732
Parents: 4005dfa
Author: Karl von Randow <ka...@cactuslab.com>
Authored: Thu Aug 27 11:45:06 2015 +1200
Committer: Karl von Randow <ka...@cactuslab.com>
Committed: Thu Aug 27 11:45:06 2015 +1200

----------------------------------------------------------------------
 .../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/e407bc91/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/e407bc91/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);
 }


[4/4] 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

Posted by se...@apache.org.
[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/8c5e1fb7
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8c5e1fb7
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8c5e1fb7

Branch: refs/heads/master
Commit: 8c5e1fb7c490e8231ea706ba0c5d6a4030053a25
Parents: d2756ee
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:28:04 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/8c5e1fb7/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);


[2/4] 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/62ebe027
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/62ebe027
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/62ebe027

Branch: refs/heads/master
Commit: 62ebe027a7d0e24f4eca5da0fff93bcdea692776
Parents: e407bc9
Author: Karl von Randow <ka...@cactuslab.com>
Authored: Thu Aug 27 11:47:36 2015 +1200
Committer: Karl von Randow <ka...@cactuslab.com>
Committed: Thu Aug 27 11:47:36 2015 +1200

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/62ebe027/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;


[3/4] cxf git commit: Merge branch 'resource-owner-grant' of https://github.com/karlvr/cxf

Posted by se...@apache.org.
Merge branch 'resource-owner-grant' of https://github.com/karlvr/cxf


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

Branch: refs/heads/master
Commit: d2756ee8f24af6b2214ab2191cc32480d9c66a55
Parents: 86a8325 62ebe02
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Aug 27 16:49:26 2015 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Aug 27 16:49:26 2015 +0100

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