private KeeperFile getFile(KeeperRecord record, Pattern filenamePattern) {

        List<KeeperFile> files = record.getFiles();
        if (files == null)
            return null;

        KeeperFile foundFile = null;
        for (KeeperFile file : files) {

            // Ignore files whose filenames do not match
            Matcher filenameMatcher = filenamePattern.matcher(file.getData().getName());
            if (!filenameMatcher.matches())
                continue;

            // Ignore ambiguous fields
            if (foundFile != null)
                return null;

            foundFile = file;

        }

        return foundFile;

    }
Returns the file attached to the give Keeper record whose filename
matches the given pattern. If there are no such files, or multiple such
files, null is returned.

@param record
    The record to retrieve the file from.

@param filenamePattern
    The pattern to match filenames against.

@return
    The single matching file attached to the given Keeper record, or
    null if there is not exactly one matching file.
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java