Package org.opensaml.saml.metadata.resolver.filter.impl

# Class NameIDFormatFilter

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.saml.metadata.resolver.filter.AbstractMetadataFilter
org.opensaml.saml.metadata.resolver.filter.impl.NameIDFormatFilter

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `MetadataFilter`

public class NameIDFormatFilter extends AbstractMetadataFilter
A filter that adds `NameIDFormat` content to entities in order to drive software behavior based on them. The entities to annotate are identified with a `Predicate`, and multiple formats can be associated with each.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Multimap<Predicate<EntityDescriptor>,String>`
`applyMap`
Rules for adding formats.
`private final SAMLObjectBuilder<NameIDFormat>`
`formatBuilder`
Builder for `NameIDFormat`.
`private static final String`
`GUARD_VALUE`
Used as a value in place of an empty collection when removing only.
`private final org.slf4j.Logger`
`log`
Class logger.
`private boolean`
`removeExistingFormats`
Whether to strip any existing Formats when adding new ones.

## Constructor Summary

Constructors
Constructor
Description
`NameIDFormatFilter()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`XMLObject`
`filter(XMLObject metadata, MetadataFilterContext context)`
Filters the given metadata, perhaps to remove elements that are not wanted.
`protected void`
`filterEntitiesDescriptor(EntitiesDescriptor descriptor)`
Filters entities descriptor.
`protected void`
`filterEntityDescriptor(EntityDescriptor descriptor)`
Filters entity descriptor.
`protected void`
`filterRoleDescriptor(RoleDescriptor role, Collection<String> formats)`
Filters role descriptor.
`void`
`setRemoveExistingFormats(boolean flag)`
Set whether the filter should remove any existing formats from an entity to which it adds new ones.
`void`
`setRules(Map<Predicate<EntityDescriptor>,Collection<String>> rules)`
Set the mappings from `Predicate` to format collection to apply.

### Methods inherited from class org.opensaml.saml.metadata.resolver.filter.AbstractMetadataFilter

`getType, setType`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### GUARD_VALUE

@Nonnull @NotEmpty private static final String GUARD_VALUE
Used as a value in place of an empty collection when removing only.

See Also:
  - Constant Field Values

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### removeExistingFormats

private boolean removeExistingFormats
Whether to strip any existing Formats when adding new ones.

### applyMap

@Nonnull private Multimap<Predicate<EntityDescriptor>,String> applyMap
Rules for adding formats.

### formatBuilder

@Nonnull private final SAMLObjectBuilder<NameIDFormat> formatBuilder
Builder for `NameIDFormat`.

## Constructor Details

### NameIDFormatFilter

public NameIDFormatFilter()
Constructor.

## Method Details

### setRemoveExistingFormats

public void setRemoveExistingFormats(boolean flag)
Set whether the filter should remove any existing formats from an entity to which it adds new ones.

Defaults to false (for compatibility).

Parameters:
  `flag` - flag to set

### setRules

public void setRules(@Nonnull Map<Predicate<EntityDescriptor>,Collection<String>> rules)
Set the mappings from `Predicate` to format collection to apply.

Parameters:
  `rules` - rules to apply

### filter

@Nullable public XMLObject filter(@Nullable XMLObject metadata, @Nonnull MetadataFilterContext context) throws FilterException
Filters the given metadata, perhaps to remove elements that are not wanted.

Parameters:
  `metadata` - the metadata to be filtered.
  `context` - the metadata filter context
Returns:
  the filtered XMLObject, which may or may not be the same as the XMLObject instance passed in to the method. Maybe be null, for example if the top-level element was removed by the filter.
Throws:
  `FilterException` - thrown if an error occurs during the filtering process

### filterEntityDescriptor

protected void filterEntityDescriptor(@Nonnull EntityDescriptor descriptor)
Filters entity descriptor.

Parameters:
  `descriptor` - entity descriptor to filter

### filterRoleDescriptor

protected void filterRoleDescriptor(@Nonnull RoleDescriptor role, @Nonnull Collection<String> formats)
Filters role descriptor.

Parameters:
  `role` - role to modify
  `formats` - formats to attach

### filterEntitiesDescriptor

protected void filterEntitiesDescriptor(@Nonnull EntitiesDescriptor descriptor)
Filters entities descriptor.

Parameters:
  `descriptor` - entities descriptor to filter