NamedJcaJceHelper.java revision e1142c149e244797ce73b0e7fad40816e447a817
1package org.bouncycastle.jcajce;
2
3import java.security.AlgorithmParameterGenerator;
4import java.security.AlgorithmParameters;
5import java.security.KeyFactory;
6import java.security.KeyPairGenerator;
7import java.security.MessageDigest;
8import java.security.NoSuchAlgorithmException;
9import java.security.NoSuchProviderException;
10import java.security.Signature;
11import java.security.cert.CertificateException;
12import java.security.cert.CertificateFactory;
13
14import javax.crypto.Cipher;
15import javax.crypto.KeyAgreement;
16import javax.crypto.KeyGenerator;
17import javax.crypto.Mac;
18import javax.crypto.NoSuchPaddingException;
19import javax.crypto.SecretKeyFactory;
20
21public class NamedJcaJceHelper
22    implements JcaJceHelper
23{
24    protected final String providerName;
25
26    public NamedJcaJceHelper(String providerName)
27    {
28        this.providerName = providerName;
29    }
30
31    public Cipher createCipher(
32        String algorithm)
33        throws NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
34    {
35        return Cipher.getInstance(algorithm, providerName);
36    }
37
38    public Mac createMac(String algorithm)
39        throws NoSuchAlgorithmException, NoSuchProviderException
40    {
41        return Mac.getInstance(algorithm, providerName);
42    }
43
44    public KeyAgreement createKeyAgreement(String algorithm)
45        throws NoSuchAlgorithmException, NoSuchProviderException
46    {
47        return KeyAgreement.getInstance(algorithm, providerName);
48    }
49
50    public AlgorithmParameterGenerator createAlgorithmParameterGenerator(String algorithm)
51        throws NoSuchAlgorithmException, NoSuchProviderException
52    {
53        return AlgorithmParameterGenerator.getInstance(algorithm, providerName);
54    }
55
56    public AlgorithmParameters createAlgorithmParameters(String algorithm)
57        throws NoSuchAlgorithmException, NoSuchProviderException
58    {
59        return AlgorithmParameters.getInstance(algorithm, providerName);
60    }
61
62    public KeyGenerator createKeyGenerator(String algorithm)
63        throws NoSuchAlgorithmException, NoSuchProviderException
64    {
65        return KeyGenerator.getInstance(algorithm, providerName);
66    }
67
68    public KeyFactory createKeyFactory(String algorithm)
69        throws NoSuchAlgorithmException, NoSuchProviderException
70    {
71        return KeyFactory.getInstance(algorithm, providerName);
72    }
73
74    public SecretKeyFactory createSecretKeyFactory(String algorithm)
75        throws NoSuchAlgorithmException, NoSuchProviderException
76    {
77        return SecretKeyFactory.getInstance(algorithm, providerName);
78    }
79
80    public KeyPairGenerator createKeyPairGenerator(String algorithm)
81        throws NoSuchAlgorithmException, NoSuchProviderException
82    {
83        return KeyPairGenerator.getInstance(algorithm, providerName);
84    }
85
86    public MessageDigest createDigest(String algorithm)
87        throws NoSuchAlgorithmException, NoSuchProviderException
88    {
89        return MessageDigest.getInstance(algorithm, providerName);
90    }
91
92    public Signature createSignature(String algorithm)
93        throws NoSuchAlgorithmException, NoSuchProviderException
94    {
95        return Signature.getInstance(algorithm, providerName);
96    }
97
98    public CertificateFactory createCertificateFactory(String algorithm)
99        throws NoSuchAlgorithmException, CertificateException, NoSuchProviderException
100    {
101        return CertificateFactory.getInstance(algorithm, providerName);
102    }
103}
104