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

# Class AlgorithmFilter

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

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

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

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

## Field Summary

Fields
Modifier and Type
Field
Description
`private Multimap<Predicate<EntityDescriptor>,XMLObject>`
`applyMap`
Rules for adding algorithms.
`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 XSString`
`guardObject`
Stands in for an empty collection when removing only.
`private final org.slf4j.Logger`
`log`
Class logger.
`private AlgorithmRegistry`
`registry`
Registry for sanity checking algorithms.
`private boolean`
`removeExistingDigestMethods`
Flag controlling removal of existing DigestMethod extensions.
`private boolean`
`removeExistingEncryptionMethods`
Flag controlling removal of existing EncryptionMethod extensions.
`private boolean`
`removeExistingSigningMethods`
Flag controlling removal of existing SigningMethod extensions.

## Constructor Summary

Constructors
Constructor
Description
`AlgorithmFilter()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addEncryptionMethod(EntityDescriptor descriptor, EncryptionMethod encryptionMethod)`
Add `EncryptionMethod` extension to every `KeyDescriptor` found in an entity.
`private void`
`checkDigestMethod(String uri)`
Check the input method for "known" and "supported" status for logging purposes.
`private void`
`checkEncryptionMethod(String uri)`
Check the input method for "known" and "supported" status for logging purposes.
`private void`
`checkSigningMethod(String uri)`
Check the input method for "known" and "supported" status for logging purposes.
`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 Extensions`
`getExtensions(EntityDescriptor descriptor)`
Return existing `Extensions` object or create it first.
`protected void`
`removeExistingMethods(EntityDescriptor descriptor)`
Performs removal of existing methods if directed.
`void`
`setRemoveExistingDigestMethods(boolean flag)`
Sets whether to remove existing DigestMethod extensions.
`void`
`setRemoveExistingEncryptionMethods(boolean flag)`
Sets whether to remove existing EncryptionMethod extensions.
`void`
`setRemoveExistingSigningMethods(boolean flag)`
Sets whether to remove existing SigningMethod extensions.
`void`
`setRules(Map<Predicate<EntityDescriptor>,Collection<XMLObject>> rules)`
Set the mappings from `Predicate` to extensions of various types 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.

### registry

@Nullable private AlgorithmRegistry registry
Registry for sanity checking algorithms.

### removeExistingDigestMethods

private boolean removeExistingDigestMethods
Flag controlling removal of existing DigestMethod extensions.

### removeExistingSigningMethods

private boolean removeExistingSigningMethods
Flag controlling removal of existing SigningMethod extensions.

### removeExistingEncryptionMethods

private boolean removeExistingEncryptionMethods
Flag controlling removal of existing EncryptionMethod extensions.

### applyMap

@Nonnull private Multimap<Predicate<EntityDescriptor>,XMLObject> applyMap
Rules for adding algorithms.

### extBuilder

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

### guardObject

@Nonnull private final XSString guardObject
Stands in for an empty collection when removing only.

## Constructor Details

### AlgorithmFilter

public AlgorithmFilter()
Constructor.

## Method Details

### setRemoveExistingDigestMethods

public void setRemoveExistingDigestMethods(boolean flag)
Sets whether to remove existing DigestMethod extensions.

Parameters:
  `flag` - flag to set

### setRemoveExistingSigningMethods

public void setRemoveExistingSigningMethods(boolean flag)
Sets whether to remove existing SigningMethod extensions.

Parameters:
  `flag` - flag to set

### setRemoveExistingEncryptionMethods

public void setRemoveExistingEncryptionMethods(boolean flag)
Sets whether to remove existing EncryptionMethod extensions.

Parameters:
  `flag` - flag to set

### setRules

public void setRules(@Nonnull Map<Predicate<EntityDescriptor>,Collection<XMLObject>> rules)
Set the mappings from `Predicate` to extensions of various types 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

### filterEntitiesDescriptor

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

Parameters:
  `descriptor` - entities descriptor to filter

### getExtensions

@Nonnull protected Extensions getExtensions(@Nonnull EntityDescriptor descriptor)
Return existing `Extensions` object or create it first.

Parameters:
  `descriptor` - the surrounding entity
Returns:
  new or existing extension block

### removeExistingMethods

protected void removeExistingMethods(@Nonnull EntityDescriptor descriptor)
Performs removal of existing methods if directed.

Parameters:
  `descriptor` - descriptor to filter

### addEncryptionMethod

protected void addEncryptionMethod(@Nonnull EntityDescriptor descriptor, @Nonnull EncryptionMethod encryptionMethod)
Add `EncryptionMethod` extension to every `KeyDescriptor` found in an entity.

Parameters:
  `descriptor` - the entity to modify
  `encryptionMethod` - extension to add

### checkDigestMethod

private void checkDigestMethod(@Nullable @NotEmpty String uri)
Check the input method for "known" and "supported" status for logging purposes.

Parameters:
  `uri` - input method

### checkSigningMethod

private void checkSigningMethod(@Nullable @NotEmpty String uri)
Check the input method for "known" and "supported" status for logging purposes.

Parameters:
  `uri` - input method

### checkEncryptionMethod

private void checkEncryptionMethod(@Nullable @NotEmpty String uri)
Check the input method for "known" and "supported" status for logging purposes.

Parameters:
  `uri` - input method