|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2006, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2006, 2009 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 15-20
Link Here
|
| 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 |
* David McKnight (IBM) - [259905][api] provide public API for getting/setting key managers for SSLContext |
|
|
18 |
* David McKnight (IBM) - [264858][dstore] OpenRSE always picks the first trusted certificate |
| 18 |
*******************************************************************************/ |
19 |
*******************************************************************************/ |
| 19 |
|
20 |
|
| 20 |
package org.eclipse.dstore.internal.core.util.ssl; |
21 |
package org.eclipse.dstore.internal.core.util.ssl; |
|
Lines 25-30
Link Here
|
| 25 |
import javax.net.ssl.KeyManagerFactory; |
26 |
import javax.net.ssl.KeyManagerFactory; |
| 26 |
import javax.net.ssl.SSLContext; |
27 |
import javax.net.ssl.SSLContext; |
| 27 |
import javax.net.ssl.TrustManager; |
28 |
import javax.net.ssl.TrustManager; |
|
|
29 |
import javax.net.ssl.X509KeyManager; |
| 28 |
|
30 |
|
| 29 |
import org.eclipse.dstore.core.util.ssl.BaseSSLContext; |
31 |
import org.eclipse.dstore.core.util.ssl.BaseSSLContext; |
| 30 |
import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; |
32 |
import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; |
|
Lines 46-55
Link Here
|
| 46 |
KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password); |
48 |
KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password); |
| 47 |
String keymgrAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); |
49 |
String keymgrAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); |
| 48 |
KeyManagerFactory kmf = KeyManagerFactory.getInstance(keymgrAlgorithm); |
50 |
KeyManagerFactory kmf = KeyManagerFactory.getInstance(keymgrAlgorithm); |
| 49 |
kmf.init(ks, password.toCharArray()); |
51 |
kmf.init(ks, password.toCharArray()); |
| 50 |
|
52 |
|
| 51 |
serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$ |
53 |
serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$ |
| 52 |
serverContext.init(kmf.getKeyManagers(), null, null); |
54 |
|
|
|
55 |
keyManagers = kmf.getKeyManagers(); |
| 56 |
|
| 57 |
// read optional system property that indicates a default certificate alias |
| 58 |
String defaultAlias = System.getProperty("DSTORE_DEFAULT_CERTIFICATE_ALIAS"); //$NON-NLS-1$ |
| 59 |
if (defaultAlias != null){ |
| 60 |
KeyManager[] x509KeyManagers = new X509KeyManager[10]; |
| 61 |
|
| 62 |
for(int i=0;i<keyManagers.length; i++){ |
| 63 |
if(keyManagers[i] instanceof X509KeyManager){ |
| 64 |
x509KeyManagers[i] = new DStoreKeyManager((X509KeyManager)keyManagers[i], defaultAlias); |
| 65 |
} |
| 66 |
} |
| 67 |
serverContext.init(x509KeyManagers, null, null); |
| 68 |
} |
| 69 |
else { |
| 70 |
serverContext.init(keyManagers, null, null); |
| 71 |
} |
| 53 |
} |
72 |
} |
| 54 |
else |
73 |
else |
| 55 |
{ |
74 |
{ |