SecurityCapabilities.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Channels
  5. {
  6. using System.Net.Security;
  7. class SecurityCapabilities : ISecurityCapabilities
  8. {
  9. internal bool supportsServerAuth;
  10. internal bool supportsClientAuth;
  11. internal bool supportsClientWindowsIdentity;
  12. internal ProtectionLevel requestProtectionLevel;
  13. internal ProtectionLevel responseProtectionLevel;
  14. public SecurityCapabilities(bool supportsClientAuth, bool supportsServerAuth, bool supportsClientWindowsIdentity,
  15. ProtectionLevel requestProtectionLevel, ProtectionLevel responseProtectionLevel)
  16. {
  17. this.supportsClientAuth = supportsClientAuth;
  18. this.supportsServerAuth = supportsServerAuth;
  19. this.supportsClientWindowsIdentity = supportsClientWindowsIdentity;
  20. this.requestProtectionLevel = requestProtectionLevel;
  21. this.responseProtectionLevel = responseProtectionLevel;
  22. }
  23. public ProtectionLevel SupportedRequestProtectionLevel { get { return requestProtectionLevel; } }
  24. public ProtectionLevel SupportedResponseProtectionLevel { get { return responseProtectionLevel; } }
  25. public bool SupportsClientAuthentication { get { return supportsClientAuth; } }
  26. public bool SupportsClientWindowsIdentity { get { return supportsClientWindowsIdentity; } }
  27. public bool SupportsServerAuthentication { get { return supportsServerAuth; } }
  28. static SecurityCapabilities None
  29. {
  30. get { return new SecurityCapabilities(false, false, false, ProtectionLevel.None, ProtectionLevel.None); }
  31. }
  32. internal static bool IsEqual(ISecurityCapabilities capabilities1, ISecurityCapabilities capabilities2)
  33. {
  34. if (capabilities1 == null)
  35. {
  36. capabilities1 = SecurityCapabilities.None;
  37. }
  38. if (capabilities2 == null)
  39. {
  40. capabilities2 = SecurityCapabilities.None;
  41. }
  42. if (capabilities1.SupportedRequestProtectionLevel != capabilities2.SupportedRequestProtectionLevel)
  43. {
  44. return false;
  45. }
  46. if (capabilities1.SupportedResponseProtectionLevel != capabilities2.SupportedResponseProtectionLevel)
  47. {
  48. return false;
  49. }
  50. if (capabilities1.SupportsClientAuthentication != capabilities2.SupportsClientAuthentication)
  51. {
  52. return false;
  53. }
  54. if (capabilities1.SupportsClientWindowsIdentity != capabilities2.SupportsClientWindowsIdentity)
  55. {
  56. return false;
  57. }
  58. if (capabilities1.SupportsServerAuthentication != capabilities2.SupportsServerAuthentication)
  59. {
  60. return false;
  61. }
  62. return true;
  63. }
  64. }
  65. }