|  | 
|  | 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. | 
|  | 2 | +// Licensed under the MIT License. | 
|  | 3 | + | 
|  | 4 | +using System; | 
|  | 5 | +using Microsoft.IdentityModel.Tokens; | 
|  | 6 | + | 
|  | 7 | +#nullable enable | 
|  | 8 | +namespace Microsoft.IdentityModel.TestUtils | 
|  | 9 | +{ | 
|  | 10 | +    internal class CustomTokenTypeValidationDelegates | 
|  | 11 | +    { | 
|  | 12 | +        internal static ValidationResult<ValidatedTokenType> CustomTokenTypeValidatorDelegate( | 
|  | 13 | +            string? type, | 
|  | 14 | +            SecurityToken? securityToken, | 
|  | 15 | +            ValidationParameters validationParameters, | 
|  | 16 | +            CallContext callContext) | 
|  | 17 | +        { | 
|  | 18 | +            // Returns a CustomTokenTypeValidationError : TokenTypeValidationError | 
|  | 19 | +            return new CustomTokenTypeValidationError( | 
|  | 20 | +                new MessageDetail(nameof(CustomTokenTypeValidatorDelegate), null), | 
|  | 21 | +                typeof(SecurityTokenInvalidTypeException), | 
|  | 22 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 23 | +                type, | 
|  | 24 | +                null); | 
|  | 25 | +        } | 
|  | 26 | + | 
|  | 27 | +        internal static ValidationResult<ValidatedTokenType> CustomTokenTypeValidatorCustomExceptionDelegate( | 
|  | 28 | +            string? type, | 
|  | 29 | +            SecurityToken? securityToken, | 
|  | 30 | +            ValidationParameters validationParameters, | 
|  | 31 | +            CallContext callContext) | 
|  | 32 | +        { | 
|  | 33 | +            return new CustomTokenTypeValidationError( | 
|  | 34 | +                new MessageDetail(nameof(CustomTokenTypeValidatorCustomExceptionDelegate), null), | 
|  | 35 | +                typeof(CustomSecurityTokenInvalidTypeException), | 
|  | 36 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 37 | +                type, | 
|  | 38 | +                null); | 
|  | 39 | +        } | 
|  | 40 | + | 
|  | 41 | +        internal static ValidationResult<ValidatedTokenType> CustomTokenTypeValidatorCustomExceptionCustomFailureTypeDelegate( | 
|  | 42 | +            string? type, | 
|  | 43 | +            SecurityToken? securityToken, | 
|  | 44 | +            ValidationParameters validationParameters, | 
|  | 45 | +            CallContext callContext) | 
|  | 46 | +        { | 
|  | 47 | +            return new CustomTokenTypeValidationError( | 
|  | 48 | +                new MessageDetail(nameof(CustomTokenTypeValidatorCustomExceptionCustomFailureTypeDelegate), null), | 
|  | 49 | +                typeof(CustomSecurityTokenInvalidTypeException), | 
|  | 50 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 51 | +                type, | 
|  | 52 | +                CustomTokenTypeValidationError.CustomTokenTypeValidationFailureType); | 
|  | 53 | +        } | 
|  | 54 | + | 
|  | 55 | +        internal static ValidationResult<ValidatedTokenType> CustomTokenTypeValidatorUnknownExceptionDelegate( | 
|  | 56 | +            string? type, | 
|  | 57 | +            SecurityToken? securityToken, | 
|  | 58 | +            ValidationParameters validationParameters, | 
|  | 59 | +            CallContext callContext) | 
|  | 60 | +        { | 
|  | 61 | +            return new CustomTokenTypeValidationError( | 
|  | 62 | +                new MessageDetail(nameof(CustomTokenTypeValidatorUnknownExceptionDelegate), null), | 
|  | 63 | +                typeof(NotSupportedException), | 
|  | 64 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 65 | +                type, | 
|  | 66 | +                null); | 
|  | 67 | +        } | 
|  | 68 | + | 
|  | 69 | +        internal static ValidationResult<ValidatedTokenType> CustomTokenTypeValidatorWithoutGetExceptionOverrideDelegate( | 
|  | 70 | +            string? type, | 
|  | 71 | +            SecurityToken? securityToken, | 
|  | 72 | +            ValidationParameters validationParameters, | 
|  | 73 | +            CallContext callContext) | 
|  | 74 | +        { | 
|  | 75 | +            return new CustomTokenTypeWithoutGetExceptionValidationOverrideError( | 
|  | 76 | +                new MessageDetail(nameof(CustomTokenTypeValidatorWithoutGetExceptionOverrideDelegate), null), | 
|  | 77 | +                typeof(CustomSecurityTokenInvalidTypeException), | 
|  | 78 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 79 | +                type, | 
|  | 80 | +                null); | 
|  | 81 | +        } | 
|  | 82 | + | 
|  | 83 | +        internal static ValidationResult<ValidatedTokenType> TokenTypeValidatorDelegate( | 
|  | 84 | +            string? type, | 
|  | 85 | +            SecurityToken? securityToken, | 
|  | 86 | +            ValidationParameters validationParameters, | 
|  | 87 | +            CallContext callContext) | 
|  | 88 | +        { | 
|  | 89 | +            return new TokenTypeValidationError( | 
|  | 90 | +                new MessageDetail(nameof(TokenTypeValidatorDelegate), null), | 
|  | 91 | +                typeof(SecurityTokenInvalidTypeException), | 
|  | 92 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 93 | +                type, | 
|  | 94 | +                null); | 
|  | 95 | +        } | 
|  | 96 | + | 
|  | 97 | +        internal static ValidationResult<ValidatedTokenType> TokenTypeValidatorThrows( | 
|  | 98 | +            string? type, | 
|  | 99 | +            SecurityToken? securityToken, | 
|  | 100 | +            ValidationParameters validationParameters, | 
|  | 101 | +            CallContext callContext) | 
|  | 102 | +        { | 
|  | 103 | +            throw new CustomSecurityTokenInvalidTypeException(nameof(TokenTypeValidatorThrows), null); | 
|  | 104 | +        } | 
|  | 105 | + | 
|  | 106 | +        internal static ValidationResult<ValidatedTokenType> TokenTypeValidatorCustomTokenTypeExceptionTypeDelegate( | 
|  | 107 | +            string? type, | 
|  | 108 | +            SecurityToken? securityToken, | 
|  | 109 | +            ValidationParameters validationParameters, | 
|  | 110 | +            CallContext callContext) | 
|  | 111 | +        { | 
|  | 112 | +            return new TokenTypeValidationError( | 
|  | 113 | +                new MessageDetail(nameof(TokenTypeValidatorCustomTokenTypeExceptionTypeDelegate), null), | 
|  | 114 | +                typeof(CustomSecurityTokenInvalidTypeException), | 
|  | 115 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 116 | +                type, | 
|  | 117 | +                null); | 
|  | 118 | +        } | 
|  | 119 | + | 
|  | 120 | +        internal static ValidationResult<ValidatedTokenType> TokenTypeValidatorCustomExceptionTypeDelegate( | 
|  | 121 | +            string? type, | 
|  | 122 | +            SecurityToken? securityToken, | 
|  | 123 | +            ValidationParameters validationParameters, | 
|  | 124 | +            CallContext callContext) | 
|  | 125 | +        { | 
|  | 126 | +            return new TokenTypeValidationError( | 
|  | 127 | +                new MessageDetail(nameof(TokenTypeValidatorCustomExceptionTypeDelegate), null), | 
|  | 128 | +                typeof(CustomSecurityTokenException), | 
|  | 129 | +                ValidationError.GetCurrentStackFrame(), | 
|  | 130 | +                type, | 
|  | 131 | +                null); | 
|  | 132 | +        } | 
|  | 133 | +    } | 
|  | 134 | +} | 
|  | 135 | +#nullable restore | 
0 commit comments