Index: ../oak/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../oak/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java	(revision 1585664)
+++ ../oak/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java	(revision )
@@ -29,6 +29,7 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.AccessDeniedException;
@@ -210,11 +211,7 @@
         if (tokenParent != null) {
             try {
                 long creationTime = new Date().getTime();
-                Calendar creation = GregorianCalendar.getInstance();
-                creation.setTimeInMillis(creationTime);
-                String tokenName = Text.replace(ISO8601.format(creation), ":", ".");
-
-                NodeUtil tokenNode = tokenParent.addChild(tokenName, TOKEN_NT_NAME);
+                NodeUtil tokenNode = createTokenNode(tokenParent, creationTime);
                 tokenNode.setString(JcrConstants.JCR_UUID, IdentifierManager.generateUUID());
 
                 String key = generateKey(options.getConfigValue(PARAM_TOKEN_LENGTH, DEFAULT_KEY_SIZE));
@@ -289,6 +286,25 @@
 
     private static long getExpirationTime(NodeUtil tokenNode, long defaultValue) {
         return tokenNode.getLong(TOKEN_ATTRIBUTE_EXPIRY, defaultValue);
+    }
+
+    /**
+     * Create a new token node below the specified {@code parent}.
+     *
+     * @param parent The parent node.
+     * @param creationTime The creation time that is used as name hint.
+     * @return The new token node
+     * @throws AccessDeniedException
+     */
+    private static NodeUtil createTokenNode(@Nonnull NodeUtil parent, @Nonnull long creationTime) throws AccessDeniedException {
+        Calendar creation = GregorianCalendar.getInstance();
+        creation.setTimeInMillis(creationTime);
+        String tokenName = Text.replace(ISO8601.format(creation), ":", ".");
+        if (parent.hasChild(tokenName)) {
+            log.debug("Token node with name " + tokenName + " already exists -> Using random name instead.");
+            tokenName = UUID.randomUUID().toString();
+        }
+        return parent.addChild(tokenName, TOKEN_NT_NAME);
     }
 
     @CheckForNull
