1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.mina.integration.spring.ssl;
20
21 import java.security.InvalidAlgorithmParameterException;
22 import java.security.KeyStore;
23 import java.security.KeyStoreException;
24 import java.security.Provider;
25 import java.security.cert.CertificateException;
26 import java.security.cert.X509Certificate;
27
28 import javax.net.ssl.ManagerFactoryParameters;
29 import javax.net.ssl.TrustManager;
30 import javax.net.ssl.TrustManagerFactory;
31 import javax.net.ssl.TrustManagerFactorySpi;
32 import javax.net.ssl.X509TrustManager;
33
34 /***
35 * Bogus {@link javax.net.ssl.TrustManagerFactory} which creates
36 * {@link javax.net.ssl.X509TrustManager} trusting everything.
37 *
38 * @author The Apache Directory Project (dev@directory.apache.org)
39 * @version $Rev: 326586 $, $Date: 2005-10-19 17:50:29 +0200 (ons, 19 okt 2005) $
40 */
41 public class BogusTrustManagerFactory extends TrustManagerFactory
42 {
43
44 public BogusTrustManagerFactory()
45 {
46 super( new BogusTrustManagerFactorySpi(),
47 new Provider("MinaBogus", 1.0, "") {}, "MinaBogus" );
48 }
49
50 private static final X509TrustManager X509 = new X509TrustManager()
51 {
52 public void checkClientTrusted( X509Certificate[] x509Certificates,
53 String s ) throws CertificateException
54 {
55 }
56
57 public void checkServerTrusted( X509Certificate[] x509Certificates,
58 String s ) throws CertificateException
59 {
60 }
61
62 public X509Certificate[] getAcceptedIssuers()
63 {
64 return new X509Certificate[ 0 ];
65 }
66 };
67
68 private static final TrustManager[] X509_MANAGERS = new TrustManager[] { X509 };
69
70 private static class BogusTrustManagerFactorySpi extends TrustManagerFactorySpi
71 {
72
73 protected TrustManager[] engineGetTrustManagers()
74 {
75 return X509_MANAGERS;
76 }
77
78 protected void engineInit( KeyStore keystore ) throws KeyStoreException
79 {
80
81 }
82
83 protected void engineInit(
84 ManagerFactoryParameters managerFactoryParameters )
85 throws InvalidAlgorithmParameterException
86 {
87
88 }
89
90 }
91 }