Package net.shibboleth.idp.saml.metadata.impl

# Class ScopeFilter

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

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

public class ScopeFilter extends AbstractMetadataFilter
A filter that adds the `Scope` extension to entities in order to drive software behavior based on them.

The entities to annotate are identified with a `Predicate`, and multiple scopes can be associated with each, with and without the regexp flag.

Note that this filter only operates on extensions defined at the `EntityDescriptor` level. When removing existing extensions, it will strip any found at both the top level and on each role.

Since:
  5.2.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private Multimap<Predicate<EntityDescriptor>,Scope>`
`applyMap`
Rules for adding scopes.
`private final SAMLObjectBuilder<Extensions>`
`extBuilder`
Builder for `Extensions`.
`private static final String`
`GUARD_VALUE`
Used as a value in place of an empty collection when removing only.
`private final Scope`
`guardObject`
Stand-in value for an empty collection.
`private final org.slf4j.Logger`
`log`
Class logger.
`private boolean`
`removeExistingScopes`
Whether to strip any existing Scopes when adding new ones.

## Constructor Summary

Constructors
Constructor
Description
`ScopeFilter()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`XMLObject`
`filter(XMLObject metadata, MetadataFilterContext context)`
`protected void`
`filterEntitiesDescriptor(EntitiesDescriptor descriptor)`
Filters entities descriptor.
`protected void`
`filterEntityDescriptor(EntityDescriptor descriptor)`
Filters entity descriptor.
`protected void`
`filterRoleDescriptor(RoleDescriptor role)`
Filters role descriptor to remove extensions.
`void`
`setRemoveExistingScopes(boolean flag)`
Set whether the filter should remove any existing scopes from an entity.
`void`
`setRules(Map<Predicate<EntityDescriptor>,Collection<Scope>> rules)`
Set the mappings from `Predicate` to Scope 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.

### guardObject

@Nonnull private final Scope guardObject
Stand-in value for an empty collection.

### removeExistingScopes

private boolean removeExistingScopes
Whether to strip any existing Scopes when adding new ones.

### applyMap

@Nonnull private Multimap<Predicate<EntityDescriptor>,Scope> applyMap
Rules for adding scopes.

### extBuilder

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

## Constructor Details

### ScopeFilter

public ScopeFilter()
Constructor.

## Method Details

### setRemoveExistingScopes

public void setRemoveExistingScopes(boolean flag)
Set whether the filter should remove any existing scopes from an entity.

Defaults to false (for compatibility).

Parameters:
  `flag` - flag to set

### setRules

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

Parameters:
  `rules` - rules to apply

### filter

@Nullable public XMLObject filter(@Nullable XMLObject metadata, @Nonnull MetadataFilterContext context) throws FilterException

Throws:
  `FilterException`

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

### filterRoleDescriptor

protected void filterRoleDescriptor(@Nonnull RoleDescriptor role)
Filters role descriptor to remove extensions.

Parameters:
  `role` - role descriptor to filter