private void saveTokens()

in src/main/java/org/apache/sling/auth/form/impl/TokenStore.java [292:320]


    private void saveTokens() {
            File parent = tokenFile.getAbsoluteFile().getParentFile();
            log.info("Token File {} parent {} ", tokenFile, parent);
            if (!parent.exists()) {
                parent.mkdirs();
            }
        try (DataOutputStream keyOutputStream = new DataOutputStream(new FileOutputStream(tmpTokenFile))) {
            keyOutputStream.writeInt(currentToken);
            keyOutputStream.writeLong(nextUpdate);
            for (int i = 0; i < currentTokens.length(); i++) {
                if (currentTokens.get(i) == null) {
                    keyOutputStream.writeInt(0);
                } else {
                    keyOutputStream.writeInt(1);
                    byte[] b = currentTokens.get(i).getEncoded();
                    keyOutputStream.writeInt(b.length);
                    keyOutputStream.write(b);
                }
            }
        } catch (IOException e) {
            log.error("Failed to save cookie keys {}", e.getMessage());
        }

        try {
            Files.move(tmpTokenFile.toPath(), tokenFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException e) {
            log.error("Failed to rename the temporary token file", e);
        }
    }