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

# Class RequiredValidUntilFilter

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

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

public class RequiredValidUntilFilter extends AbstractMetadataFilter
A metadata filter that requires the presence of a `validUntil` attribute on the root element of the metadata document. It can optionally enforce that the validity period (now minus `validUntil` date) is not longer than a specified amount. A maximum validity interval of less than 1 means that no restriction is placed on the metadata's `validUntil` attribute.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.
`private Duration`
`maxValidityInterval`
The maximum interval between now and the `validUntil` date.

## Constructor Summary

Constructors
Constructor
Description
`RequiredValidUntilFilter()`
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.
`Duration`
`getMaxValidityInterval()`
Get the maximum interval between now and the `validUntil` date.
`protected Instant`
`getValidUntil(XMLObject metadata)`
Gets the validUntil time of the metadata, if present.
`void`
`setMaxValidityInterval(Duration validity)`
Set the maximum interval between now and the `validUntil` date.

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

### maxValidityInterval

@Nullable private Duration maxValidityInterval
The maximum interval between now and the `validUntil` date. Defaults to 14 days.

## Constructor Details

### RequiredValidUntilFilter

public RequiredValidUntilFilter()
Constructor.

## Method Details

### getMaxValidityInterval

@Nullable public Duration getMaxValidityInterval()
Get the maximum interval between now and the `validUntil` date. A value <=0 indicates that there is no restriction.

Returns:
  maximum interval between now and the `validUntil` date

### setMaxValidityInterval

public void setMaxValidityInterval(@Nullable Duration validity)
Set the maximum interval between now and the `validUntil` date. A value <=0 indicates that there is no restriction.

Parameters:
  `validity` - time between now and the `validUntil` date

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

### getValidUntil

@Nullable protected Instant getValidUntil(@Nonnull XMLObject metadata) throws FilterException
Gets the validUntil time of the metadata, if present.

Parameters:
  `metadata` - metadata from which to get the validUntil instant
Returns:
  the valid until instant or null if it is not present
Throws:
  `FilterException` - thrown if the given XML object is not an `EntitiesDescriptor` or `EntityDescriptor`