code: private void prepareTokenFile(final String user,
        final Credentials credentials,
        final File tokenFile,
        final Logger logger) throws IOException {
      writeCredentialsToFile(credentials, tokenFile, logger);
      try {
        assignPermissions(user, tokenFile, logger);
      } catch (final IOException e) {
        // On any error managing token file. delete the file
        tokenFile.delete();
        throw e;
      }
    }
docs: Prepare token file. Writes credentials to a token file and sets appropriate permissions to keep
  the file secure
  
  @param user user to be proxied
  @param credentials Credentials to be written to file
  @param tokenFile file to be written
  @param logger logger to use
  @throws IOException If there are issues in reading / updating the token file