X509CollectionStore.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store
  7. {
  8. /**
  9. * A simple collection backed store.
  10. */
  11. internal class X509CollectionStore
  12. : IX509Store
  13. {
  14. private ICollection _local;
  15. /**
  16. * Basic constructor.
  17. *
  18. * @param collection - initial contents for the store, this is copied.
  19. */
  20. internal X509CollectionStore(
  21. ICollection collection)
  22. {
  23. _local = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(collection);
  24. }
  25. /**
  26. * Return the matches in the collection for the passed in selector.
  27. *
  28. * @param selector the selector to match against.
  29. * @return a possibly empty collection of matching objects.
  30. */
  31. public ICollection GetMatches(
  32. IX509Selector selector)
  33. {
  34. if (selector == null)
  35. {
  36. return BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(_local);
  37. }
  38. IList result = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList();
  39. foreach (object obj in _local)
  40. {
  41. if (selector.Match(obj))
  42. result.Add(obj);
  43. }
  44. return result;
  45. }
  46. }
  47. }
  48. #pragma warning restore
  49. #endif