Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 604F610019 for ; Tue, 4 Mar 2014 13:21:46 +0000 (UTC) Received: (qmail 6413 invoked by uid 500); 4 Mar 2014 13:21:45 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 6293 invoked by uid 500); 4 Mar 2014 13:21:38 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 6271 invoked by uid 99); 4 Mar 2014 13:21:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2014 13:21:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2014 13:21:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DBEDB23889DA; Tue, 4 Mar 2014 13:21:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: baedke@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140304132112.DBEDB23889DA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;