jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1468965 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
Date Wed, 17 Apr 2013 15:19:57 GMT
Author: mreutegg
Date: Wed Apr 17 15:19:57 2013
New Revision: 1468965

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

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java?rev=1468965&r1=1468964&r2=1468965&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedAuthentication.java
Wed Apr 17 15:19:57 2013
@@ -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