| | | 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.Net.Security; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF.Channels |
| | | 7 | | { |
| | | 8 | | internal class SecurityCapabilities : ISecurityCapabilities |
| | | 9 | | { |
| | 0 | 10 | | public SecurityCapabilities(bool supportsClientAuth, bool supportsServerAuth, bool supportsClientWindowsIdentity |
| | 0 | 11 | | ProtectionLevel requestProtectionLevel, ProtectionLevel responseProtectionLevel) |
| | | 12 | | { |
| | 0 | 13 | | SupportsClientAuthentication = supportsClientAuth; |
| | 0 | 14 | | SupportsServerAuthentication = supportsServerAuth; |
| | 0 | 15 | | SupportsClientWindowsIdentity = supportsClientWindowsIdentity; |
| | 0 | 16 | | SupportedRequestProtectionLevel = requestProtectionLevel; |
| | 0 | 17 | | SupportedResponseProtectionLevel = responseProtectionLevel; |
| | 0 | 18 | | } |
| | | 19 | | |
| | 0 | 20 | | public ProtectionLevel SupportedRequestProtectionLevel { get; } |
| | 0 | 21 | | public ProtectionLevel SupportedResponseProtectionLevel { get; } |
| | 0 | 22 | | public bool SupportsClientAuthentication { get; } |
| | 0 | 23 | | public bool SupportsClientWindowsIdentity { get; } |
| | 0 | 24 | | public bool SupportsServerAuthentication { get; } |
| | | 25 | | |
| | 0 | 26 | | private static SecurityCapabilities None => new SecurityCapabilities(false, false, false, ProtectionLevel.None, |
| | | 27 | | |
| | | 28 | | internal static bool IsEqual(ISecurityCapabilities capabilities1, ISecurityCapabilities capabilities2) |
| | | 29 | | { |
| | 0 | 30 | | if (capabilities1 == null) |
| | | 31 | | { |
| | 0 | 32 | | capabilities1 = None; |
| | | 33 | | } |
| | | 34 | | |
| | 0 | 35 | | if (capabilities2 == null) |
| | | 36 | | { |
| | 0 | 37 | | capabilities2 = None; |
| | | 38 | | } |
| | | 39 | | |
| | 0 | 40 | | if (capabilities1.SupportedRequestProtectionLevel != capabilities2.SupportedRequestProtectionLevel) |
| | | 41 | | { |
| | 0 | 42 | | return false; |
| | | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | if (capabilities1.SupportedResponseProtectionLevel != capabilities2.SupportedResponseProtectionLevel) |
| | | 46 | | { |
| | 0 | 47 | | return false; |
| | | 48 | | } |
| | | 49 | | |
| | 0 | 50 | | if (capabilities1.SupportsClientAuthentication != capabilities2.SupportsClientAuthentication) |
| | | 51 | | { |
| | 0 | 52 | | return false; |
| | | 53 | | } |
| | | 54 | | |
| | 0 | 55 | | if (capabilities1.SupportsClientWindowsIdentity != capabilities2.SupportsClientWindowsIdentity) |
| | | 56 | | { |
| | 0 | 57 | | return false; |
| | | 58 | | } |
| | | 59 | | |
| | 0 | 60 | | if (capabilities1.SupportsServerAuthentication != capabilities2.SupportsServerAuthentication) |
| | | 61 | | { |
| | 0 | 62 | | return false; |
| | | 63 | | } |
| | | 64 | | |
| | 0 | 65 | | return true; |
| | | 66 | | } |
| | | 67 | | } |
| | | 68 | | } |