public Map<String, String> filterAttributes(Collection<Form> schema,
            Map<String, String> attributes) {

        Map<String, String> filtered = new HashMap<String, String>();

        // Grab all attribute value strictly for defined fields
        for (Form form : schema) {
            for (Field field : form.getFields()) {

                // Pull the associated attribute value from given map
                String attributeName = field.getName();
                String attributeValue = attributes.get(attributeName);

                // Include attribute value within filtered map only if
                // defined or present within provided map
                if (attributeValue != null || 
                        attributes.containsKey(attributeName))
                    filtered.put(attributeName, attributeValue);

            }
        }

        return filtered;

    }
Filters the given map of attribute name/value pairs, producing a new
map containing only attributes defined as fields within the given schema.

@param schema
    The schema whose fields should be used to filter the given map of
    attributes.

@param attributes
    The map of attribute name/value pairs to filter.

@return
    A new map containing only the attributes defined as fields within
    the given schema.
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectTranslator.java