01: package org.bouncycastle.jce.provider;
02:
03: import org.bouncycastle.util.CollectionStore;
04: import org.bouncycastle.util.Selector;
05: import org.bouncycastle.x509.X509CollectionStoreParameters;
06: import org.bouncycastle.x509.X509StoreParameters;
07: import org.bouncycastle.x509.X509StoreSpi;
08:
09: import java.util.Collection;
10:
11: /**
12: * This class is a collection based Bouncy Castle
13: * {@link org.bouncycastle.x509.X509Store} SPI implementation for certificate
14: * pairs.
15: *
16: * @see org.bouncycastle.x509.X509Store
17: * @see org.bouncycastle.x509.X509CertificatePair
18: */
19: public class X509StoreCertPairCollection extends X509StoreSpi {
20:
21: private CollectionStore _store;
22:
23: public X509StoreCertPairCollection() {
24: }
25:
26: /**
27: * Initializes this store.
28: *
29: * @param params The {@link X509CollectionStoreParameters}s for this store.
30: * @throws IllegalArgumentException if <code>params</code> is no instance of
31: * <code>X509CollectionStoreParameters</code>.
32: */
33: public void engineInit(X509StoreParameters params) {
34: if (!(params instanceof X509CollectionStoreParameters)) {
35: throw new IllegalArgumentException(
36: "Initialization parameters must be an instance of "
37: + X509CollectionStoreParameters.class
38: .getName() + ".");
39: }
40:
41: _store = new CollectionStore(
42: ((X509CollectionStoreParameters) params)
43: .getCollection());
44: }
45:
46: /**
47: * Returns a colelction of certificate pairs which match the given
48: * <code>selector</code>.
49: * <p/>
50: * The returned collection contains
51: * {@link org.bouncycastle.x509.X509CertificatePair}s. The selector must be
52: * a {@link org.bouncycastle.x509.X509CertPairStoreSelector} to select
53: * certificate pairs.
54: *
55: * @return A collection with matching certificate pairs.
56: */
57: public Collection engineGetMatches(Selector selector) {
58: return _store.getMatches(selector);
59: }
60: }
|