| | | 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.Runtime.Serialization; |
| | | 5 | | using System.Security.Cryptography; |
| | | 6 | | using System; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Security |
| | | 9 | | { |
| | | 10 | | internal class SspiNegotiationTokenAuthenticatorState : NegotiationTokenAuthenticatorState |
| | | 11 | | { |
| | | 12 | | public SspiNegotiationTokenAuthenticatorState(ISspiNegotiation sspiNegotiation) |
| | 0 | 13 | | : base() |
| | | 14 | | { |
| | 0 | 15 | | SspiNegotiation = sspiNegotiation ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof |
| | 0 | 16 | | NegotiationDigest = IncrementalHash.CreateHash(HashAlgorithmName.SHA1); |
| | 0 | 17 | | } |
| | | 18 | | |
| | 0 | 19 | | public ISspiNegotiation SspiNegotiation { get; } |
| | | 20 | | |
| | 0 | 21 | | internal int RequestedKeySize { get; set; } |
| | | 22 | | |
| | 0 | 23 | | internal IncrementalHash NegotiationDigest { get; } |
| | | 24 | | |
| | 0 | 25 | | internal string Context { get; set; } |
| | | 26 | | |
| | 0 | 27 | | internal EndpointAddress AppliesTo { get; set; } |
| | | 28 | | |
| | 0 | 29 | | internal DataContractSerializer AppliesToSerializer { get; set; } |
| | | 30 | | |
| | | 31 | | public override string GetRemoteIdentityName() |
| | | 32 | | { |
| | 0 | 33 | | if (SspiNegotiation != null && !IsNegotiationCompleted) |
| | | 34 | | { |
| | 0 | 35 | | return SspiNegotiation.GetRemoteIdentityName(); |
| | | 36 | | } |
| | 0 | 37 | | return base.GetRemoteIdentityName(); |
| | | 38 | | } |
| | | 39 | | |
| | | 40 | | public override void Dispose() |
| | | 41 | | { |
| | | 42 | | try |
| | | 43 | | { |
| | 0 | 44 | | using (AsyncLock.TakeLock()) |
| | | 45 | | { |
| | 0 | 46 | | if (SspiNegotiation != null) |
| | | 47 | | { |
| | 0 | 48 | | SspiNegotiation.Dispose(); |
| | | 49 | | |
| | | 50 | | } |
| | 0 | 51 | | if (NegotiationDigest != null) |
| | | 52 | | { |
| | 0 | 53 | | ((IDisposable)NegotiationDigest).Dispose(); |
| | | 54 | | } |
| | 0 | 55 | | } |
| | | 56 | | } |
| | | 57 | | finally |
| | | 58 | | { |
| | 0 | 59 | | base.Dispose(); |
| | 0 | 60 | | } |
| | 0 | 61 | | } |
| | | 62 | | } |
| | | 63 | | } |