jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bae...@apache.org
Subject svn commit: r1574095 - in /jackrabbit/branches/2.6: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
Date Tue, 04 Mar 2014 13:21:12 GMT
Author: baedke
Date: Tue Mar  4 13:21:12 2014
New Revision: 1574095

URL: http://svn.apache.org/r1574095
Log:
JCR-3573: Improve token based login concurrency

Modified:
    jackrabbit/branches/2.6/   (props changed)
    jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java

Propchange: jackrabbit/branches/2.6/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1468965

Modified: jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java?rev=1574095&r1=1574094&r2=1574095&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
Tue Mar  4 13:21:12 2014
@@ -304,7 +304,7 @@ public class TokenBasedAuthentication im
      * specified user in the current workspace or if an error occurs while
      * creating the token node.
      */
-    public synchronized static Credentials createToken(User user, SimpleCredentials credentials,
+    public static Credentials createToken(User user, SimpleCredentials credentials,
                                                        long tokenExpiration, Session session)
throws RepositoryException {
         String workspaceName = session.getWorkspace().getName();
         if (user == null) {
@@ -320,11 +320,16 @@ public class TokenBasedAuthentication im
         if (userPath != null && session.nodeExists(userPath)) {
             Node userNode = session.getNode(userPath);
             Node tokenParent;
-            if (userNode.hasNode(TOKENS_NODE_NAME)) {
-                tokenParent = userNode.getNode(TOKENS_NODE_NAME);
-            } else {
-                tokenParent = userNode.addNode(TOKENS_NODE_NAME, TOKENS_NT_NAME);
+            if (!userNode.hasNode(TOKENS_NODE_NAME)) {
+                userNode.addNode(TOKENS_NODE_NAME, TOKENS_NT_NAME);
+                try {
+                    session.save();
+                } catch (RepositoryException e) {
+                    // may happen when .tokens node is created concurrently
+                    session.refresh(false);
+                }
             }
+            tokenParent = userNode.getNode(TOKENS_NODE_NAME);
 
             long creationTime = new Date().getTime();
             long expirationTime = creationTime + tokenExpiration;



Mime
View raw message