Package net.shibboleth.profile.context.logic

# Class DateAttributePredicate

java.lang.Object
net.shibboleth.profile.context.logic.AbstractAttributePredicate
net.shibboleth.profile.context.logic.DateAttributePredicate

All Implemented Interfaces:
  `Predicate<ProfileRequestContext>`

public class DateAttributePredicate extends AbstractAttributePredicate
Provides a date/time matching predicate that compares a date-based attribute value against current system time with optional offset. By convention the predicate returns true if and only if the date represented by the attribute value is after the current system time; false otherwise. Thus the semantics are well-suited for cases such as evaluation of expiration dates.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final String`
`attributeName`
Name of attribute to query for.
`private final DateTimeFormatter`
`dateTimeFormatter`
Formatter used to parse string-based date attribute values.
`private final org.slf4j.Logger`
`log`
Class logger.
`private boolean`
`resultIfMissing`
Result of predicate if attribute is missing or has no values.
`private Duration`
`systemTimeOffset`
Offset from system time used for date comparisons.

## Constructor Summary

Constructors
Constructor
Description
`DateAttributePredicate(String attribute)`
Create a new instance that performs date comparisons against the given attribute.
`DateAttributePredicate(String attribute, String formatString)`
Create a new instance that performs date comparisons against the given attribute using the given date parser.
`DateAttributePredicate(String attribute, DateTimeFormatter formatter)`
Create a new instance that performs date comparisons against the given attribute using the given date parser.

## Method Summary

Modifier and Type
Method
Description
`protected boolean`
`allowNullAttributeContext()`
Get the result of the predicate in the case the attribute context is null.
`protected boolean`
`hasMatch(Map<String,IdPAttribute> attributeMap)`
Abstract implementation of the condition to evaluate.
`void`
`setOffset(Duration offset)`
Set the system time offset, which affects the reference date for comparisons.
`void`
`setResultIfMissing(boolean flag)`
Set the result to return if the attribute to check is missing or has no values.

### Methods inherited from class net.shibboleth.profile.context.logic.AbstractAttributePredicate

`getAttributeContextLookupStrategy, isUseUnfilteredAttributes, setAttributeContextLookupStrategy, setUseUnfilteredAttributes, test`

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

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

### Methods inherited from interface java.util.function.Predicate

`and, negate, or`

## Field Details

### log

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

### attributeName

@Nonnull @NotEmpty private final String attributeName
Name of attribute to query for.

### dateTimeFormatter

@Nullable private final DateTimeFormatter dateTimeFormatter
Formatter used to parse string-based date attribute values.

### systemTimeOffset

@Nonnull private Duration systemTimeOffset
Offset from system time used for date comparisons.

### resultIfMissing

private boolean resultIfMissing
Result of predicate if attribute is missing or has no values.

## Constructor Details

### DateAttributePredicate

public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") String attribute)
Create a new instance that performs date comparisons against the given attribute.

Parameters:
  `attribute` - Attribute name that provides candidate date values to test.

### DateAttributePredicate

public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") String attribute, @Nonnull @ParameterName(name="formatter") DateTimeFormatter formatter)
Create a new instance that performs date comparisons against the given attribute using the given date parser.

Parameters:
  `attribute` - Attribute name that provides candidate date values to test.
  `formatter` - Date/time parser.

### DateAttributePredicate

public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") String attribute, @Nonnull @NotEmpty @ParameterName(name="formatString") String formatString)
Create a new instance that performs date comparisons against the given attribute using the given date parser.

Parameters:
  `attribute` - Attribute name that provides candidate date values to test.
  `formatString` - date/time parsing string, currently based on `DateTimeFormatter`

## Method Details

### setOffset

public void setOffset(@Nonnull Duration offset)
Set the system time offset, which affects the reference date for comparisons.

By default all comparisons are against system time, i.e. zero offset.

Parameters:
  `offset` - System time offset. A negative value decreases the target date (sooner); a positive value increases the target date (later).

### setResultIfMissing

public void setResultIfMissing(boolean flag)
Set the result to return if the attribute to check is missing or has no values.

Parameters:
  `flag` - flag to set

### allowNullAttributeContext

protected boolean allowNullAttributeContext()
Get the result of the predicate in the case the attribute context is null.

Defaults to false unless overridden by a subclass.

Overrides:
  `allowNullAttributeContext` in class `AbstractAttributePredicate`
Returns:
  null context result

### hasMatch

protected boolean hasMatch(@Nonnull Map<String,IdPAttribute> attributeMap)
Abstract implementation of the condition to evaluate.

Specified by:
  `hasMatch` in class `AbstractAttributePredicate`
Parameters:
  `attributeMap` - the attributes to evaluate
Returns:
  the condition result