Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        /// <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));
        }