cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Minor update to JPAOAuthDataProvider
Date Thu, 21 Apr 2016 14:27:43 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 13848329a -> 0b609b0ab


Minor update to JPAOAuthDataProvider


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

Branch: refs/heads/master
Commit: 0b609b0ab323baecc3cb20e251b43fde43d4c42c
Parents: 1384832
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Apr 21 15:26:05 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Apr 21 15:27:29 2016 +0100

----------------------------------------------------------------------
 .../security/oauth2/provider/JPAOAuthDataProvider.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0b609b0a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
index c552592..bdce24b 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
@@ -24,6 +24,7 @@ import java.util.List;
 import javax.persistence.EntityManager;
 import javax.persistence.TypedQuery;
 
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.OAuthPermission;
 import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
@@ -71,7 +72,7 @@ public class JPAOAuthDataProvider extends AbstractOAuthDataProvider {
 
     @Override
     public List<ServerAccessToken> getAccessTokens(Client c, UserSubject sub) {
-        return getTokensQuery(c, sub).getResultList();
+        return CastUtils.cast(getTokensQuery(c, sub).getResultList());
     }
 
     @Override
@@ -144,23 +145,23 @@ public class JPAOAuthDataProvider extends AbstractOAuthDataProvider
{
                 + resourceOwnerSubject.getLogin() + "'", Client.class);
         }
     }
-    protected TypedQuery<ServerAccessToken> getTokensQuery(Client c, UserSubject resourceOwnerSubject)
{
+    protected TypedQuery<BearerAccessToken> getTokensQuery(Client c, UserSubject resourceOwnerSubject)
{
         if (c == null && resourceOwnerSubject == null) {
             return entityManager.createQuery("SELECT t FROM " + BEARER_TOKEN_TABLE_NAME +
" t", 
-                                             ServerAccessToken.class);
+                                             BearerAccessToken.class);
         } else if (c == null) {
             return entityManager.createQuery(
                 "SELECT t FROM " + BEARER_TOKEN_TABLE_NAME + " t JOIN t.subject s WHERE s.login
= '" 
-                + resourceOwnerSubject.getLogin() + "'", ServerAccessToken.class);
+                + resourceOwnerSubject.getLogin() + "'", BearerAccessToken.class);
         } else if (resourceOwnerSubject == null) {
             return entityManager.createQuery(
                 "SELECT t FROM " + BEARER_TOKEN_TABLE_NAME + " t JOIN t.client c WHERE c.clientId
= '" 
-                    + c.getClientId() + "'", ServerAccessToken.class);
+                    + c.getClientId() + "'", BearerAccessToken.class);
         } else {
             return entityManager.createQuery(
                 "SELECT t FROM " + BEARER_TOKEN_TABLE_NAME + " t JOIN t.subject s JOIN t.client
c WHERE s.login = '" 
                 + resourceOwnerSubject.getLogin() + "' AND c.clientId = '" + c.getClientId()
+ "'",
-                ServerAccessToken.class);
+                BearerAccessToken.class);
         }
     }
     protected TypedQuery<RefreshToken> getRefreshTokensQuery(Client c, UserSubject
resourceOwnerSubject) {


Mime
View raw message