Lines 14-19
Link Here
|
14 |
* Contributors: |
14 |
* Contributors: |
15 |
* David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types |
15 |
* David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types |
16 |
* Noriaki Takatsu (IBM) - [259905][api] Provide a facility to use its own keystore |
16 |
* Noriaki Takatsu (IBM) - [259905][api] Provide a facility to use its own keystore |
|
|
17 |
* David McKnight (IBM) - [259905][api] provide public API for getting/setting key managers for SSLContext |
17 |
*******************************************************************************/ |
18 |
*******************************************************************************/ |
18 |
|
19 |
|
19 |
package org.eclipse.dstore.internal.core.util.ssl; |
20 |
package org.eclipse.dstore.internal.core.util.ssl; |
Lines 25-42
Link Here
|
25 |
import javax.net.ssl.SSLContext; |
26 |
import javax.net.ssl.SSLContext; |
26 |
import javax.net.ssl.TrustManager; |
27 |
import javax.net.ssl.TrustManager; |
27 |
|
28 |
|
|
|
29 |
import org.eclipse.dstore.core.util.ssl.BaseSSLContext; |
28 |
import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; |
30 |
import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; |
29 |
import org.eclipse.dstore.core.util.ssl.IDataStoreTrustManager; |
31 |
import org.eclipse.dstore.core.util.ssl.IDataStoreTrustManager; |
30 |
|
32 |
|
31 |
|
33 |
|
32 |
public class DStoreSSLContext |
34 |
public class DStoreSSLContext |
33 |
{ |
35 |
{ |
34 |
private static KeyManager[] _keyManagers; |
|
|
35 |
|
36 |
public static void setKeyManager(KeyManager[] keyManagers) |
37 |
{ |
38 |
_keyManagers = keyManagers; |
39 |
} |
40 |
|
36 |
|
41 |
public static SSLContext getServerSSLContext(String filePath, String password) |
37 |
public static SSLContext getServerSSLContext(String filePath, String password) |
42 |
{ |
38 |
{ |
Lines 44-50
Link Here
|
44 |
|
40 |
|
45 |
try |
41 |
try |
46 |
{ |
42 |
{ |
47 |
if (_keyManagers == null) |
43 |
KeyManager[] keyManagers = BaseSSLContext.getKeyManagers(); |
|
|
44 |
if (keyManagers == null) |
48 |
{ |
45 |
{ |
49 |
KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password); |
46 |
KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password); |
50 |
String keymgrAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); |
47 |
String keymgrAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); |
Lines 57-63
Link Here
|
57 |
else |
54 |
else |
58 |
{ |
55 |
{ |
59 |
serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$ |
56 |
serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$ |
60 |
serverContext.init(_keyManagers, null, null); |
57 |
serverContext.init(keyManagers, null, null); |
61 |
} |
58 |
} |
62 |
|
59 |
|
63 |
} |
60 |
} |
Lines 81-87
Link Here
|
81 |
mgrs[0] = trustManager; |
78 |
mgrs[0] = trustManager; |
82 |
|
79 |
|
83 |
|
80 |
|
84 |
clientContext.init(_keyManagers, mgrs, null); |
81 |
KeyManager[] keyManagers = BaseSSLContext.getKeyManagers(); |
|
|
82 |
clientContext.init(keyManagers, mgrs, null); |
85 |
} |
83 |
} |
86 |
catch (Exception e) |
84 |
catch (Exception e) |
87 |
{ |
85 |
{ |