void saveTokens()

in src/main/java/org/apache/sling/auth/saml2/impl/TokenStore.java [288:314]


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