示例#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));
        }
示例#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));
        }
示例#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));
        }