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

# Class EntityAttributesFilter

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

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

public class EntityAttributesFilter extends AbstractMetadataFilter
A filter that adds `EntityAttributes` extension content to entities in order to drive software behavior based on them.

The entities to annotate are identified with a `Predicate`, and multiple attributes can be associated with each.

As of 3.4.0, another predicate can be set to validate pre-existing extension content to better protect use cases of this component.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Multimap<Predicate<EntityDescriptor>,Attribute>`
`applyMap`
Rules for adding attributes.
`private Predicate<Attribute>`
`attributeFilter`
A condition to apply to pre-existing tags to determine their legitimacy.
`private final SAMLObjectBuilder<EntityAttributes>`
`entityAttributesBuilder`
Builder for `EntityAttributes`.
`private final SAMLObjectBuilder<Extensions>`
`extBuilder`
Builder for `Extensions`.
`private final org.slf4j.Logger`
`log`
Class logger.

## Constructor Summary

Constructors
Constructor
Description
`EntityAttributesFilter()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private void`
`addEntityAttribute(EntityDescriptor descriptor, EntityAttributes container, Attribute input)`
Get or create `Attribute` based on the input/template object.
`private void`
`applyFilter(EntityDescriptor descriptor)`
Apply include policy to metadata on input.
`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.
`void`
`setAttributeFilter(Predicate<Attribute> condition)`
Set a condition to apply to any pre-existing extension attributes, such that failure causes their removal.
`void`
`setRules(Map<Predicate<EntityDescriptor>,Collection<Attribute>> rules)`
Set the mappings from `Predicate` to `Attribute` 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

### log

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

### applyMap

@Nonnull private Multimap<Predicate<EntityDescriptor>,Attribute> applyMap
Rules for adding attributes.

### attributeFilter

@Nullable private Predicate<Attribute> attributeFilter
A condition to apply to pre-existing tags to determine their legitimacy.

### extBuilder

@Nonnull private final SAMLObjectBuilder<Extensions> extBuilder
Builder for `Extensions`.

### entityAttributesBuilder

@Nonnull private final SAMLObjectBuilder<EntityAttributes> entityAttributesBuilder
Builder for `EntityAttributes`.

## Constructor Details

### EntityAttributesFilter

public EntityAttributesFilter()
Constructor.

## Method Details

### setRules

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

Parameters:
  `rules` - rules to apply

### setAttributeFilter

public void setAttributeFilter(@Nullable Predicate<Attribute> condition)
Set a condition to apply to any pre-existing extension attributes, such that failure causes their removal.

If not set, then anything is allowed.

Parameters:
  `condition` - condition to apply
Since:
  3.4.0

### 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

### filterEntitiesDescriptor

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

Parameters:
  `descriptor` - entities descriptor to filter

### addEntityAttribute

private void addEntityAttribute(@Nonnull EntityDescriptor descriptor, @Nonnull EntityAttributes container, @Nonnull Attribute input)
Get or create `Attribute` based on the input/template object.

Parameters:
  `descriptor` - parent entity
  `container` - extension container
  `input` - input object

### applyFilter

private void applyFilter(@Nonnull EntityDescriptor descriptor)
Apply include policy to metadata on input.

Parameters:
  `descriptor` - input to evaluate