public static WindowsUsername splitWindowsUsernameFromDomain(String vaultField) {

        // If it's the down-level logon format, return the extracted username and domain
        Matcher downLevelLogonMatcher = DOWN_LEVEL_LOGON_NAME_PATTERN.matcher(vaultField);
        if (downLevelLogonMatcher.matches())
            return new WindowsUsername(
                    downLevelLogonMatcher.group("username"),
                    downLevelLogonMatcher.group("domain"));

        // If it's the user principal format, return the extracted username and domain
        Matcher userPrincipalMatcher = USER_PRINCIPAL_NAME_PATTERN.matcher(vaultField);
        if (userPrincipalMatcher.matches())
            return new WindowsUsername(
                    userPrincipalMatcher.group("username"),
                    userPrincipalMatcher.group("domain"));

        // If none of the expected formats matched, return the username with do domain
        return new WindowsUsername(vaultField);

    }
Strip off a Windows domain from the provided username, if one is
present. For example: "DOMAIN\\user" or "user@DOMAIN" will both
be stripped to just "user". Note: neither the '@' or '\\' characters
are valid in Windows usernames.

@param vaultField
    The raw field value as retrieved from the vault. This might contain
    a Windows domain.

@return
    The provided username with the Windows domain stripped off, if one
    is present.
extensions/guacamole-vault/modules/guacamole-vault-base/src/main/java/org/apache/guacamole/vault/secret/WindowsUsername.java