Package net.shibboleth.idp.profile.logic
Class DateAttributePredicate
- java.lang.Object
-
- net.shibboleth.idp.profile.logic.AbstractAttributePredicate
-
- net.shibboleth.idp.profile.logic.DateAttributePredicate
-
- All Implemented Interfaces:
Predicate<org.opensaml.profile.context.ProfileRequestContext>,net.shibboleth.utilities.java.support.logic.Predicate<org.opensaml.profile.context.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 StringattributeNameName of attribute to query for.private DateTimeFormatterdateTimeFormatterFormatter used to parse string-based date attribute values.private DateTimeFormatterlegacyFormatterDeprecated.private org.slf4j.LoggerlogClass logger.private booleanresultIfMissingResult of predicate if attribute is missing or has no values.private DurationsystemTimeOffsetOffset from system time used for date comparisons.
-
Constructor Summary
Constructors Constructor Description DateAttributePredicate(String attribute)Deprecated.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.DateAttributePredicate(String attribute, DateTimeFormatter formatter)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleanallowNullAttributeContext()Get the result of the predicate in the case the attribute context is null.protected booleanhasMatch(Map<String,net.shibboleth.idp.attribute.IdPAttribute> attributeMap)Abstract implementation of the condition to evaluate.voidsetOffset(Duration offset)Set the system time offset, which affects the reference date for comparisons.voidsetResultIfMissing(boolean flag)Set the result to return if the attribute to check is missing or has no values.voidsetSystemTimeOffset(Duration offset)Deprecated.-
Methods inherited from class net.shibboleth.idp.profile.logic.AbstractAttributePredicate
getAttributeContextLookupStrategy, isUseUnfilteredAttributes, setAttributeContextLookupStrategy, setUseUnfilteredAttributes, test
-
-
-
-
Field Detail
-
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 DateTimeFormatter dateTimeFormatter
Formatter used to parse string-based date attribute values.
-
legacyFormatter
@Deprecated @Nullable private DateTimeFormatter legacyFormatter
Deprecated.Legacy 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 Detail
-
DateAttributePredicate
@Deprecated public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") String attribute)
Deprecated.Create a new instance that performs date comparisons against the given attribute using ISO date/time format parser by default.This is deprecated in favor of the Java 8 API version.
- Parameters:
attribute- Attribute name that provides candidate date values to test.
-
DateAttributePredicate
@Deprecated public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") String attribute, @Nonnull @ParameterName(name="formatter") DateTimeFormatter formatter)
Deprecated.Create a new instance that performs date comparisons against the given attribute using the given date parser.This is deprecated in favor of the Java 8 API version.
- 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 @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 onDateTimeFormatter
-
-
Method Detail
-
setSystemTimeOffset
@Deprecated public void setSystemTimeOffset(@Nonnull Duration offset)
Deprecated.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).
-
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.- Overrides:
allowNullAttributeContextin classAbstractAttributePredicate- Returns:
- null context result
-
hasMatch
protected boolean hasMatch(@Nonnull @NonnullElements Map<String,net.shibboleth.idp.attribute.IdPAttribute> attributeMap)Abstract implementation of the condition to evaluate.- Specified by:
hasMatchin classAbstractAttributePredicate- Parameters:
attributeMap- the attributes to evaluate- Returns:
- the condition result
-
-