private void addRecordTokens(Map<String, Future<String>> tokens, String prefix,
            KeeperRecord record) throws GuacamoleException {

        if (record == null)
            return;

        // Domain of server-related record
        String domain = recordService.getDomain(record);
        if (domain != null)
            tokens.put(prefix + "DOMAIN", CompletableFuture.completedFuture(domain));

        // Username of server-related record
        String username = recordService.getUsername(record);
        if (username != null) {

            // If the record had no directly defined domain, but there is a
            // username, and the configuration is enabled to split Windows
            // domains out of usernames, attempt to split the domain out now
            if (domain == null && confService.getSplitWindowsUsernames()) {
                WindowsUsername usernameAndDomain =
                        WindowsUsername.splitWindowsUsernameFromDomain(username);

                // Always store the username token
                tokens.put(prefix + "USERNAME", CompletableFuture.completedFuture(
                        usernameAndDomain.getUsername()));

                // Only store the domain if one is detected
                if (usernameAndDomain.hasDomain())
                    tokens.put(prefix + "DOMAIN", CompletableFuture.completedFuture(
                        usernameAndDomain.getDomain()));

            }

            // If splitting is not enabled, store the whole value in the USERNAME token
            else {
                tokens.put(prefix + "USERNAME", CompletableFuture.completedFuture(username));
            }
        }

        // Password of server-related record
        String password = recordService.getPassword(record);
        if (password != null)
            tokens.put(prefix + "PASSWORD", CompletableFuture.completedFuture(password));

        // Key passphrase of server-related record
        String passphrase = recordService.getPassphrase(record);
        if (passphrase != null)
            tokens.put(prefix + "PASSPHRASE", CompletableFuture.completedFuture(passphrase));

        // Private key of server-related record
        Future<String> privateKey = recordService.getPrivateKey(record);
        tokens.put(prefix + "KEY", privateKey);

    }
Adds contextual parameter tokens for the secrets in the given record to
the given map of existing tokens. The values of each token are
determined from secrets within the record. Depending on the record, this
will be a subset of the username, password, private key, and passphrase.

@param tokens
    The map of parameter tokens that any new tokens should be added to.

@param prefix
    The prefix that should be prepended to each added token.

@param record
    The record to retrieve secrets from when generating tokens. This may
    be null.

@throws GuacamoleException
    If configuration details in guacamole.properties cannot be parsed.
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmSecretService.java