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 JPACodeDataProvider
Date Thu, 21 Apr 2016 12:12:02 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 2d84f4043 -> d1687e70d


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

Branch: refs/heads/3.1.x-fixes
Commit: d1687e70dc8b0e8571cc7dfebbd173ec1ccb1c32
Parents: 2d84f40
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:11:39 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/d1687e70/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