cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: Minor update to JPACodeDataProvider
Date Thu, 21 Apr 2016 12:10:31 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5b740ccf9 -> 39754b7da


Minor update to JPACodeDataProvider


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

Branch: refs/heads/master
Commit: d5d9c6c55d26d0e60f13240312f2c39b0481320d
Parents: ea6a524
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Apr 21 13:09:42 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Apr 21 13:09:42 2016 +0100

----------------------------------------------------------------------
 .../oauth2/grants/code/JPACodeDataProvider.java         | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d5d9c6c5/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java
index c122f34..d6d759c 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACodeDataProvider.java
@@ -44,7 +44,17 @@ public class JPACodeDataProvider extends JPAOAuthDataProvider implements
Authori
     }
 
     protected void saveCodeGrant(ServerAuthorizationCodeGrant grant) { 
-        persistEntity(grant);
+        getEntityManager().getTransaction().begin();
+        if (grant.getSubject() != null) {
+            UserSubject sub = getEntityManager().find(UserSubject.class, grant.getSubject().getLogin());
+            if (sub == null) {
+                getEntityManager().persist(grant.getSubject());
+            } else {
+                grant.setSubject(sub);
+            }
+        }
+        getEntityManager().persist(grant);
+        getEntityManager().getTransaction().commit();
     }
     
     @Override


Mime
View raw message