SignatureConfirmations.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Security
  5. {
  6. using System;
  7. class SignatureConfirmations
  8. {
  9. SignatureConfirmation[] confirmations;
  10. int length;
  11. bool encrypted;
  12. struct SignatureConfirmation
  13. {
  14. public byte[] value;
  15. public SignatureConfirmation(byte[] value)
  16. {
  17. this.value = value;
  18. }
  19. }
  20. public SignatureConfirmations()
  21. {
  22. confirmations = new SignatureConfirmation[1];
  23. length = 0;
  24. }
  25. public int Count
  26. {
  27. get { return length; }
  28. }
  29. public void AddConfirmation(byte[] value, bool encrypted)
  30. {
  31. if (confirmations.Length == length)
  32. {
  33. SignatureConfirmation[] newConfirmations = new SignatureConfirmation[length * 2];
  34. Array.Copy(confirmations, 0, newConfirmations, 0, length);
  35. confirmations = newConfirmations;
  36. }
  37. confirmations[length] = new SignatureConfirmation(value);
  38. ++length;
  39. this.encrypted |= encrypted;
  40. }
  41. public void GetConfirmation(int index, out byte[] value, out bool encrypted)
  42. {
  43. if (index < 0 || index >= length)
  44. {
  45. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("index", SR.GetString(SR.ValueMustBeInRange, 0, length)));
  46. }
  47. value = confirmations[index].value;
  48. encrypted = this.encrypted;
  49. }
  50. public bool IsMarkedForEncryption
  51. {
  52. get { return this.encrypted; }
  53. }
  54. }
  55. }