summary refs log tree commit diff
path: root/crypto/src/x509/store/X509CollectionStore.cs
blob: 92173140be051fe6007edd1fd4a1703db2e0dc0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections;

using Org.BouncyCastle.Utilities;

namespace Org.BouncyCastle.X509.Store
{
	/**
	 * A simple collection backed store.
	 */
	internal class X509CollectionStore
		: IX509Store
	{
		private ICollection _local;

		/**
		 * Basic constructor.
		 *
		 * @param collection - initial contents for the store, this is copied.
		 */
		internal X509CollectionStore(
			ICollection collection)
		{
			_local = Platform.CreateArrayList(collection);
		}

		/**
		 * Return the matches in the collection for the passed in selector.
		 *
		 * @param selector the selector to match against.
		 * @return a possibly empty collection of matching objects.
		 */
		public ICollection GetMatches(
			IX509Selector selector)
		{
			if (selector == null)
			{
                return Platform.CreateArrayList(_local);
			}

            IList result = Platform.CreateArrayList();
			foreach (object obj in _local)
			{
				if (selector.Match(obj))
					result.Add(obj);
			}

			return result;
		}
	}
}