UserNamePasswordClientCredential.cs 1.6 KB

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