/// <inheritdoc /> public TokenValidationResult TryValidate(Jwt jwt) { if (jwt is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.jwt); } if (jwt.Payload is null) { return(TokenValidationResult.MalformedToken()); } var claim = jwt.Payload[_claim]; if (claim is null) { return(TokenValidationResult.MissingClaim(jwt, _claim)); } for (int i = 0; i < _values.Count; i++) { if (_values[i] !.Equals((TClaim)claim)) { return(TokenValidationResult.Success(jwt)); } } return(TokenValidationResult.InvalidClaim(jwt, _claim)); }
/// <inheritdoc /> public TokenValidationResult TryValidate(Jwt jwt) { if (jwt is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.jwt); } if (jwt.Payload is null) { return(TokenValidationResult.MalformedToken()); } var claim = jwt.Payload[_claim]; if (claim is null) { return(TokenValidationResult.MissingClaim(jwt, _claim)); } if (_value != (double?)claim) { return(TokenValidationResult.InvalidClaim(jwt, _claim)); } return(TokenValidationResult.Success(jwt)); }
/// <inheritdoc /> public TokenValidationResult TryValidate(Jwt jwt) { var expires = jwt.ExpirationTime; if (!expires.HasValue) { return(TokenValidationResult.MissingClaim(jwt, Claims.ExpUtf8)); } if (!_tokenReplayCache.TryAdd(jwt, expires.Value)) { return(TokenValidationResult.TokenReplayed(jwt)); } return(TokenValidationResult.Success(jwt)); }
public TokenValidationResult TryValidate(Jwt jwt) { if (jwt is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.jwt); } if (!jwt.Header.TryGetValue(HeaderParameters.AlgUtf8, out var property)) { return(TokenValidationResult.MissingHeader(HeaderParameters.AlgUtf8)); } if (!_algorithm.AsSpan().SequenceEqual(new ReadOnlySpan <byte>((byte[]?)property.Value))) { return(TokenValidationResult.InvalidHeader(HeaderParameters.AlgUtf8)); } return(TokenValidationResult.Success(jwt)); }
/// <inheritdoc /> public TokenValidationResult TryValidate(Jwt jwt) { if (jwt is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.jwt); } if (jwt.Payload is null) { return(TokenValidationResult.MalformedToken()); } if (jwt.Payload.ContainsKey(_claim)) { return(TokenValidationResult.Success(jwt)); } return(TokenValidationResult.MissingClaim(jwt, _claim)); }