diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/ssl/BaseSSLContext.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/ssl/BaseSSLContext.java new file mode 100644 index 00000000000..bcbd3eb9fdf --- /dev/null +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/ssl/BaseSSLContext.java @@ -0,0 +1,33 @@ +/******************************************************************************** + * Copyright (c) 20089 IBM Corporation. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight. + * + * Contributors: + * David McKnight (IBM) - [259905][api] provide public API for getting/setting key managers for SSLContext + ********************************************************************************/ + +package org.eclipse.dstore.core.util.ssl; + +import javax.net.ssl.KeyManager; + + +/** + * @since 3.1 + */ +public class BaseSSLContext { + private static KeyManager[] _keyManagers; + + public static void setKeyManagers(KeyManager[] keyManagers){ + _keyManagers = keyManagers; + } + + public static KeyManager[] getKeyManagers(){ + return _keyManagers; + } +} diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java index e389d89c456..60a993e7c9b 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types * Noriaki Takatsu (IBM) - [259905][api] Provide a facility to use its own keystore + * David McKnight (IBM) - [259905][api] provide public API for getting/setting key managers for SSLContext *******************************************************************************/ package org.eclipse.dstore.internal.core.util.ssl; @@ -25,18 +26,13 @@ import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; +import org.eclipse.dstore.core.util.ssl.BaseSSLContext; import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; import org.eclipse.dstore.core.util.ssl.IDataStoreTrustManager; public class DStoreSSLContext { - private static KeyManager[] _keyManagers; - - public static void setKeyManager(KeyManager[] keyManagers) - { - _keyManagers = keyManagers; - } public static SSLContext getServerSSLContext(String filePath, String password) { @@ -44,7 +40,8 @@ public class DStoreSSLContext try { - if (_keyManagers == null) + KeyManager[] keyManagers = BaseSSLContext.getKeyManagers(); + if (keyManagers == null) { KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password); String keymgrAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); @@ -57,7 +54,7 @@ public class DStoreSSLContext else { serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$ - serverContext.init(_keyManagers, null, null); + serverContext.init(keyManagers, null, null); } } @@ -81,7 +78,8 @@ public class DStoreSSLContext mgrs[0] = trustManager; - clientContext.init(_keyManagers, mgrs, null); + KeyManager[] keyManagers = BaseSSLContext.getKeyManagers(); + clientContext.init(keyManagers, mgrs, null); } catch (Exception e) {