~brian-thomason/+junk/bouncycastle

« back to all changes in this revision

Viewing changes to src/org/bouncycastle/jce/provider/X509StoreCertPairCollection.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:20:32 UTC
  • Revision ID: brian.thomason@canonical.com-20111220172032-rdtm13jgdxtksacr
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.bouncycastle.jce.provider;
 
2
 
 
3
import org.bouncycastle.util.CollectionStore;
 
4
import org.bouncycastle.util.Selector;
 
5
import org.bouncycastle.x509.X509CollectionStoreParameters;
 
6
import org.bouncycastle.x509.X509StoreParameters;
 
7
import org.bouncycastle.x509.X509StoreSpi;
 
8
 
 
9
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
 
 
22
    private CollectionStore _store;
 
23
 
 
24
    public X509StoreCertPairCollection()
 
25
    {
 
26
    }
 
27
 
 
28
    /**
 
29
     * Initializes this store.
 
30
     *
 
31
     * @param params The {@link X509CollectionStoreParameters}s for this store.
 
32
     * @throws IllegalArgumentException if <code>params</code> is no instance of
 
33
     *                                  <code>X509CollectionStoreParameters</code>.
 
34
     */
 
35
    public void engineInit(X509StoreParameters params)
 
36
    {
 
37
        if (!(params instanceof X509CollectionStoreParameters))
 
38
        {
 
39
            throw new IllegalArgumentException(
 
40
                "Initialization parameters must be an instance of "
 
41
                    + X509CollectionStoreParameters.class.getName()
 
42
                    + ".");
 
43
        }
 
44
 
 
45
        _store = new CollectionStore(((X509CollectionStoreParameters)params)
 
46
            .getCollection());
 
47
    }
 
48
 
 
49
    /**
 
50
     * Returns a colelction of certificate pairs which match the given
 
51
     * <code>selector</code>.
 
52
     * <p/>
 
53
     * The returned collection contains
 
54
     * {@link org.bouncycastle.x509.X509CertificatePair}s. The selector must be
 
55
     * a {@link org.bouncycastle.x509.X509CertPairStoreSelector} to select
 
56
     * certificate pairs.
 
57
     *
 
58
     * @return A collection with matching certificate pairs.
 
59
     */
 
60
    public Collection engineGetMatches(Selector selector)
 
61
    {
 
62
        return _store.getMatches(selector);
 
63
    }
 
64
}