blob: bc21f9d39edafe3acfce338b951753c09261c10b (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
using System;
using System.Collections.Generic;
namespace Org.BouncyCastle.Cms
{
public class SignerInformationStore
{
private readonly IList<SignerInformation> m_all;
private readonly IDictionary<SignerID, IList<SignerInformation>> m_table =
new Dictionary<SignerID, IList<SignerInformation>>();
/**
* Create a store containing a single SignerInformation object.
*
* @param signerInfo the signer information to contain.
*/
public SignerInformationStore(SignerInformation signerInfo)
{
m_all = new List<SignerInformation>(1);
m_all.Add(signerInfo);
SignerID sid = signerInfo.SignerID;
m_table[sid] = m_all;
}
/**
* Create a store containing a collection of SignerInformation objects.
*
* @param signerInfos a collection signer information objects to contain.
*/
public SignerInformationStore(IEnumerable<SignerInformation> signerInfos)
{
m_all = new List<SignerInformation>(signerInfos);
foreach (SignerInformation signer in signerInfos)
{
SignerID sid = signer.SignerID;
if (!m_table.TryGetValue(sid, out var list))
{
list = new List<SignerInformation>(1);
m_table[sid] = list;
}
list.Add(signer);
}
}
/**
* Return the first SignerInformation object that matches the
* passed in selector. Null if there are no matches.
*
* @param selector to identify a signer
* @return a single SignerInformation object. Null if none matches.
*/
public SignerInformation GetFirstSigner(SignerID selector)
{
if (m_table.TryGetValue(selector, out var list))
return list[0];
return null;
}
/// <summary>The number of signers in the collection.</summary>
public int Count
{
get { return m_all.Count; }
}
/// <returns>An ICollection of all signers in the collection</returns>
public IList<SignerInformation> GetSigners()
{
return new List<SignerInformation>(m_all);
}
/**
* Return possible empty collection with signers matching the passed in SignerID
*
* @param selector a signer id to select against.
* @return a collection of SignerInformation objects.
*/
public IList<SignerInformation> GetSigners(SignerID selector)
{
if (m_table.TryGetValue(selector, out var list))
return new List<SignerInformation>(list);
return new List<SignerInformation>(0);
}
}
}
|