Class ReplayRejectingJwtValidator
java.lang.Object
com.irurueta.authserver.authorization.api.web.clientauth.ReplayRejectingJwtValidator
- All Implemented Interfaces:
org.springframework.security.oauth2.core.OAuth2TokenValidator<org.springframework.security.oauth2.jwt.Jwt>
public class ReplayRejectingJwtValidator
extends Object
implements org.springframework.security.oauth2.core.OAuth2TokenValidator<org.springframework.security.oauth2.jwt.Jwt>
Validates what the framework's default assertion validators leave out: the assertion must carry a
jti, an
iat no later than now (within the same clock skew the framework's timestamp validator allows) and an
exp no more than the configured maximum lifetime after it, so a future iat cannot stretch the
window, and its jti must not
have been used before by the same client (RFC 7523, section 3). The use is recorded last, only for an assertion
that passed the other checks, so a refused assertion never consumes its identifier. The record is made through
RegisterClientAssertionUseCase, so the replay protection is shared by every instance of the server.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClockSource of the current instant.private static final DurationClock skew tolerated foriat, the default of the framework'sJwtTimestampValidator.private static final StringDescription of the failures.private final ClientAssertionPropertiesSettings of the client assertions, for the longest lifetime.private final RegisterClientAssertionUseCaseRemembers the assertions that were accepted. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.springframework.security.oauth2.core.OAuth2TokenValidatorResultBuilds a failure.org.springframework.security.oauth2.core.OAuth2TokenValidatorResultvalidate(org.springframework.security.oauth2.jwt.Jwt jwt) Checks the assertion and records its use.
-
Field Details
-
DESCRIPTION_PREFIX
Description of the failures.- See Also:
-
CLOCK_SKEW
Clock skew tolerated foriat, the default of the framework'sJwtTimestampValidator. -
registerClientAssertion
Remembers the assertions that were accepted. -
properties
Settings of the client assertions, for the longest lifetime. -
clock
Source of the current instant.
-
-
Constructor Details
-
ReplayRejectingJwtValidator
public ReplayRejectingJwtValidator()
-
-
Method Details
-
validate
public org.springframework.security.oauth2.core.OAuth2TokenValidatorResult validate(org.springframework.security.oauth2.jwt.Jwt jwt) Checks the assertion and records its use.- Specified by:
validatein interfaceorg.springframework.security.oauth2.core.OAuth2TokenValidator<org.springframework.security.oauth2.jwt.Jwt>- Parameters:
jwt- the assertion, already verified for signature, issuer, subject, audience and expiry.- Returns:
- success, or a failure when the
jti,iatorexpis missing,iatis in the future, the lifetime is longer than allowed or thejtiwas already used.
-
failure
private static org.springframework.security.oauth2.core.OAuth2TokenValidatorResult failure(String reason) Builds a failure.- Parameters:
reason- what is wrong with the assertion.- Returns:
- the failed result.
-