summary refs log tree commit diff
path: root/crypto/src/x509/store/X509CollectionStoreParameters.cs
blob: 7fd047a470c0ee88124b95933dd7a95394d4bc99 (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
52
53
54
55
56
57
58
59
60
using System;
using System.Collections;
using System.Text;

using Org.BouncyCastle.Utilities;

namespace Org.BouncyCastle.X509.Store
{
	/// <remarks>This class contains a collection for collection based <code>X509Store</code>s.</remarks>
	public class X509CollectionStoreParameters
		: IX509StoreParameters
	{
		private readonly IList collection;

		/// <summary>
		/// Constructor.
		/// <p>
		/// The collection is copied.
		/// </p>
		/// </summary>
		/// <param name="collection">The collection containing X.509 object types.</param>
		/// <exception cref="ArgumentNullException">If collection is null.</exception>
		public X509CollectionStoreParameters(
			ICollection collection)
		{
			if (collection == null)
				throw new ArgumentNullException("collection");

			this.collection = Platform.CreateArrayList(collection);
		}

		// TODO Do we need to be able to Clone() these, and should it really be shallow?
//		/**
//		* Returns a shallow clone. The returned contents are not copied, so adding
//		* or removing objects will effect this.
//		*
//		* @return a shallow clone.
//		*/
//		public object Clone()
//		{
//			return new X509CollectionStoreParameters(collection);
//		}

		/// <summary>Returns a copy of the <code>ICollection</code>.</summary>
		public ICollection GetCollection()
		{
			return Platform.CreateArrayList(collection);
		}

		/// <summary>Returns a formatted string describing the parameters.</summary>
		public override string ToString()
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("X509CollectionStoreParameters: [\n");
			sb.Append("  collection: " + collection + "\n");
			sb.Append("]");
			return sb.ToString();
		}
	}
}