public String getUsername(KeeperRecord record) {

        // Prefer standard login field
        Login loginField = getField(record, Login.class, null);
        if (loginField != null)
            return getSingleStringValue(loginField.getValue());

        KeeperRecordData data = record.getData();
        List<KeeperRecordField> custom = data.getCustom();

        // Use text "username" custom field as fallback ...
        Text textField = getField(custom, Text.class, USERNAME_LABEL_PATTERN);
        if (textField != null)
            return getSingleStringValue(textField.getValue());

        // ... or hidden "username" custom field
        HiddenField hiddenField = getField(custom, HiddenField.class, USERNAME_LABEL_PATTERN);
        if (hiddenField != null)
            return getSingleStringValue(hiddenField.getValue());

        return null;

    }
Returns the single username associated with the given record. If the
record has no associated username, or multiple usernames, null is
returned. Usernames are retrieved from "Login" fields, as well as
"Text" and "Hidden" fields that have the label "username"
(case-insensitive).

@param record
    The record to retrieve the username from.

@return
    The username associated with the given record, or null if the record
    has no associated username or multiple usernames.
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java