Class AbstractAssertionIDReplayValidator
java.lang.Object
org.opensaml.saml.saml2.assertion.impl.AbstractAssertionIDReplayValidator
- Direct Known Subclasses:
AssertionReplayValidator,OneTimeUseConditionValidator
An abstract class for validators that enforce that an Assertion ID is not replayed/reused.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.slf4j.LoggerLogger.private final ReplayCacheReplay cache used to track which assertions have been used.private final DurationTime for disposal of value from cache. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAssertionIDReplayValidator(ReplayCache replay, Duration expires) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleandoValidate(Assertion assertion, ValidationContext context) Evaluate an Assertion for replay.protected abstract StringGet the cache context used with the replay cache.protected StringgetCacheValue(Assertion assertion) Get the string value which will be tracked in the cache for purposes of replay detection.protected abstract StringGet the optional validation context param name to use for the per-validation expirationprotected InstantgetExpires(Assertion assertion, ValidationContext context) Get the replay cache expiration time for the assertion being evaluated.protected DurationGet the configured validator cache expiration interval.
-
Field Details
-
log
@Nonnull private org.slf4j.Logger logLogger. -
replayCache
Replay cache used to track which assertions have been used. -
replayCacheExpires
Time for disposal of value from cache.
-
-
Constructor Details
-
AbstractAssertionIDReplayValidator
Constructor.- Parameters:
replay- reply cache used to track which assertions have been usedexpires- time for disposal of tracked assertion from the replay cache. May be null, then defaults to 8 hours
-
-
Method Details
-
getReplayCacheExpires
Get the configured validator cache expiration interval.- Returns:
- the configured cache expiration interval
-
getCacheContext
Get the cache context used with the replay cache.- Returns:
- the cache context
-
getExpirationParameterName
Get the optional validation context param name to use for the per-validation expirationThis is the name of the parameter in the supplied
ValidationContextwhich holds an optionalDurationvalue.- Returns:
- param name, or null
-
doValidate
protected boolean doValidate(@Nonnull Assertion assertion, @Nonnull ValidationContext context) throws AssertionValidationException Evaluate an Assertion for replay.- Parameters:
assertion- the assertion to evaluatecontext- the current validation contexxt- Returns:
- false if replay detected, true if not
- Throws:
AssertionValidationException- if there is a fatal error evaluating the Assertion
-
getExpires
@Nonnull protected Instant getExpires(@Nonnull Assertion assertion, @Nonnull ValidationContext context) Get the replay cache expiration time for the assertion being evaluated.Defaults to
Instant.now().plus(getReplayCacheExpires()).A subclass might override this to base expiration on data from the assertion or the validation context.
- Parameters:
assertion- the SAML 2 Assertion being evaluatedcontext- the current validation context- Returns:
- the effective expiration for the assertion being evaluated
-
getCacheValue
@Nonnull protected String getCacheValue(@Nonnull Assertion assertion) throws AssertionValidationException Get the string value which will be tracked in the cache for purposes of replay detection.- Parameters:
assertion- the SAML 2 Assertion to evaluate- Returns:
- the cache value
- Throws:
AssertionValidationException- thrown if there is a problem calculating the cached value
-