| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.ObjectModel; |
| | | 6 | | using System.Threading.Tasks; |
| | | 7 | | using CoreWCF.IdentityModel.Policy; |
| | | 8 | | using CoreWCF.IdentityModel.Tokens; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.IdentityModel.Selectors |
| | | 11 | | { |
| | | 12 | | public abstract class UserNameSecurityTokenAuthenticator : SecurityTokenAuthenticator |
| | | 13 | | { |
| | 19 | 14 | | protected UserNameSecurityTokenAuthenticator() |
| | | 15 | | { |
| | 19 | 16 | | } |
| | | 17 | | |
| | 36 | 18 | | protected override bool CanValidateTokenCore(SecurityToken token) => token is UserNameSecurityToken; |
| | | 19 | | |
| | | 20 | | protected override ValueTask<ReadOnlyCollection<IAuthorizationPolicy>> ValidateTokenCoreAsync(SecurityToken toke |
| | | 21 | | { |
| | 18 | 22 | | UserNameSecurityToken userNameToken = (UserNameSecurityToken)token; |
| | 18 | 23 | | return ValidateUserNamePasswordCoreAsync(userNameToken.UserName, userNameToken.Password); |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | [Obsolete("Implementers should override ValidateUserNamePasswordCoreAsync.")] |
| | 0 | 27 | | protected virtual ReadOnlyCollection<IAuthorizationPolicy> ValidateUserNamePasswordCore(string userName, string |
| | | 28 | | |
| | | 29 | | protected virtual ValueTask<ReadOnlyCollection<IAuthorizationPolicy>> ValidateUserNamePasswordCoreAsync(string u |
| | | 30 | | { |
| | | 31 | | // Default to calling sync implementation to support existing derived types which haven't overridden this me |
| | | 32 | | #pragma warning disable CS0618 // Type or member is obsolete |
| | 0 | 33 | | return new ValueTask<ReadOnlyCollection<IAuthorizationPolicy>>(ValidateUserNamePasswordCore(userName, passwo |
| | | 34 | | #pragma warning restore CS0618 // Type or member is obsolete |
| | | 35 | | } |
| | | 36 | | } |
| | | 37 | | } |