- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSLTrustProvider.java
More file actions
Latest commit
70 lines (62 loc) · 2.43 KB
/
Copy pathSSLTrustProvider.java
File metadata and controls
70 lines (62 loc) · 2.43 KB
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
importjava.security.AccessController;
importjava.security.InvalidAlgorithmParameterException;
importjava.security.KeyStore;
importjava.security.KeyStoreException;
importjava.security.PrivilegedAction;
importjava.security.Security;
importjava.security.cert.X509Certificate;
importjavax.net.ssl.ManagerFactoryParameters;
importjavax.net.ssl.TrustManager;
importjavax.net.ssl.TrustManagerFactorySpi;
importjavax.net.ssl.X509TrustManager;
publicfinalclassSSLTrustProviderextendsjava.security.Provider
{
/**
*
*/
privatestaticfinallongserialVersionUID = -7467051676096334305L;
privatefinalstaticStringNAME = "XTrustJSSE";
privatefinalstaticStringINFO = "XTrust JSSE Provider (implements trust factory with truststore validation disabled)";
privatefinalstaticdoubleVERSION = 1.0D;
@SuppressWarnings("unchecked")
publicSSLTrustProvider()
{
super(NAME, VERSION, INFO);
AccessController.doPrivileged(newPrivilegedAction()
{
publicObjectrun()
{
put("TrustManagerFactory." + TrustManagerFactoryImpl.getAlgorithm(),
TrustManagerFactoryImpl.class.getName());
returnnull;
}
});
}
publicstaticvoidinstall()
{
if(Security.getProvider(NAME) == null)
{
Security.insertProviderAt(newSSLTrustProvider(), 2);
Security.setProperty("ssl.TrustManagerFactory.algorithm", TrustManagerFactoryImpl.getAlgorithm());
}
}
publicfinalstaticclassTrustManagerFactoryImplextendsTrustManagerFactorySpi
{
publicTrustManagerFactoryImpl() { }
publicstaticStringgetAlgorithm() { return"XTrust509"; }
protectedvoidengineInit(KeyStorekeystore) throwsKeyStoreException { }
protectedvoidengineInit(ManagerFactoryParametersmgrparams) throwsInvalidAlgorithmParameterException
{
thrownewInvalidAlgorithmParameterException(SSLTrustProvider.NAME + " does not use ManagerFactoryParameters");
}
protectedTrustManager[] engineGetTrustManagers()
{
returnnewTrustManager[] { newX509TrustManager()
{
publicX509Certificate[] getAcceptedIssuers() { returnnull; }
publicvoidcheckClientTrusted(X509Certificate[] certs, StringauthType) { }
publicvoidcheckServerTrusted(X509Certificate[] certs, StringauthType) { }
}};
}
}
}