blob: 5467e16e423ec7621ae13cffd4ba3fa615d6f8c1 (
plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
|
package org.spongycastle.jce.provider;
import java.security.InvalidAlgorithmParameterException;
import java.security.cert.CRL;
import java.security.cert.CRLSelector;
import java.security.cert.CertSelector;
import java.security.cert.CertStoreException;
import java.security.cert.CertStoreParameters;
import java.security.cert.CertStoreSpi;
import java.security.cert.Certificate;
import java.security.cert.CollectionCertStoreParameters;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
public class CertStoreCollectionSpi extends CertStoreSpi
{
private CollectionCertStoreParameters params;
public CertStoreCollectionSpi(CertStoreParameters params)
throws InvalidAlgorithmParameterException
{
super(params);
if (!(params instanceof CollectionCertStoreParameters))
{
throw new InvalidAlgorithmParameterException("org.spongycastle.jce.provider.CertStoreCollectionSpi: parameter must be a CollectionCertStoreParameters object\n" + params.toString());
}
this.params = (CollectionCertStoreParameters)params;
}
public Collection engineGetCertificates(
CertSelector selector)
throws CertStoreException
{
List col = new ArrayList();
Iterator iter = params.getCollection().iterator();
if (selector == null)
{
while (iter.hasNext())
{
Object obj = iter.next();
if (obj instanceof Certificate)
{
col.add(obj);
}
}
}
else
{
while (iter.hasNext())
{
Object obj = iter.next();
if ((obj instanceof Certificate) && selector.match((Certificate)obj))
{
col.add(obj);
}
}
}
return col;
}
public Collection engineGetCRLs(
CRLSelector selector)
throws CertStoreException
{
List col = new ArrayList();
Iterator iter = params.getCollection().iterator();
if (selector == null)
{
while (iter.hasNext())
{
Object obj = iter.next();
if (obj instanceof CRL)
{
col.add(obj);
}
}
}
else
{
while (iter.hasNext())
{
Object obj = iter.next();
if ((obj instanceof CRL) && selector.match((CRL)obj))
{
col.add(obj);
}
}
}
return col;
}
}
|