WindowsServiceCredential.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Security
  5. {
  6. public sealed class WindowsServiceCredential
  7. {
  8. bool allowAnonymousLogons = SspiSecurityTokenProvider.DefaultAllowUnauthenticatedCallers;
  9. bool includeWindowsGroups = SspiSecurityTokenProvider.DefaultExtractWindowsGroupClaims;
  10. bool isReadOnly;
  11. internal WindowsServiceCredential()
  12. {
  13. // empty
  14. }
  15. internal WindowsServiceCredential(WindowsServiceCredential other)
  16. {
  17. this.allowAnonymousLogons = other.allowAnonymousLogons;
  18. this.includeWindowsGroups = other.includeWindowsGroups;
  19. this.isReadOnly = other.isReadOnly;
  20. }
  21. public bool AllowAnonymousLogons
  22. {
  23. get
  24. {
  25. return this.allowAnonymousLogons;
  26. }
  27. set
  28. {
  29. ThrowIfImmutable();
  30. this.allowAnonymousLogons = value;
  31. }
  32. }
  33. public bool IncludeWindowsGroups
  34. {
  35. get
  36. {
  37. return this.includeWindowsGroups;
  38. }
  39. set
  40. {
  41. ThrowIfImmutable();
  42. this.includeWindowsGroups = value;
  43. }
  44. }
  45. internal void MakeReadOnly()
  46. {
  47. this.isReadOnly = true;
  48. }
  49. void ThrowIfImmutable()
  50. {
  51. if (this.isReadOnly)
  52. {
  53. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
  54. }
  55. }
  56. }
  57. }