You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2018/11/22 21:38:00 UTC
[directory-studio] 01/01: Delete JNDI connection provider and
provider selection from UI
This is an automated email from the ASF dual-hosted git repository.
seelmann pushed a commit to branch remove-jndi-provider-and-jndi-layer
in repository https://gitbox.apache.org/repos/asf/directory-studio.git
commit 66c9dd83a0763fd736c6d2ac2d4c00276bba6a80
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Thu Nov 22 22:37:33 2018 +0100
Delete JNDI connection provider and provider selection from UI
---
.../studio/connection/core/Connection.java | 42 +-
.../core/ConnectionActionFilterAdapter.java | 6 -
.../connection/core/ConnectionCoreConstants.java | 12 -
.../connection/core/ConnectionCorePlugin.java | 71 -
.../core/ConnectionCorePreferencesInitializer.java | 4 -
.../connection/core/ConnectionParameter.java | 51 +-
.../studio/connection/core/io/ConnectionIO.java | 27 -
.../core/io/jndi/DummySSLSocketFactory.java | 215 ---
.../core/io/jndi/JNDIConnectionWrapper.java | 1571 --------------------
.../core/io/jndi/JNDISubentriesControl.java | 57 -
.../core/io/jndi/JndiStudioNamingEnumeration.java | 400 -----
.../core/io/jndi/StudioSSLSocketFactory.java | 227 ---
.../ui/preferences/ConnectionsPreferencePage.java | 53 -
.../ui/widgets/NetworkParameterPage.java | 93 +-
.../apacheds/CreateConnectionAction.java | 3 -
.../core/ConnectionWrapperTestBase.java | 74 +-
.../core/DirectoryApiConnectionWrapperTest.java | 12 +-
.../core/JNDIConnectionWrapperTest.java | 44 -
.../test/integration/ui/EntryEditorTest.java | 1 -
.../test/integration/ui/NewEntryWizardTest.java | 1 -
.../integration/ui/bots/ConnectionsViewBot.java | 17 -
.../ui/bots/NewConnectionWizardBot.java | 17 -
22 files changed, 24 insertions(+), 2974 deletions(-)
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
index 958ffec..76497df 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
@@ -28,11 +28,9 @@ import org.apache.directory.studio.connection.core.ConnectionParameter.Authentic
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.Krb5Configuration;
import org.apache.directory.studio.connection.core.ConnectionParameter.Krb5CredentialConfiguration;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
import org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper;
-import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.IActionFilter;
@@ -208,7 +206,7 @@ public class Connection implements ConnectionPropertyPageProvider, IAdaptable
public Object clone()
{
ConnectionParameter cp = new ConnectionParameter( getName(), getHost(), getPort(), getEncryptionMethod(),
- getNetworkProvider(), getAuthMethod(), getBindPrincipal(), getBindPassword(), getSaslRealm(), isReadOnly(),
+ getAuthMethod(), getBindPrincipal(), getBindPassword(), getSaslRealm(), isReadOnly(),
getConnectionParameter().getExtendedProperties() , getTimeoutMillis() );
return new Connection( cp );
@@ -222,32 +220,7 @@ public class Connection implements ConnectionPropertyPageProvider, IAdaptable
*/
public ConnectionWrapper getConnectionWrapper()
{
- if ( getNetworkProvider() == NetworkProvider.JNDI && NetworkProvider.JNDI.isSupported() )
- {
- return getJndiConnectionWrapper();
- }
- else
- {
- return getDirectoryApiConnectionWrapper();
-
- }
- }
-
-
- /**
- * Gets the JNDI connection wrapper.
- *
- * @return
- * the JNDI connection wrapper
- */
- private ConnectionWrapper getJndiConnectionWrapper()
- {
- if ( !( connectionWrapper instanceof JNDIConnectionWrapper ) )
- {
- connectionWrapper = new JNDIConnectionWrapper( this );
- }
-
- return connectionWrapper;
+ return getDirectoryApiConnectionWrapper();
}
@@ -358,17 +331,6 @@ public class Connection implements ConnectionPropertyPageProvider, IAdaptable
/**
- * Gets the network provider.
- *
- * @return the network provider
- */
- public NetworkProvider getNetworkProvider()
- {
- return connectionParameter.getNetworkProvider();
- }
-
-
- /**
* Gets the id.
*
* @return the id
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionActionFilterAdapter.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionActionFilterAdapter.java
index bbb0146..825a9e5 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionActionFilterAdapter.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionActionFilterAdapter.java
@@ -37,7 +37,6 @@ public class ConnectionActionFilterAdapter implements IActionFilter
private static final String HOST = "host"; //$NON-NLS-1$
private static final String PORT = "port"; //$NON-NLS-1$
private static final String ENCRYPTION_METHOD = "encryptionMethod"; //$NON-NLS-1$
- private static final String NETWORK_PROVIDER = "networkProvider"; //$NON-NLS-1$
private static final String AUTH_METHOD = "authMethod"; //$NON-NLS-1$
private static final String BIND_PRINCIPAL = "bindPrincipal"; //$NON-NLS-1$
private static final String BIND_PASSWORD = "bindPassword"; //$NON-NLS-1$
@@ -118,11 +117,6 @@ public class ConnectionActionFilterAdapter implements IActionFilter
{
return value.equals( connection.getEncryptionMethod().toString() );
}
- // NETWORK PROVIDER
- else if ( NETWORK_PROVIDER.equals( name ) )
- {
- return value.equals( connection.getNetworkProvider().toString() );
- }
// AUTH METHOD
else if ( AUTH_METHOD.equals( name ) )
{
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
index f8384bf..736e4d7 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
@@ -55,9 +55,6 @@ public final class ConnectionCoreConstants
/** The constant used to identify if certificates for secure connections should be validated */
public static final String PREFERENCE_VALIDATE_CERTIFICATES = "validateCertificates"; //$NON-NLS-1$
- /** The constant used to identify the preferred LDAP context factory */
- public static final String PREFERENCE_LDAP_CONTEXT_FACTORY = "ldapContextFactory"; //$NON-NLS-1$
-
/** The constant used to identify the "enable modification logs" preference */
public static final String PREFERENCE_MODIFICATIONLOGS_ENABLE = "modificationLogsEnable"; //$NON-NLS-1$
@@ -88,15 +85,6 @@ public final class ConnectionCoreConstants
/** The constant used to identify the KRB5 login module class name */
public static final String PREFERENCE_KRB5_LOGIN_MODULE = "krb5LoginModule"; //$NON-NLS-1$
- /** The constant used to identify the default network provider setting */
- public static final String PREFERENCE_DEFAULT_NETWORK_PROVIDER = "defaultNetworkProvider"; //$NON-NLS-1$
-
- /** The constant used to identify the 'JNDI' value for the default network provider setting */
- public static final int PREFERENCE_NETWORK_PROVIDER_JNDI = 0;
-
- /** The constant used to identify the 'Apache Directory LDAP API' value for the default provider setting */
- public static final int PREFERENCE_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API = 1;
-
/** The constant used to identify if connections passwords should be stored in a keystore */
public static final String PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE = "connectionsPasswordsKeystore"; //$NON-NLS-1$
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java
index 437d308..94d3cf9 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java
@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.PropertyResourceBundle;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.core.event.CoreEventRunner;
import org.apache.directory.studio.connection.core.event.EventRunner;
import org.apache.directory.studio.connection.core.io.jndi.LdifModificationLogger;
@@ -530,44 +529,6 @@ public class ConnectionCorePlugin extends Plugin
/**
- * Gets the default LDAP context factory.
- *
- * Right now the following context factories are supported:
- * <ul>
- * <li>com.sun.jndi.ldap.LdapCtxFactory</li>
- * <li>org.apache.harmony.jndi.provider.ldap.LdapContextFactory</li>
- * </ul>
- *
- * @return the default LDAP context factory
- */
- public String getDefaultLdapContextFactory()
- {
- String defaultLdapContextFactory = ""; //$NON-NLS-1$
-
- try
- {
- String sun = "com.sun.jndi.ldap.LdapCtxFactory"; //$NON-NLS-1$
- Class.forName( sun );
- defaultLdapContextFactory = sun;
- }
- catch ( ClassNotFoundException e )
- {
- }
- try
- {
- String apache = "org.apache.harmony.jndi.provider.ldap.LdapContextFactory"; //$NON-NLS-1$
- Class.forName( apache );
- defaultLdapContextFactory = apache;
- }
- catch ( ClassNotFoundException e )
- {
- }
-
- return defaultLdapContextFactory;
- }
-
-
- /**
* Gets the default KRB5 login module.
*
* Right now the following context factories are supported:
@@ -604,36 +565,4 @@ public class ConnectionCorePlugin extends Plugin
return defaultKrb5LoginModule;
}
-
- /**
- * Gets the default network provider from the preferences store.
- *
- * @return the default network provider
- */
- public NetworkProvider getDefaultNetworkProvider()
- {
- return getNetworkProvider( getPluginPreferences().getInt(
- ConnectionCoreConstants.PREFERENCE_DEFAULT_NETWORK_PROVIDER ) );
- }
-
-
- /**
- * Gets the network provider associated with the value.
- *
- * @param networkProviderValue the network provider value
- *
- * @return the network provider
- */
- public NetworkProvider getNetworkProvider( int networkProviderValue )
- {
- if ( networkProviderValue == ConnectionCoreConstants.PREFERENCE_NETWORK_PROVIDER_JNDI
- && NetworkProvider.JNDI.isSupported() )
- {
- return NetworkProvider.JNDI;
- }
- else
- {
- return NetworkProvider.APACHE_DIRECTORY_LDAP_API;
- }
- }
}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java
index 88a8517..7b4af45 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java
@@ -40,14 +40,10 @@ public class ConnectionCorePreferencesInitializer extends AbstractPreferenceInit
Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences();
// LDAP connection settings
- String defaultLdapContextFactory = ConnectionCorePlugin.getDefault().getDefaultLdapContextFactory();
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_LDAP_CONTEXT_FACTORY, defaultLdapContextFactory );
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_VALIDATE_CERTIFICATES, true );
String defaultKrb5LoginModule = ConnectionCorePlugin.getDefault().getDefaultKrb5LoginModule();
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_KRB5_LOGIN_MODULE, defaultKrb5LoginModule );
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_USE_KRB5_SYSTEM_PROPERTIES, false );
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_DEFAULT_NETWORK_PROVIDER,
- ConnectionCoreConstants.PREFERENCE_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API );
// Modification Logs
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, true );
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
index 44007f8..caa01df 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.commons.lang.SystemUtils;
import org.apache.directory.api.ldap.model.constants.SaslQoP;
import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
@@ -59,28 +58,6 @@ public class ConnectionParameter
}
/**
- * Enum for the network provider.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
- public enum NetworkProvider
- {
- /** JNDI */
- JNDI,
-
- /** Apache Directory LDAP API */
- APACHE_DIRECTORY_LDAP_API
- ;
- public boolean isSupported() {
- if(this == APACHE_DIRECTORY_LDAP_API) {
- return true;
- } else /* JNDI */ {
- return SystemUtils.JAVA_VERSION_FLOAT < 9.0f;
- }
- }
- }
-
- /**
* Enum for the used authentication method.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -144,9 +121,6 @@ public class ConnectionParameter
/** The encryption method. */
private EncryptionMethod encryptionMethod;
- /** The network provider. */
- private NetworkProvider networkProvider;
-
/** The authentication method. */
private AuthenticationMethod authMethod;
@@ -221,7 +195,7 @@ public class ConnectionParameter
* @param timeoutMillis the timeout in milliseconds
*/
public ConnectionParameter( String name, String host, int port, EncryptionMethod encryptionMethod,
- NetworkProvider networkProvider, AuthenticationMethod authMethod, String bindPrincipal, String bindPassword,
+ AuthenticationMethod authMethod, String bindPrincipal, String bindPassword,
String saslRealm, boolean isReadOnly, Map<String, String> extendedProperties, long timeoutMillis )
{
this.id = createId();
@@ -229,7 +203,6 @@ public class ConnectionParameter
this.host = host;
this.port = port;
this.encryptionMethod = encryptionMethod;
- this.networkProvider = networkProvider;
this.authMethod = authMethod;
this.bindPrincipal = bindPrincipal;
this.bindPassword = bindPassword;
@@ -379,28 +352,6 @@ public class ConnectionParameter
/**
- * Gets the network provider.
- *
- * @return the network provider
- */
- public NetworkProvider getNetworkProvider()
- {
- return networkProvider;
- }
-
-
- /**
- * Sets the network provider.
- *
- * @param networkProvider the network provider
- */
- public void setNetworkProvider( NetworkProvider networkProvider )
- {
- this.networkProvider = networkProvider;
- }
-
-
- /**
* Gets the id.
*
* @return the id
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
index a8caabb..699a174 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
@@ -30,14 +30,12 @@ import java.util.Set;
import org.apache.directory.api.ldap.model.constants.SaslQoP;
import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
-import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionFolder;
import org.apache.directory.studio.connection.core.ConnectionParameter;
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.Krb5Configuration;
import org.apache.directory.studio.connection.core.ConnectionParameter.Krb5CredentialConfiguration;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -63,7 +61,6 @@ public class ConnectionIO
private static final String HOST_TAG = "host"; //$NON-NLS-1$
private static final String PORT_TAG = "port"; //$NON-NLS-1$
private static final String ENCRYPTION_METHOD_TAG = "encryptionMethod"; //$NON-NLS-1$
- private static final String NETWORK_PROVIDER_TAG = "networkProvider"; //$NON-NLS-1$
private static final String AUTH_METHOD_TAG = "authMethod"; //$NON-NLS-1$
private static final String BIND_PRINCIPAL_TAG = "bindPrincipal"; //$NON-NLS-1$
private static final String BIND_PASSWORD_TAG = "bindPassword"; //$NON-NLS-1$
@@ -214,27 +211,6 @@ public class ConnectionIO
}
}
- // Network Provider
- Attribute networkProviderAttribute = element.attribute( NETWORK_PROVIDER_TAG );
-
- if ( networkProviderAttribute != null )
- {
- try
- {
- connection.setNetworkProvider( NetworkProvider.valueOf( networkProviderAttribute.getValue() ) );
- }
- catch ( IllegalArgumentException e )
- {
- throw new ConnectionIOException( "Unable to parse 'Network Provider' of connection '" //$NON-NLS-1$
- + connection.getName() + "' as int value. Network Provider value :" //$NON-NLS-1$
- + networkProviderAttribute.getValue() );
- }
- }
- else
- {
- connection.setNetworkProvider( ConnectionCorePlugin.getDefault().getDefaultNetworkProvider() );
- }
-
// Auth Method
Attribute authMethodAttribute = element.attribute( AUTH_METHOD_TAG );
@@ -493,9 +469,6 @@ public class ConnectionIO
// Encryption Method
connectionElement.addAttribute( ENCRYPTION_METHOD_TAG, connection.getEncryptionMethod().toString() );
- // Network Parameter
- connectionElement.addAttribute( NETWORK_PROVIDER_TAG, connection.getNetworkProvider().toString() );
-
// Auth Method
connectionElement.addAttribute( AUTH_METHOD_TAG, connection.getAuthMethod().toString() );
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/DummySSLSocketFactory.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/DummySSLSocketFactory.java
deleted file mode 100644
index 8e9b658..0000000
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/DummySSLSocketFactory.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.studio.connection.core.io.jndi;
-
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.SecureRandom;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-
-/**
- * A SSLSocketFactory that accepts every certificate without validation.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class DummySSLSocketFactory extends SSLSocketFactory
-{
-
- /** The default instance. */
- private static SSLSocketFactory instance;
-
-
- /**
- * Gets the default instance.
- *
- * Note: This method is invoked from the JNDI framework when
- * creating a ldaps:// connection.
- *
- * @return the default instance
- */
- public static SSLSocketFactory getDefault()
- {
- if ( instance == null )
- {
- instance = new DummySSLSocketFactory();
- }
- return instance;
- }
-
- /** The delegate. */
- private SSLSocketFactory delegate;
-
-
- /**
- * Creates a new instance of DummySSLSocketFactory.
- *
- * Note: This method is invoked from the JNDI (Apache Harmony)
- * when creating a ldaps:// connection. Must be public!
- */
- public DummySSLSocketFactory()
- {
- try
- {
- TrustManager tm = new X509TrustManager()
- {
- public X509Certificate[] getAcceptedIssuers()
- {
- return new X509Certificate[0];
- }
-
-
- public void checkClientTrusted( X509Certificate[] arg0, String arg1 ) throws CertificateException
- {
- }
-
-
- public void checkServerTrusted( X509Certificate[] arg0, String arg1 ) throws CertificateException
- {
- }
- };
- TrustManager[] tma =
- { tm };
- SSLContext sc = SSLContext.getInstance( "TLS" ); //$NON-NLS-1$
- sc.init( null, tma, new SecureRandom() );
- delegate = sc.getSocketFactory();
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String[] getDefaultCipherSuites()
- {
- return delegate.getDefaultCipherSuites();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String[] getSupportedCipherSuites()
- {
- return delegate.getSupportedCipherSuites();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( Socket s, String host, int port, boolean autoClose ) throws IOException
- {
- try
- {
- return delegate.createSocket( s, host, port, autoClose );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( String host, int port ) throws IOException, UnknownHostException
- {
- try
- {
- return delegate.createSocket( host, port );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( InetAddress host, int port ) throws IOException
- {
- try
- {
- return delegate.createSocket( host, port );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( String host, int port, InetAddress localHost, int localPort ) throws IOException,
- UnknownHostException
- {
- try
- {
- return delegate.createSocket( host, port, localHost, localPort );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( InetAddress address, int port, InetAddress localhAddress, int localPort )
- throws IOException
- {
- try
- {
- return delegate.createSocket( address, port, localhAddress, localPort );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
deleted file mode 100644
index fac60e7..0000000
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
+++ /dev/null
@@ -1,1571 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.studio.connection.core.io.jndi;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-
-import javax.naming.CommunicationException;
-import javax.naming.CompositeName;
-import javax.naming.Context;
-import javax.naming.InsufficientResourcesException;
-import javax.naming.InvalidNameException;
-import javax.naming.Name;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.PartialResultException;
-import javax.naming.ReferralException;
-import javax.naming.ServiceUnavailableException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.Control;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.LdapName;
-import javax.naming.ldap.StartTlsRequest;
-import javax.naming.ldap.StartTlsResponse;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.AppConfigurationEntry;
-import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
-import javax.security.auth.login.Configuration;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-import javax.security.sasl.Sasl;
-
-import org.apache.directory.api.util.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.directory.api.ldap.model.constants.SaslQoP;
-import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
-import org.apache.directory.api.ldap.model.exception.LdapURLEncodingException;
-import org.apache.directory.api.ldap.model.message.Referral;
-import org.apache.directory.api.ldap.model.message.ReferralImpl;
-import org.apache.directory.api.ldap.model.url.LdapUrl;
-import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
-import org.apache.directory.studio.connection.core.Connection;
-import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
-import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
-import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
-import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
-import org.apache.directory.studio.connection.core.ConnectionParameter;
-import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
-import org.apache.directory.studio.connection.core.IAuthHandler;
-import org.apache.directory.studio.connection.core.ICredentials;
-import org.apache.directory.studio.connection.core.IJndiLogger;
-import org.apache.directory.studio.connection.core.Messages;
-import org.apache.directory.studio.connection.core.Utils;
-import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
-import org.apache.directory.studio.connection.core.io.ConnectionWrapperUtils;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.osgi.util.NLS;
-
-
-/**
- * A connection wrapper that uses JNDI.
- *
- * - asychron + cancelable
- * - SSL certificate
- * - manages broken/closed connections
- * - delete old Rdn
- * - exception handling
- * - referral handling
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class JNDIConnectionWrapper implements ConnectionWrapper
-{
- private static final String JAVA_NAMING_LDAP_DELETE_RDN = "java.naming.ldap.deleteRDN"; //$NON-NLS-1$
-
- private static final String AUTHMETHOD_NONE = "none"; //$NON-NLS-1$
-
- private static final String AUTHMETHOD_SIMPLE = "simple"; //$NON-NLS-1$
-
- private static final String AUTHMETHOD_DIGEST_MD5 = "DIGEST-MD5"; //$NON-NLS-1$
-
- private static final String AUTHMETHOD_CRAM_MD5 = "CRAM-MD5"; //$NON-NLS-1$
-
- private static final String AUTHMETHOD_GSSAPI = "GSSAPI"; //$NON-NLS-1$
-
- private static final String NO_CONNECTION = "No connection"; //$NON-NLS-1$
-
- private static final String JAVA_NAMING_SECURITY_SASL_REALM = "java.naming.security.sasl.realm"; //$NON-NLS-1$
-
- private static final String JAVA_NAMING_LDAP_FACTORY_SOCKET = "java.naming.ldap.factory.socket"; //$NON-NLS-1$
-
- private static final String COM_SUN_JNDI_DNS_TIMEOUT_RETRIES = "com.sun.jndi.dns.timeout.retries"; //$NON-NLS-1$
-
- private static final String COM_SUN_JNDI_DNS_TIMEOUT_INITIAL = "com.sun.jndi.dns.timeout.initial"; //$NON-NLS-1$
-
- private static final String COM_SUN_JNDI_LDAP_CONNECT_TIMEOUT = "com.sun.jndi.ldap.connect.timeout"; //$NON-NLS-1$
-
- private static final String JAVA_NAMING_LDAP_VERSION = "java.naming.ldap.version"; //$NON-NLS-1$
-
- private static final String JAVA_NAMING_LDAP_DEREF_ALIASES = "java.naming.ldap.derefAliases"; //$NON-NLS-1$
-
- private static final String JAVA_NAMING_LDAP_ATTRIBUTES_BINARY = "java.naming.ldap.attributes.binary"; //$NON-NLS-1$
-
- private static int searchRequestNum = 0;
-
- private Connection connection;
-
- private boolean useLdaps;
-
- private boolean useStartTLS;
-
- private String authMethod;
-
- private String bindPrincipal;
-
- private String bindCredentials;
-
- private String saslRealm;
-
- private Hashtable<String, String> environment;
-
- private InitialLdapContext context;
-
- private boolean isConnected;
-
- private Thread jobThread;
-
- private Collection<String> binaryAttributes;
-
- /** JNDI constant for "throw" referrals handling */
- public static final String REFERRAL_THROW = "throw"; //$NON-NLS-1$
-
- /** JNDI constant for "follow" referrals handling */
- public static final String REFERRAL_FOLLOW = "follow"; //$NON-NLS-1$
-
- /** JNDI constant for "ignore" referrals handling */
- public static final String REFERRAL_IGNORE = "ignore"; //$NON-NLS-1$
-
- /** JNDI constant for "searching" alias dereferencing */
- public static final String ALIAS_SEARCHING = "searching"; //$NON-NLS-1$
-
- /** JNDI constant for "finding" alias dereferencing */
- public static final String ALIAS_FINDING = "finding"; //$NON-NLS-1$
-
- /** JNDI constant for "always" alias dereferencing */
- public static final String ALIAS_ALWAYS = "always"; //$NON-NLS-1$
-
- /** JNDI constant for "never" alias dereferencing */
- public static final String ALIAS_NEVER = "never"; //$NON-NLS-1$
-
-
- /**
- * Creates a new instance of JNDIConnectionContext.
- *
- * @param connection the connection
- */
- public JNDIConnectionWrapper( Connection connection )
- {
- this.connection = connection;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void connect( StudioProgressMonitor monitor )
- {
- context = null;
- isConnected = false;
- jobThread = null;
-
- try
- {
- doConnect( monitor );
- }
- catch ( NamingException ne )
- {
- disconnect();
- monitor.reportError( ne );
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void disconnect()
- {
- if ( jobThread != null )
- {
- Thread t = jobThread;
- jobThread = null;
- t.interrupt();
- }
- if ( context != null )
- {
- try
- {
- context.close();
- }
- catch ( NamingException e )
- {
- // ignore
- }
- context = null;
- }
- isConnected = false;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void bind( StudioProgressMonitor monitor )
- {
- try
- {
- doBind( monitor );
- }
- catch ( NamingException ne )
- {
- disconnect();
- monitor.reportError( ne );
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void unbind()
- {
- disconnect();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public boolean isConnected()
- {
- return context != null;
- }
-
-
- /**
- * Sets the binary attributes.
- *
- * @param binaryAttributes the binary attributes
- */
- public void setBinaryAttributes( Collection<String> binaryAttributes )
- {
- this.binaryAttributes = binaryAttributes;
- StringBuilder sb = new StringBuilder();
-
- for ( String string : binaryAttributes )
- {
- sb.append( string ).append( ' ' );
- }
-
- String binaryAttributesString = sb.toString();
-
- if ( environment != null )
- {
- environment.put( JAVA_NAMING_LDAP_ATTRIBUTES_BINARY, binaryAttributesString );
- }
-
- if ( context != null )
- {
- try
- {
- context.addToEnvironment( JAVA_NAMING_LDAP_ATTRIBUTES_BINARY, binaryAttributesString );
- }
- catch ( NamingException e )
- {
- // TODO: logging
- e.printStackTrace();
- }
- }
- }
-
-
- /**
- * Search.
- *
- * @param searchBase the search base
- * @param filter the filter
- * @param searchControls the controls
- * @param aliasesDereferencingMethod the aliases dereferencing method
- * @param referralsHandlingMethod the referrals handling method
- * @param controls the LDAP controls
- * @param monitor the progress monitor
- * @param referralsInfo the referrals info
- *
- * @return the naming enumeration or null if an exception occurs.
- */
- public JndiStudioNamingEnumeration search( final String searchBase, final String filter,
- final SearchControls searchControls, final AliasDereferencingMethod aliasesDereferencingMethod,
- final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
- final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
- {
- final long requestNum = searchRequestNum++;
-
- // start
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- LdapContext searchCtx = context;
- try
- {
- // create the search context
- searchCtx = context.newInstance( controls );
-
- // translate alias dereferencing method
- searchCtx.addToEnvironment( JAVA_NAMING_LDAP_DEREF_ALIASES,
- translateDerefAliasMethod( aliasesDereferencingMethod ) );
-
- // use "throw" as we handle referrals manually
- searchCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
-
- // perform the search
- NamingEnumeration<SearchResult> result = searchCtx.search( JNDIConnectionWrapper
- .getSaveJndiName( searchBase ), filter, searchControls );
- namingEnumeration = new JndiStudioNamingEnumeration( connection, searchCtx, result, null,
- searchBase, filter, searchControls, aliasesDereferencingMethod, referralsHandlingMethod,
- controls, requestNum, monitor, referralsInfo );
- }
- catch ( PartialResultException | ReferralException e )
- {
- namingEnumeration = new JndiStudioNamingEnumeration( connection, searchCtx, null, e, searchBase,
- filter, searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls,
- requestNum, monitor, referralsInfo );
- }
- catch ( NamingException e )
- {
- namingException = e;
- }
-
- for ( IJndiLogger logger : getJndiLoggers() )
- {
- if ( namingEnumeration != null )
- {
- logger.logSearchRequest( connection, searchBase, filter, searchControls,
- aliasesDereferencingMethod, controls, requestNum, namingException );
- }
- else
- {
- logger.logSearchRequest( connection, searchBase, filter, searchControls,
- aliasesDereferencingMethod, controls, requestNum, namingException );
- logger.logSearchResultDone( connection, 0, requestNum, namingException );
- }
- }
- }
- };
-
- try
- {
- checkConnectionAndRunAndMonitor( runnable, monitor );
- }
- catch ( NamingException ne )
- {
- monitor.reportError( ne );
- return null;
- }
-
- if ( runnable.isCanceled() )
- {
- monitor.setCanceled( true );
- }
- if ( runnable.getException() != null )
- {
- monitor.reportError( runnable.getException() );
- return null;
- }
- else
- {
- return runnable.getResult();
- }
- }
-
-
- /**
- * Modifies attributes of an entry.
- *
- * @param dn the Dn
- * @param modificationItems the modification items
- * @param controls the controls
- * @param monitor the progress monitor
- * @param referralsInfo the referrals info
- */
- public void modifyEntry( final String dn, final ModificationItem[] modificationItems, final Control[] controls,
- final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
- {
- if ( connection.isReadOnly() )
- {
- monitor
- .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly, connection.getName() ) ) );
- return;
- }
-
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- try
- {
- // create modify context
- LdapContext modCtx = context.newInstance( controls );
-
- // use "throw" as we handle referrals manually
- modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
-
- // perform modification
- modCtx.modifyAttributes( getSaveJndiName( dn ), modificationItems );
- }
- catch ( ReferralException re )
- {
- try
- {
- ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
- Referral referral = newReferralsInfo.getNextReferral();
-
- if ( referral != null )
- {
- Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
- monitor, this );
- if ( referralConnection != null )
- {
- List<String> urls = new ArrayList<>( referral.getLdapUrls() );
-
- String referralDn = new LdapUrl( urls.get( 0 ) ).getDn().getName();
- referralConnection.getConnectionWrapper().modifyEntry( referralDn,
- modificationItems, controls, monitor, newReferralsInfo );
- }
- else
- {
- canceled = true;
- }
- }
-
- return;
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
- catch ( LdapURLEncodingException e )
- {
- namingException = new NamingException( e.getMessage() );
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
-
- for ( IJndiLogger logger : getJndiLoggers() )
- {
- logger.logChangetypeModify( connection, dn, modificationItems, controls, namingException );
- }
- }
- };
-
- try
- {
- checkConnectionAndRunAndMonitor( runnable, monitor );
- }
- catch ( NamingException ne )
- {
- monitor.reportError( ne );
- }
-
- if ( runnable.isCanceled() )
- {
- monitor.setCanceled( true );
- }
- if ( runnable.getException() != null )
- {
- monitor.reportError( runnable.getException() );
- }
- }
-
-
- /**
- * Renames an entry.
- *
- * @param oldDn the old Dn
- * @param newDn the new Dn
- * @param deleteOldRdn true to delete the old Rdn
- * @param controls the controls
- * @param monitor the progress monitor
- * @param referralsInfo the referrals info
- */
- public void renameEntry( final String oldDn, final String newDn, final boolean deleteOldRdn,
- final Control[] controls, final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
- {
- if ( connection.isReadOnly() )
- {
- monitor
- .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly, connection.getName() ) ) );
- return;
- }
-
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- try
- {
- // create modify context
- LdapContext modCtx = context.newInstance( controls );
-
- // use "throw" as we handle referrals manually
- modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
-
- // delete old Rdn
- if ( deleteOldRdn )
- {
- modCtx.addToEnvironment( JAVA_NAMING_LDAP_DELETE_RDN, "true" ); //$NON-NLS-1$
- }
- else
- {
- modCtx.addToEnvironment( JAVA_NAMING_LDAP_DELETE_RDN, "false" ); //$NON-NLS-1$
- }
-
- // rename entry
- modCtx.rename( getSaveJndiName( oldDn ), getSaveJndiName( newDn ) );
- }
- catch ( ReferralException re )
- {
- try
- {
- ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
- Referral referral = newReferralsInfo.getNextReferral();
- if ( referral != null )
- {
- Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
- monitor, this );
- if ( referralConnection != null )
- {
- referralConnection.getConnectionWrapper().renameEntry( oldDn, newDn, deleteOldRdn,
- controls, monitor, newReferralsInfo );
- }
- else
- {
- canceled = true;
- }
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
-
- for ( IJndiLogger logger : getJndiLoggers() )
- {
- logger.logChangetypeModDn( connection, oldDn, newDn, deleteOldRdn, controls, namingException );
- }
- }
- };
-
- try
- {
- checkConnectionAndRunAndMonitor( runnable, monitor );
- }
- catch ( NamingException ne )
- {
- monitor.reportError( ne );
- }
-
- if ( runnable.isCanceled() )
- {
- monitor.setCanceled( true );
- }
- if ( runnable.getException() != null )
- {
- monitor.reportError( runnable.getException() );
- }
- }
-
-
- /**
- * Creates an entry.
- *
- * @param dn the entry's Dn
- * @param attributes the entry's attributes
- * @param controls the controls
- * @param monitor the progress monitor
- * @param referralsInfo the referrals info
- */
- public void createEntry( final String dn, final Attributes attributes, final Control[] controls,
- final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
- {
- if ( connection.isReadOnly() )
- {
- monitor
- .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly, connection.getName() ) ) );
- return;
- }
-
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- try
- {
- // create modify context
- LdapContext modCtx = context.newInstance( controls );
-
- // use "throw" as we handle referrals manually
- modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
-
- // create entry
- modCtx.createSubcontext( getSaveJndiName( dn ), attributes );
- }
- catch ( ReferralException re )
- {
- try
- {
- ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
- Referral referral = newReferralsInfo.getNextReferral();
-
- if ( referral != null )
- {
- Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
- monitor, this );
-
- if ( referralConnection != null )
- {
- List<String> urls = new ArrayList<>( referral.getLdapUrls() );
-
- String referralDn = new LdapUrl( urls.get( 0 ) ).getDn().getName();
- referralConnection.getConnectionWrapper().createEntry( referralDn, attributes,
- controls, monitor, newReferralsInfo );
- }
- else
- {
- canceled = true;
- }
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
- catch ( LdapURLEncodingException e )
- {
- namingException = new NamingException( e.getMessage() );
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
-
- for ( IJndiLogger logger : getJndiLoggers() )
- {
- logger.logChangetypeAdd( connection, dn, attributes, controls, namingException );
- }
- }
- };
-
- try
- {
- checkConnectionAndRunAndMonitor( runnable, monitor );
- }
- catch ( NamingException ne )
- {
- monitor.reportError( ne );
- }
-
- if ( runnable.isCanceled() )
- {
- monitor.setCanceled( true );
- }
- if ( runnable.getException() != null )
- {
- monitor.reportError( runnable.getException() );
- }
- }
-
-
- /**
- * Deletes an entry.
- *
- * @param dn the Dn of the entry to delete
- * @param controls the controls
- * @param monitor the progress monitor
- * @param referralsInfo the referrals info
- */
- public void deleteEntry( final String dn, final Control[] controls, final StudioProgressMonitor monitor,
- final ReferralsInfo referralsInfo )
- {
- if ( connection.isReadOnly() )
- {
- monitor
- .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly, connection.getName() ) ) );
- return;
- }
-
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- try
- {
- // create modify context
- LdapContext modCtx = context.newInstance( controls );
-
- // use "throw" as we handle referrals manually
- modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
-
- // delete entry
- modCtx.destroySubcontext( getSaveJndiName( dn ) );
- }
- catch ( ReferralException re )
- {
- try
- {
- ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
- Referral referral = newReferralsInfo.getNextReferral();
- if ( referral != null )
- {
- Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
- monitor, this );
- if ( referralConnection != null )
- {
- List<String> urls = new ArrayList<>( referral.getLdapUrls() );
-
- String referralDn = new LdapUrl( urls.get( 0 ) ).getDn().getName();
- referralConnection.getConnectionWrapper().deleteEntry( referralDn, controls,
- monitor, newReferralsInfo );
- }
- else
- {
- canceled = true;
- }
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
- catch ( LdapURLEncodingException e )
- {
- namingException = new NamingException( e.getMessage() );
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
-
- for ( IJndiLogger logger : getJndiLoggers() )
- {
- logger.logChangetypeDelete( connection, dn, controls, namingException );
- }
- }
- };
-
- try
- {
- checkConnectionAndRunAndMonitor( runnable, monitor );
- }
- catch ( NamingException ne )
- {
- monitor.reportError( ne );
- }
-
- if ( runnable.isCanceled() )
- {
- monitor.setCanceled( true );
- }
- if ( runnable.getException() != null )
- {
- monitor.reportError( runnable.getException() );
- }
- }
-
-
- private void doConnect( final StudioProgressMonitor monitor ) throws NamingException
- {
- context = null;
- isConnected = true;
-
- // setup connection parameters
- String host = connection.getConnectionParameter().getHost();
- int port = connection.getConnectionParameter().getPort();
- long timeoutMillis = connection.getConnectionParameter().getTimeoutMillis();
-
- useLdaps = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.LDAPS;
- useStartTLS = connection.getConnectionParameter().getEncryptionMethod() == ConnectionParameter.EncryptionMethod.START_TLS;
-
- environment = new Hashtable<>();
- Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences();
- final boolean validateCertificates = preferences
- .getBoolean( ConnectionCoreConstants.PREFERENCE_VALIDATE_CERTIFICATES );
- String ldapCtxFactory = preferences.getString( ConnectionCoreConstants.PREFERENCE_LDAP_CONTEXT_FACTORY );
- environment.put( Context.INITIAL_CONTEXT_FACTORY, ldapCtxFactory );
- environment.put( JAVA_NAMING_LDAP_VERSION, "3" ); //$NON-NLS-1$
-
- // timeouts
- /*
- * Don't use a timeout when using ldaps: JNDI throws a SocketException when setting a timeout on SSL connections.
- * See https://bugs.openjdk.java.net/browse/JDK-8173451
- */
- if ( !useLdaps )
- {
- if ( timeoutMillis < 0 )
- {
- timeoutMillis = 0;
- }
- environment.put( COM_SUN_JNDI_LDAP_CONNECT_TIMEOUT, Long.toString( timeoutMillis ) ); //$NON-NLS-1$
- }
-
- environment.put( COM_SUN_JNDI_DNS_TIMEOUT_INITIAL, "2000" ); //$NON-NLS-1$
- environment.put( COM_SUN_JNDI_DNS_TIMEOUT_RETRIES, "3" ); //$NON-NLS-1$
-
- // ldaps://
- if ( useLdaps )
- {
- environment.put( Context.PROVIDER_URL, LdapUrl.LDAPS_SCHEME + host + ':' + port );
- environment.put( Context.SECURITY_PROTOCOL, "ssl" ); //$NON-NLS-1$
- // host name verification is done in StudioTrustManager
- environment.put( JAVA_NAMING_LDAP_FACTORY_SOCKET, validateCertificates ? StudioSSLSocketFactory.class
- .getName() : DummySSLSocketFactory.class.getName() );
- }
- else
- {
- environment.put( Context.PROVIDER_URL, LdapUrl.LDAP_SCHEME + host + ':' + port );
- }
-
- if ( binaryAttributes != null )
- {
- setBinaryAttributes( binaryAttributes );
- }
-
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- try
- {
- context = new InitialLdapContext( environment, null );
-
- if ( useStartTLS )
- {
- try
- {
- StartTlsResponse tls = ( StartTlsResponse ) context
- .extendedOperation( new StartTlsRequest() );
- // deactivate host name verification at this level,
- // host name verification is done in StudioTrustManager
- tls.setHostnameVerifier( ( hostname, session ) -> true );
-
- if ( validateCertificates )
- {
- tls.negotiate( StudioSSLSocketFactory.getDefault() );
- }
- else
- {
- tls.negotiate( DummySSLSocketFactory.getDefault() );
- }
- }
- catch ( Exception e )
- {
- namingException = new NamingException( e.getMessage() != null ? e.getMessage()
- : "Error while establishing TLS session" ); //$NON-NLS-1$
- namingException.setRootCause( e );
- context.close();
- }
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
- }
- };
-
- runAndMonitor( runnable, monitor );
-
- if ( runnable.getException() != null )
- {
- throw runnable.getException();
- }
- else if ( context != null )
- {
- // all OK
- }
- else
- {
- throw new NamingException( "???" ); //$NON-NLS-1$
- }
- }
-
-
- private void doBind( final StudioProgressMonitor monitor ) throws NamingException
- {
- if ( context != null && isConnected )
- {
- // setup authentication methdod
- authMethod = AUTHMETHOD_NONE;
- if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE )
- {
- authMethod = AUTHMETHOD_SIMPLE;
- }
- else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5 )
- {
- authMethod = AUTHMETHOD_DIGEST_MD5;
- saslRealm = connection.getConnectionParameter().getSaslRealm();
- }
- else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5 )
- {
- authMethod = AUTHMETHOD_CRAM_MD5;
- }
- else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_GSSAPI )
- {
- authMethod = AUTHMETHOD_GSSAPI;
- }
-
- // No Authentication
- if ( authMethod == AUTHMETHOD_NONE )
- {
- bindPrincipal = ""; //$NON-NLS-1$
- bindCredentials = ""; //$NON-NLS-1$
- }
- else
- {
- // setup credentials
- IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
- if ( authHandler == null )
- {
- NamingException namingException = new NamingException( Messages.model__no_auth_handler );
- monitor.reportError( Messages.model__no_auth_handler, namingException );
- throw namingException;
- }
- ICredentials credentials = authHandler.getCredentials( connection.getConnectionParameter() );
- if ( credentials == null )
- {
- CancelException cancelException = new CancelException();
- monitor.setCanceled( true );
- monitor.reportError( Messages.model__no_credentials, cancelException );
- throw cancelException;
- }
- if ( credentials.getBindPrincipal() == null || credentials.getBindPassword() == null )
- {
- NamingException namingException = new NamingException( Messages.model__no_credentials );
- monitor.reportError( Messages.model__no_credentials, namingException );
- throw namingException;
- }
- bindPrincipal = credentials.getBindPrincipal();
- bindCredentials = credentials.getBindPassword();
- }
-
- InnerRunnable runnable = new InnerRunnable()
- {
- public void run()
- {
- try
- {
- context.removeFromEnvironment( Context.SECURITY_AUTHENTICATION );
- context.removeFromEnvironment( Context.SECURITY_PRINCIPAL );
- context.removeFromEnvironment( Context.SECURITY_CREDENTIALS );
- context.removeFromEnvironment( JAVA_NAMING_SECURITY_SASL_REALM );
-
- context.addToEnvironment( Context.SECURITY_AUTHENTICATION, authMethod );
-
- // SASL options
- if ( connection.getConnectionParameter().getAuthMethod() == AuthenticationMethod.SASL_CRAM_MD5
- || connection.getConnectionParameter().getAuthMethod() == AuthenticationMethod.SASL_DIGEST_MD5
- || connection.getConnectionParameter().getAuthMethod() == AuthenticationMethod.SASL_GSSAPI )
- {
- // Request quality of protection
- switch ( connection.getConnectionParameter().getSaslQop() )
- {
- case AUTH:
- context.addToEnvironment( Sasl.QOP, SaslQoP.AUTH.getValue() );
- break;
- case AUTH_INT:
- context.addToEnvironment( Sasl.QOP, SaslQoP.AUTH_INT.getValue() );
- break;
- case AUTH_CONF:
- context.addToEnvironment( Sasl.QOP, SaslQoP.AUTH_CONF.getValue() );
- break;
- }
-
- // Request mutual authentication
- if ( connection.getConnectionParameter().isSaslMutualAuthentication() )
- {
- context.addToEnvironment( Sasl.SERVER_AUTH, "true" ); //$NON-NLS-1$
- }
- else
- {
- context.removeFromEnvironment( Sasl.SERVER_AUTH );
- }
-
- // Request cryptographic protection strength
- switch ( connection.getConnectionParameter().getSaslSecurityStrength() )
- {
- case HIGH:
- context.addToEnvironment( Sasl.STRENGTH, SaslSecurityStrength.HIGH.getValue() );
- break;
- case MEDIUM:
- context.addToEnvironment( Sasl.STRENGTH, SaslSecurityStrength.MEDIUM.getValue() );
- break;
- case LOW:
- context.addToEnvironment( Sasl.STRENGTH, SaslSecurityStrength.LOW.getValue() );
- break;
- }
- }
-
- // Bind
- if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_GSSAPI )
- {
- // GSSAPI
- doGssapiBind( this );
- }
- else
- {
- // no GSSAPI
- context.addToEnvironment( Context.SECURITY_PRINCIPAL, bindPrincipal );
- context.addToEnvironment( Context.SECURITY_CREDENTIALS, bindCredentials );
-
- if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5
- && StringUtils.isNotEmpty( saslRealm ) )
- {
- context.addToEnvironment( JAVA_NAMING_SECURITY_SASL_REALM, saslRealm );
- }
-
- context.reconnect( context.getConnectControls() );
- }
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- }
- }
- };
-
- runAndMonitor( runnable, monitor );
-
- if ( runnable.getException() != null )
- {
- throw runnable.getException();
- }
- else if ( context != null )
- {
- // all OK
- }
- else
- {
- throw new NamingException( "???" ); //$NON-NLS-1$
- }
- }
- else
- {
- throw new NamingException( NO_CONNECTION );
- }
- }
-
-
- private void doGssapiBind( final InnerRunnable innerRunnable ) throws NamingException
- {
- File configFile = null;
- try
- {
- Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences();
- boolean useKrb5SystemProperties = preferences
- .getBoolean( ConnectionCoreConstants.PREFERENCE_USE_KRB5_SYSTEM_PROPERTIES );
- String krb5LoginModule = preferences.getString( ConnectionCoreConstants.PREFERENCE_KRB5_LOGIN_MODULE );
-
- if ( !useKrb5SystemProperties )
- {
- // Kerberos Configuration
- switch ( connection.getConnectionParameter().getKrb5Configuration() )
- {
- case DEFAULT:
- // nothing
- System.clearProperty( "java.security.krb5.conf" ); //$NON-NLS-1$
- break;
- case FILE:
- // use specified krb5.conf
- System.setProperty( "java.security.krb5.conf", connection.getConnectionParameter() //$NON-NLS-1$
- .getKrb5ConfigurationFile() );
- break;
- case MANUAL:
- // write manual config parameters to connection specific krb5.conf file
- String fileName = Utils.getFilenameString( connection.getId() ) + ".krb5.conf"; //$NON-NLS-1$
- configFile = ConnectionCorePlugin.getDefault().getStateLocation().append( fileName ).toFile();
- String realm = connection.getConnectionParameter().getKrb5Realm();
- String host = connection.getConnectionParameter().getKrb5KdcHost();
- int port = connection.getConnectionParameter().getKrb5KdcPort();
- StringBuilder sb = new StringBuilder();
- sb.append( "[libdefaults]" ).append( ConnectionCoreConstants.LINE_SEPARATOR ); //$NON-NLS-1$
- sb.append( "default_realm = " ).append( realm ).append( ConnectionCoreConstants.LINE_SEPARATOR ); //$NON-NLS-1$
- sb.append( "[realms]" ).append( ConnectionCoreConstants.LINE_SEPARATOR ); //$NON-NLS-1$
- sb.append( realm ).append( " = {" ).append( ConnectionCoreConstants.LINE_SEPARATOR ); //$NON-NLS-1$
- sb.append( "kdc = " ).append( host ).append( ":" ).append( port ).append( //$NON-NLS-1$ //$NON-NLS-2$
- ConnectionCoreConstants.LINE_SEPARATOR );
- sb.append( "}" ).append( ConnectionCoreConstants.LINE_SEPARATOR ); //$NON-NLS-1$
- try
- {
- FileUtils.writeStringToFile( configFile, sb.toString() );
- }
- catch ( IOException ioe )
- {
- NamingException ne = new NamingException();
- ne.setRootCause( ioe );
- throw ne;
- }
- System.setProperty( "java.security.krb5.conf", configFile.getAbsolutePath() ); //$NON-NLS-1$
- }
-
- // Use our custom configuration so we don't need to mess with external configuration
- Configuration.setConfiguration( new InnerConfiguration( krb5LoginModule ) );
- }
-
- // Gets the TGT, either from native ticket cache or obtain new from KDC
- LoginContext lc = null;
- try
- {
- lc = new LoginContext( this.getClass().getName(), new InnerCallbackHandler() );
- lc.login();
- }
- catch ( LoginException le )
- {
- NamingException ne = new NamingException();
- ne.setRootCause( le );
- throw ne;
- }
-
- // Login to LDAP server, obtains a service ticket from KDC
- Subject.doAs( lc.getSubject(), (PrivilegedAction<Object>)() ->
- {
- try
- {
- context.reconnect( context.getConnectControls() );
- }
- catch ( NamingException ne )
- {
- innerRunnable.namingException = ne;
- }
- return null;
- }
- );
- }
- finally
- {
- // delete temporary config file
- if ( configFile != null && configFile.exists() )
- {
- configFile.delete();
- }
- }
- }
-
-
- private void checkConnectionAndRunAndMonitor( final InnerRunnable runnable, final StudioProgressMonitor monitor )
- throws NamingException
- {
- // check connection
- if ( !isConnected || context == null )
- {
- doConnect( monitor );
- doBind( monitor );
- }
- if ( context == null )
- {
- throw new NamingException( NO_CONNECTION );
- }
-
- // loop for reconnection
- for ( int i = 0; i <= 1; i++ )
- {
- runAndMonitor( runnable, monitor );
-
- // check reconnection
- if ( i == 0
- && ( ( runnable.getException() instanceof CommunicationException )
- || ( runnable.getException() instanceof ServiceUnavailableException ) || ( runnable.getException() instanceof InsufficientResourcesException ) ) )
- {
-
- doConnect( monitor );
- doBind( monitor );
- runnable.reset();
- }
- else
- {
- break;
- }
- }
- }
-
-
- private void runAndMonitor( final InnerRunnable runnable, final StudioProgressMonitor monitor )
- throws CancelException
- {
- if ( !monitor.isCanceled() )
- {
- // monitor
- StudioProgressMonitor.CancelListener listener = event ->
- {
- if ( monitor.isCanceled() )
- {
- if ( jobThread != null && jobThread.isAlive() )
- {
- jobThread.interrupt();
- }
-
- if ( context != null )
- {
- try
- {
- context.close();
- }
- catch ( NamingException ne )
- {
- }
-
- isConnected = false;
- context = null;
- }
-
- isConnected = false;
- }
- };
-
- monitor.addCancelListener( listener );
- jobThread = Thread.currentThread();
-
- // run
- try
- {
- runnable.run();
- }
- finally
- {
- monitor.removeCancelListener( listener );
- jobThread = null;
- }
-
- if ( monitor.isCanceled() )
- {
- throw new CancelException();
- }
- }
- }
-
- private final class InnerConfiguration extends Configuration
- {
- private String krb5LoginModule;
- private AppConfigurationEntry[] configList = null;
-
-
- public InnerConfiguration( String krb5LoginModule )
- {
- this.krb5LoginModule = krb5LoginModule;
- }
-
-
- public AppConfigurationEntry[] getAppConfigurationEntry( String applicationName )
- {
- if ( configList == null )
- {
- HashMap<String, Object> options = new HashMap<>();
-
- // TODO: this only works for Sun JVM
- options.put( "refreshKrb5Config", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
-
- switch ( connection.getConnectionParameter().getKrb5CredentialConfiguration() )
- {
- case USE_NATIVE:
- options.put( "useTicketCache", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
- options.put( "doNotPrompt", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
- break;
-
- case OBTAIN_TGT:
- options.put( "doNotPrompt", "false" ); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
-
- configList = new AppConfigurationEntry[1];
- configList[0] = new AppConfigurationEntry( krb5LoginModule, LoginModuleControlFlag.REQUIRED, options );
- }
- return configList;
- }
-
-
- @Override
- public void refresh()
- {
- }
- }
-
- private final class InnerCallbackHandler implements CallbackHandler
- {
- public void handle( Callback[] callbacks ) throws UnsupportedCallbackException, IOException
- {
- for ( int ii = 0; ii < callbacks.length; ii++ )
- {
- Callback callBack = callbacks[ii];
-
- if ( callBack instanceof NameCallback )
- {
- // Handles username callback.
- NameCallback nameCallback = ( NameCallback ) callBack;
- nameCallback.setName( bindPrincipal );
- }
- else if ( callBack instanceof PasswordCallback )
- {
- // Handles password callback.
- PasswordCallback passwordCallback = ( PasswordCallback ) callBack;
- passwordCallback.setPassword( bindCredentials.toCharArray() );
- }
- else
- {
- throw new UnsupportedCallbackException( callBack, "Callback not supported" ); //$NON-NLS-1$
- }
- }
- }
- }
-
- abstract class InnerRunnable implements Runnable
- {
- protected JndiStudioNamingEnumeration namingEnumeration = null;
- protected NamingException namingException = null;
- protected boolean canceled = false;
-
-
- /**
- * Gets the exception.
- *
- * @return the exception
- */
- public NamingException getException()
- {
- return namingException;
- }
-
-
- /**
- * Gets the result.
- *
- * @return the result
- */
- public JndiStudioNamingEnumeration getResult()
- {
- return namingEnumeration;
- }
-
-
- /**
- * Checks if is canceled.
- *
- * @return true, if is canceled
- */
- public boolean isCanceled()
- {
- return canceled;
- }
-
-
- /**
- * Reset.
- */
- public void reset()
- {
- namingEnumeration = null;
- namingException = null;
- canceled = false;
- }
- }
-
-
- private List<IJndiLogger> getJndiLoggers()
- {
- return ConnectionCorePlugin.getDefault().getJndiLoggers();
- }
-
-
- /**
- * Translates the alias dereferencing method to its JNDI specific string.
- *
- * @param aliasDereferencingMethod the alias dereferencing method
- *
- * @return the JNDI specific alias dereferencing method string
- */
- private String translateDerefAliasMethod( AliasDereferencingMethod aliasDereferencingMethod )
- {
- String m = ALIAS_ALWAYS;
-
- switch ( aliasDereferencingMethod )
- {
- case NEVER:
- m = ALIAS_NEVER;
- break;
- case ALWAYS:
- m = ALIAS_ALWAYS;
- break;
- case FINDING:
- m = ALIAS_FINDING;
- break;
- case SEARCH:
- m = ALIAS_SEARCHING;
- break;
- }
-
- return m;
- }
-
-
- /**
- * Gets a Name object that is save for JNDI operations.
- * <p>
- * In JNDI we have could use the following classes for names:
- * <ul>
- * <li>Dn as String</li>
- * <li>javax.naming.CompositeName</li>
- * <li>javax.naming.ldap.LdapName (since Java5)</li>
- * <li>org.apache.directory.api.ldap.name.LdapDN</li>
- * </ul>
- * <p>
- * There are some drawbacks when using this classes:
- * <ul>
- * <li>When passing Dn as String, JNDI doesn't handle slashes '/' correctly.
- * So we must use a Name object here.</li>
- * <li>With CompositeName we have the same problem with slashes '/'.</li>
- * <li>When using LdapDN from shared-ldap, JNDI uses the toString() method
- * and LdapDN.toString() returns the normalized ATAV, but we need the
- * user provided ATAV.</li>
- * <li>When using LdapName for the empty Dn (Root DSE) JNDI _sometimes_ throws
- * an Exception (java.lang.IndexOutOfBoundsException: Posn: -1, Size: 0
- * at javax.naming.ldap.LdapName.getPrefix(LdapName.java:240)).</li>
- * <li>Using LdapDN for the RootDSE doesn't work with Apache Harmony because
- * its JNDI provider only accepts intstances of CompositeName or LdapName.</li>
- * </ul>
- * <p>
- * So we use LdapName as default and the CompositeName for the empty Dn.
- *
- * @param name the Dn
- *
- * @return the save JNDI name
- *
- * @throws InvalidNameException the invalid name exception
- */
- static Name getSaveJndiName( String name ) throws InvalidNameException
- {
- if ( name == null || StringUtils.isEmpty( name ) ) //$NON-NLS-1$
- {
- return new CompositeName();
- }
- else
- {
- return new LdapName( name );
- }
- }
-
-
- /**
- * Retrieves all referrals from the ReferralException and
- * creates or updates the ReferralsInfo.
- *
- * @param referralException the referral exception
- * @param initialReferralsInfo the initial referrals info, may be null
- *
- * @return the created or updated referrals info
- *
- * @throws NamingException if a loop was encountered.
- */
- static ReferralsInfo handleReferralException( ReferralException referralException,
- ReferralsInfo initialReferralsInfo ) throws NamingException
- {
- if ( initialReferralsInfo == null )
- {
- initialReferralsInfo = new ReferralsInfo( true );
- }
-
- Referral referral = handleReferralException( referralException, initialReferralsInfo, null );
-
- while ( referralException.skipReferral() )
- {
- try
- {
- Context ctx = referralException.getReferralContext();
- ctx.list( StringUtils.EMPTY ); //$NON-NLS-1$
- }
- catch ( NamingException ne )
- {
- if ( ne instanceof ReferralException )
- {
- if ( ne != referralException )
- {
- // what a hack:
- // if the same exception is throw, we have another URL for the same Referral/SearchResultReference
- // if another exception is throws, we have a new Referral/SearchResultReference
- // in the latter case we null out the reference, a new one will be created by handleReferral()
- referral = null;
- }
-
- referralException = ( ReferralException ) ne;
-
- referral = handleReferralException( referralException, initialReferralsInfo, referral );
- }
- else
- {
- break;
- }
- }
- }
-
- return initialReferralsInfo;
- }
-
-
- private static Referral handleReferralException( ReferralException referralException,
- ReferralsInfo initialReferralsInfo, Referral referral )
- {
- String info = ( String ) referralException.getReferralInfo();
-
- if ( referral == null )
- {
- referral = new ReferralImpl();
- initialReferralsInfo.addReferral( referral );
- }
-
- referral.addLdapUrl( info );
-
- return referral;
- }
-
-}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDISubentriesControl.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDISubentriesControl.java
deleted file mode 100644
index ecb787f..0000000
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDISubentriesControl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.studio.connection.core.io.jndi;
-
-
-import javax.naming.ldap.BasicControl;
-
-
-/**
- * The Subentries control.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class JNDISubentriesControl extends BasicControl
-{
-
- private static final long serialVersionUID = -6614360496036854589L;
-
- /**
- * The Subentries control's OID is 1.3.6.1.4.1.4203.1.10.1.
- */
- public static final String OID = "1.3.6.1.4.1.4203.1.10.1"; //$NON-NLS-1$
-
- /**
- * The Subentries control's value.
- */
- public static final byte[] VALUE = new byte[]
- { 0x01, 0x01, ( byte ) 0xFF };
-
-
- /**
- * Creates a new instance of JNDISubentriesControl.
- */
- public JNDISubentriesControl()
- {
- super( OID, false, VALUE );
- }
-
-}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java
deleted file mode 100644
index 6ac6f41..0000000
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.studio.connection.core.io.jndi;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.PartialResultException;
-import javax.naming.ReferralException;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.Control;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.api.ldap.model.exception.LdapURLEncodingException;
-import org.apache.directory.api.ldap.model.message.Referral;
-import org.apache.directory.api.ldap.model.url.LdapUrl;
-import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
-import org.apache.directory.studio.connection.core.Connection;
-import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
-import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
-import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
-import org.apache.directory.studio.connection.core.IJndiLogger;
-import org.apache.directory.studio.connection.core.io.AbstractStudioNamingEnumeration;
-import org.apache.directory.studio.connection.core.io.ConnectionWrapperUtils;
-
-
-/**
- * A naming enumeration that handles referrals itself.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class JndiStudioNamingEnumeration extends AbstractStudioNamingEnumeration
-{
- private final LdapContext ctx;
- private NamingEnumeration<SearchResult> initialNamingEnumeration;
- private NamingEnumeration<SearchResult> delegate;
- private NamingException initialReferralException;
-
-
- /**
- * Creates a new instance of ReferralNamingEnumeration.
- *
- * @param connection the connection
- * @param ctx the JNDI context
- * @param searchBase the search base
- * @param filter the filter
- * @param searchControls the search controls
- * @param aliasesDereferencingMethod the aliases dereferencing method
- * @param referralsHandlingMethod the referrals handling method
- * @param controls the LDAP controls
- * @param monitor the progress monitor
- * @param referralsInfo the referrals info
- */
- public JndiStudioNamingEnumeration( Connection connection, LdapContext ctx,
- NamingEnumeration<SearchResult> delegate,
- NamingException initialReferralException, String searchBase, String filter, SearchControls searchControls,
- AliasDereferencingMethod aliasesDereferencingMethod, ReferralHandlingMethod referralsHandlingMethod,
- Control[] controls, long requestNum, StudioProgressMonitor monitor, ReferralsInfo referralsInfo )
- {
- super( connection, searchBase, filter, searchControls, aliasesDereferencingMethod, referralsHandlingMethod,
- controls, requestNum, monitor, referralsInfo );
- this.ctx = ctx;
- this.initialNamingEnumeration = delegate;
- this.delegate = delegate;
- this.initialReferralException = initialReferralException;
- this.requestNum = requestNum;
- }
-
-
- /**
- * @see javax.naming.NamingEnumeration#close()
- */
- public void close() throws NamingException
- {
- delegate.close();
- }
-
-
- /**
- * @see javax.naming.NamingEnumeration#hasMore()
- */
- public boolean hasMore() throws NamingException
- {
- NamingException logResultDoneException = null;
- boolean done = false;
-
- while ( true )
- {
- try
- {
- if ( initialReferralException != null )
- {
- NamingException referralException = initialReferralException;
- initialReferralException = null;
- throw referralException;
- }
-
- boolean hasMore = delegate != null && delegate.hasMore();
- if ( !hasMore && !done && referralsInfo != null && referralsInfo.hasMoreReferrals() )
- {
- done = checkReferral();
- }
- else
- {
- done = !hasMore;
- return hasMore;
- }
- }
- catch ( PartialResultException pre )
- {
- done = true;
- logResultDoneException = pre;
-
- // ignore exception if referrals handling method is IGNORE
- // report exception if referrals handling method is FOLLOW or MANGAGE
- if ( referralsHandlingMethod == ReferralHandlingMethod.IGNORE )
- {
- return false;
- }
- else
- {
- throw pre;
- }
- }
- catch ( ReferralException re )
- {
- done = true;
- logResultDoneException = re;
- if ( referralsInfo == null )
- {
- referralsInfo = new ReferralsInfo( false );
- }
- referralsInfo = JNDIConnectionWrapper.handleReferralException( re, referralsInfo );
- if ( referralsInfo.hasMoreReferrals() )
- {
- logResultDoneException = null;
- done = checkReferral();
- }
- }
- catch ( NamingException ne )
- {
- done = true;
- logResultDoneException = ne;
- throw ne;
- }
- finally
- {
- if ( done )
- {
- for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() )
- {
- logger.logSearchResultDone( connection, resultEntryCounter, requestNum, logResultDoneException );
- }
- }
- }
- }
- }
-
-
- /**
- * @see java.util.Enumeration#hasMoreElements()
- */
- public boolean hasMoreElements()
- {
- throw new UnsupportedOperationException( "Call hasMore() instead of hasMoreElements() !" ); //$NON-NLS-1$
- }
-
-
- /**
- * @see javax.naming.NamingEnumeration#next()
- */
- public StudioSearchResult next() throws NamingException
- {
- StudioSearchResult studioSearchResult = null;
- NamingException namingException = null;
- try
- {
- SearchResult searchResult = delegate.next();
- resultEntryCounter++;
- if ( searchResult instanceof StudioSearchResult )
- {
- studioSearchResult = ( StudioSearchResult ) searchResult;
- }
- else
- {
- studioSearchResult = new StudioSearchResult( searchResult, getConnection(), referralsInfo != null, null );
- }
- return studioSearchResult;
- }
- catch ( NamingException ne )
- {
- namingException = ne;
- throw ne;
- }
- finally
- {
- if ( delegate == initialNamingEnumeration )
- {
- for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() )
- {
- logger.logSearchResultEntry( connection, studioSearchResult, requestNum, namingException );
- }
- }
- }
- }
-
-
- /**
- * @see java.util.Enumeration#nextElement()
- */
- public StudioSearchResult nextElement()
- {
- throw new UnsupportedOperationException( "Call next() instead of nextElement() !" ); //$NON-NLS-1$
- }
-
-
- /**
- * Gets the connection.
- *
- * @return the connection
- */
- public Connection getConnection()
- {
- if ( delegate instanceof JndiStudioNamingEnumeration )
- {
- return ( ( JndiStudioNamingEnumeration ) delegate ).getConnection();
- }
- else
- {
- return connection;
- }
- }
-
-
- /**
- * Gets the response controls.
- *
- * @return the response controls, may be null
- *
- * @throws NamingException the naming exception
- */
- public Control[] getResponseControls() throws NamingException
- {
- return ctx != null ? ctx.getResponseControls() : null;
- }
-
-
- private boolean checkReferral() throws NamingException
- {
- try
- {
- boolean done = false;
-
- // ignore exception if referrals handling method is IGNORE
- // follow referral if referrals handling method is FOLLOW
- // follow manually if referrals handling method is FOLLOW_MANUALLY
- if ( referralsHandlingMethod == ReferralHandlingMethod.IGNORE )
- {
- done = true;
- delegate = null;
- }
- else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW_MANUALLY )
- {
- delegate = new NamingEnumeration<SearchResult>()
- {
- List<String> urls;
-
- private NamingEnumeration<SearchResult> init() throws NamingException
- {
- urls = new ArrayList<String>();
- {
- while ( referralsInfo.hasMoreReferrals() )
- {
- Referral referral = referralsInfo.getNextReferral();
- for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() )
- {
- logger.logSearchResultReference( connection, referral, referralsInfo, requestNum,
- null );
- }
- urls.addAll( referral.getLdapUrls() );
- }
- }
- return this;
- }
-
-
- public SearchResult nextElement()
- {
- throw new UnsupportedOperationException( "Call next() instead of nextElement() !" ); //$NON-NLS-1$
- }
-
-
- public boolean hasMoreElements()
- {
- throw new UnsupportedOperationException( "Call hasMore() instead of hasMoreElements() !" ); //$NON-NLS-1$
- }
-
-
- public SearchResult next() throws NamingException
- {
- try
- {
- LdapUrl url = new LdapUrl( urls.remove( 0 ) );
- SearchResult searchResult = new SearchResult( url.getDn().getName(), null,
- new BasicAttributes(),
- false );
- searchResult.setNameInNamespace( url.getDn().getName() );
- StudioSearchResult ssr = new StudioSearchResult( searchResult, null, false, url );
- return ssr;
- }
- catch ( LdapURLEncodingException e )
- {
- throw new NamingException( e.getMessage() );
- }
- }
-
-
- public boolean hasMore() throws NamingException
- {
- return !urls.isEmpty();
- }
-
-
- public void close() throws NamingException
- {
- urls.clear();
- referralsInfo = null;
- }
- }.init();
- }
- else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW )
- {
- Referral referral = referralsInfo.getNextReferral();
- for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() )
- {
- logger.logSearchResultReference( connection, referral, referralsInfo, requestNum, null );
- }
- List<String> urls = new ArrayList<String>( referral.getLdapUrls() );
- LdapUrl url = new LdapUrl( urls.get( 0 ) );
- Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral, monitor, this );
- if ( referralConnection != null )
- {
- done = false;
- String referralSearchBase = url.getDn() != null && !url.getDn().isEmpty() ? url.getDn().getName()
- : searchBase;
- String referralFilter = url.getFilter() != null && url.getFilter().length() == 0 ? url.getFilter()
- : filter;
- SearchControls referralSearchControls = new SearchControls();
- referralSearchControls.setSearchScope( url.getScope().getScope() > -1 ? url.getScope().getScope()
- : searchControls
- .getSearchScope() );
- referralSearchControls.setReturningAttributes( url.getAttributes() != null
- && url.getAttributes().size() > 0 ? url.getAttributes().toArray(
- new String[url.getAttributes().size()] ) : searchControls.getReturningAttributes() );
- referralSearchControls.setCountLimit( searchControls.getCountLimit() );
- referralSearchControls.setTimeLimit( searchControls.getTimeLimit() );
- referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() );
- referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );
-
- delegate = referralConnection.getConnectionWrapper().search( referralSearchBase, referralFilter,
- referralSearchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, monitor,
- referralsInfo );
- }
- else
- {
- done = true;
- delegate = null;
- }
- }
- return done;
- }
- catch ( LdapURLEncodingException e )
- {
- return false;
- }
- }
-
-}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java
deleted file mode 100644
index dfd0647..0000000
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.studio.connection.core.io.jndi;
-
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.KeyStore;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.directory.studio.connection.core.io.StudioTrustManager;
-
-
-/**
- * A {@link SSLSocketFactory} that uses a custom {@link TrustManager} ({@link StudioTrustManager}).
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class StudioSSLSocketFactory extends SSLSocketFactory
-{
-
- /**
- * Gets the default instance. In fact just creates a new
- * instance on each call to make sure the underlying
- * TrustManagers are newly initialized.
- *
- * Note: This method is invoked from Sun JNDI when
- * creating a ldaps:// connection. Must be public static!
- *
- * @return the default instance
- */
- public static SSLSocketFactory getDefault()
- {
- return new StudioSSLSocketFactory();
- }
-
- /** The delegate. */
- private SSLSocketFactory delegate;
-
- /** The trust managers. */
- private StudioTrustManager[] trustManagers;
-
-
- /**
- * Creates a new instance of StudioSSLSocketFactory.
- *
- * Note: This default constructor is invoked from Apache Harmony JNDI
- * when creating a ldaps:// connection. Must be public!
- */
- public StudioSSLSocketFactory()
- {
- try
- {
- // get default trust managers (using JVM "cacerts" key store)
- TrustManagerFactory factory = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
- factory.init( ( KeyStore ) null );
- TrustManager[] defaultTrustManagers = factory.getTrustManagers();
-
- // create wrappers around the trust managers
- trustManagers = new StudioTrustManager[defaultTrustManagers.length];
- for ( int i = 0; i < defaultTrustManagers.length; i++ )
- {
- trustManagers[i] = new StudioTrustManager( ( X509TrustManager ) defaultTrustManagers[i] );
- }
-
- // create the real socket factory
- SSLContext sc = SSLContext.getInstance( "TLS" ); //$NON-NLS-1$
- sc.init( null, trustManagers, null );
- delegate = sc.getSocketFactory();
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- throw new RuntimeException( e );
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String[] getDefaultCipherSuites()
- {
- return delegate.getDefaultCipherSuites();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String[] getSupportedCipherSuites()
- {
- return delegate.getSupportedCipherSuites();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( Socket s, String host, int port, boolean autoClose ) throws IOException
- {
- try
- {
- updateTrustManagers( host );
- return delegate.createSocket( s, host, port, autoClose );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( String host, int port ) throws IOException, UnknownHostException
- {
- try
- {
- updateTrustManagers( host );
- return delegate.createSocket( host, port );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( InetAddress host, int port ) throws IOException
- {
- try
- {
- updateTrustManagers( host );
- return delegate.createSocket( host, port );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( String host, int port, InetAddress localHost, int localPort ) throws IOException,
- UnknownHostException
- {
- try
- {
- updateTrustManagers( host );
- return delegate.createSocket( host, port, localHost, localPort );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Socket createSocket( InetAddress address, int port, InetAddress localAddress, int localPort )
- throws IOException
- {
- try
- {
- updateTrustManagers( address );
- return delegate.createSocket( address, port, localAddress, localPort );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
-
- private void updateTrustManagers( InetAddress address )
- {
- updateTrustManagers( address.getHostName() );
- }
-
-
- private void updateTrustManagers( String host )
- {
- for ( StudioTrustManager trustManager : trustManagers )
- {
- trustManager.setHost( host );
- }
- }
-}
diff --git a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/ConnectionsPreferencePage.java b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/ConnectionsPreferencePage.java
index 10373d4..8deed48 100644
--- a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/ConnectionsPreferencePage.java
+++ b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/ConnectionsPreferencePage.java
@@ -24,7 +24,6 @@ package org.apache.directory.studio.connection.ui.preferences;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.PreferencePage;
@@ -50,8 +49,6 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
public class ConnectionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
{
- private Combo networkProviderCombo;
- private Text ldapContextFactoryText;
private Button useKrb5SystemPropertiesButton;
private Label krb5LoginModuleNoteLabel;
private Text krb5LoginModuleText;
@@ -88,27 +85,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
BaseWidgetUtils.createSpacer( composite, 1 );
BaseWidgetUtils.createSpacer( composite, 1 );
- Group defaultNetworkProviderGroup = BaseWidgetUtils.createGroup(
- BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
- Messages.getString( "ConnectionsPreferencePage.DefaultNetworkProvider" ), 1 ); //$NON-NLS-1$
- NetworkProvider defaultNetworkProvider = ConnectionCorePlugin.getDefault().getDefaultNetworkProvider();
- String[] networkProviders = new String[]
- { "Apache Directory LDAP Client API", "JNDI (Java Naming and Directory Interface)" }; //$NON-NLS-1$ //$NON-NLS-2$
- networkProviderCombo = BaseWidgetUtils.createReadonlyCombo( defaultNetworkProviderGroup,
- networkProviders, 0, 2 );
- networkProviderCombo.select( defaultNetworkProvider == NetworkProvider.APACHE_DIRECTORY_LDAP_API ? 0
- : 1 );
-
- Group ldapContextFactoryGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite,
- 1, 1 ), Messages.getString( "ConnectionsPreferencePage.ContextFactory" ), 1 ); //$NON-NLS-1$
Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences();
- String ldapCtxFactory = preferences.getString( ConnectionCoreConstants.PREFERENCE_LDAP_CONTEXT_FACTORY );
- String defaultLdapCtxFactory = preferences
- .getDefaultString( ConnectionCoreConstants.PREFERENCE_LDAP_CONTEXT_FACTORY );
- String ldapCtxFactoryNote = NLS.bind( Messages
- .getString( "ConnectionsPreferencePage.SystemDetectedContextFactory" ), defaultLdapCtxFactory ); //$NON-NLS-1$
- ldapContextFactoryText = BaseWidgetUtils.createText( ldapContextFactoryGroup, ldapCtxFactory, 1 );
- BaseWidgetUtils.createWrappedLabel( ldapContextFactoryGroup, ldapCtxFactoryNote, 1 );
Group krb5SettingsGroup = BaseWidgetUtils.createGroup(
BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages
@@ -161,14 +138,6 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
@Override
protected void performDefaults()
{
- NetworkProvider defaultdDefaultNetworkProvider = ConnectionCorePlugin.getDefault().getNetworkProvider(
- ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getDefaultInt( ConnectionCoreConstants.PREFERENCE_DEFAULT_NETWORK_PROVIDER ) );
- networkProviderCombo.select( defaultdDefaultNetworkProvider == NetworkProvider.APACHE_DIRECTORY_LDAP_API ? 0
- : 1 );
-
- ldapContextFactoryText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
- ConnectionCoreConstants.PREFERENCE_LDAP_CONTEXT_FACTORY ) );
krb5LoginModuleText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
ConnectionCoreConstants.PREFERENCE_KRB5_LOGIN_MODULE ) );
useKrb5SystemPropertiesButton.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences()
@@ -183,11 +152,6 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
*/
public boolean performOk()
{
- ConnectionCorePlugin.getDefault().getPluginPreferences()
- .setValue( ConnectionCoreConstants.PREFERENCE_DEFAULT_NETWORK_PROVIDER,
- getNetworkProviderValue() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_LDAP_CONTEXT_FACTORY, ldapContextFactoryText.getText() );
ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
ConnectionCoreConstants.PREFERENCE_KRB5_LOGIN_MODULE, krb5LoginModuleText.getText() );
ConnectionCorePlugin.getDefault().getPluginPreferences()
@@ -199,21 +163,4 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
return true;
}
-
- /**
- * Gets the encyrption method.
- *
- * @return the encyrption method
- */
- private int getNetworkProviderValue()
- {
- switch ( networkProviderCombo.getSelectionIndex() )
- {
- case 1:
- return ConnectionCoreConstants.PREFERENCE_NETWORK_PROVIDER_JNDI;
-
- default:
- return ConnectionCoreConstants.PREFERENCE_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API;
- }
- }
}
diff --git a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
index 61a24da..561c84a 100644
--- a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
+++ b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
@@ -22,9 +22,7 @@ package org.apache.directory.studio.connection.ui.widgets;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.api.ldap.model.url.LdapUrl;
@@ -38,7 +36,6 @@ import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionParameter;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.core.jobs.CheckNetworkParameterRunnable;
import org.apache.directory.studio.connection.ui.AbstractConnectionParameterPage;
import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
@@ -85,7 +82,6 @@ import org.eclipse.ui.dialogs.PreferencesUtil;
* | | | Server certificates for LDAP connections can | | |
* | | | managed in the '<certificate validation>' | | |
* | | | preference page. | | |
- * | | | Provider : [ Apache Directory LDAP API |v] | | |
* | | | | | |
* | | | (Check Network Parameter) | | |
* | | +-------------------------------------------------------------------+ | |
@@ -108,12 +104,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
private static final String X_ENCRYPTION_START_TLS = "StartTLS"; //$NON-NLS-1$
- private static final String X_NETWORK_PROVIDER = "X-NETWORK-PROVIDER"; //$NON-NLS-1$
-
- private static final String X_NETWORK_PROVIDER_JNDI = "JNDI"; //$NON-NLS-1$
-
- private static final String X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API = "ApacheDirectoryLdapApi"; //$NON-NLS-1$
-
/** The connection name text widget */
private Text nameText;
@@ -126,9 +116,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
/** The combo to select the encryption method */
private Combo encryptionMethodCombo;
- /** The combo to select the network provider */
- private Combo networkProviderCombo;
-
/** The button to check the connection parameters */
private Button checkConnectionButton;
@@ -232,22 +219,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
/**
- * Gets the network type (JNDI or Apache LDAP API)
- *
- * @return the network type
- */
- private ConnectionParameter.NetworkProvider getNetworkProvider()
- {
- if ( networkProviderCombo.getSelectionIndex() == 1 )
- {
- return ConnectionParameter.NetworkProvider.JNDI;
- }
-
- return ConnectionParameter.NetworkProvider.APACHE_DIRECTORY_LDAP_API;
- }
-
-
- /**
* Gets a temporary connection with all connection parameter
* entered in this page.
*
@@ -256,8 +227,8 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
private Connection getTestConnection()
{
ConnectionParameter connectionParameter = new ConnectionParameter( null, getHostName(), getPort(),
- getEncyrptionMethod(),
- getNetworkProvider(), ConnectionParameter.AuthenticationMethod.NONE, null, null, null, true, null, 30000L );
+ getEncyrptionMethod(), ConnectionParameter.AuthenticationMethod.NONE, null, null, null, true, null,
+ 30000L );
return new Connection( connectionParameter );
}
@@ -345,21 +316,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
.getString( "NetworkParameterPage.WarningCertificateValidation" ), 2 ); //$NON-NLS-1$
}
- List<String> networkProviderList = new ArrayList<>();
- networkProviderList.add( "Apache Directory LDAP Client API" ); //$NON-NLS-1$
- if ( NetworkProvider.JNDI.isSupported() )
- {
- networkProviderList.add( "JNDI (Java Naming and Directory Interface)" ); //$NON-NLS-1$
- }
- String[] networkProviders = networkProviderList.toArray( new String[0] );
-
- BaseWidgetUtils.createLabel( groupComposite, Messages.getString( "NetworkParameterPage.Provider" ), 1 ); //$NON-NLS-1$
- networkProviderCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite, networkProviders, 0, 2 );
- networkProviderCombo
- .select( ConnectionCorePlugin.getDefault()
- .getDefaultNetworkProvider() == NetworkProvider.APACHE_DIRECTORY_LDAP_API ? 0
- : 1 );
-
BaseWidgetUtils.createSpacer( groupComposite, 2 );
checkConnectionButton = new Button( groupComposite, SWT.PUSH );
GridData gridData = new GridData();
@@ -444,9 +400,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
}
encryptionMethodCombo.select( encryptionMethodIndex );
- networkProviderCombo.select( parameter.getNetworkProvider() == NetworkProvider.APACHE_DIRECTORY_LDAP_API
- || networkProviderCombo.getItemCount() < 2 ? 0
- : 1 );
readOnlyConnectionCheckbox.setSelection( parameter.isReadOnly() );
timeoutSecondsText.setText( Long.toString( parameter.getTimeoutMillis() / 1000L ) );
@@ -484,18 +437,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
}
} );
- networkProviderCombo.addSelectionListener( new SelectionAdapter()
- {
- /**
- * {@inheritDoc}
- */
- @Override
- public void widgetSelected( SelectionEvent event )
- {
- connectionPageModified();
- }
- } );
-
checkConnectionButton.addSelectionListener( new SelectionAdapter()
{
/**
@@ -552,7 +493,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
parameter.setHost( getHostName() );
parameter.setPort( getPort() );
parameter.setEncryptionMethod( getEncyrptionMethod() );
- parameter.setNetworkProvider( getNetworkProvider() );
parameter.setReadOnly( isReadOnly() );
parameter.setTimeoutMillis( getTimeoutSeconds() * 1000L );
}
@@ -600,7 +540,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
|| ( !StringUtils.equals( connectionParameter.getHost(), getHostName() ) )
|| ( connectionParameter.getPort() != getPort() )
|| ( connectionParameter.getEncryptionMethod() != getEncyrptionMethod() )
- || ( connectionParameter.getNetworkProvider() != getNetworkProvider() )
|| ( connectionParameter.isReadOnly() != isReadOnly() )
|| ( connectionParameter.getTimeoutMillis() != getTimeoutSeconds() * 1000L );
}
@@ -630,16 +569,6 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
ldapUrl.getExtensions().add( new Extension( false, X_ENCRYPTION, X_ENCRYPTION_START_TLS ) );
break;
}
-
- if ( parameter.getNetworkProvider() == NetworkProvider.JNDI )
- {
- ldapUrl.getExtensions().add( new Extension( false, X_NETWORK_PROVIDER, X_NETWORK_PROVIDER_JNDI ) );
- }
- else
- {
- ldapUrl.getExtensions().add(
- new Extension( false, X_NETWORK_PROVIDER, X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API ) );
- }
}
@@ -680,23 +609,5 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
{
parameter.setEncryptionMethod( ConnectionParameter.EncryptionMethod.NONE );
}
-
- // network provider, LDAP API if unknown or absent
- String networkProvider = ldapUrl.getExtensionValue( X_NETWORK_PROVIDER );
-
- if ( StringUtils.isNotEmpty( networkProvider )
- && X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API.equalsIgnoreCase( networkProvider ) )
- {
- parameter.setNetworkProvider( ConnectionParameter.NetworkProvider.APACHE_DIRECTORY_LDAP_API );
- }
- else if ( StringUtils.isNotEmpty( networkProvider )
- && X_NETWORK_PROVIDER_JNDI.equalsIgnoreCase( networkProvider ) )
- {
- parameter.setNetworkProvider( ConnectionParameter.NetworkProvider.JNDI );
- }
- else
- {
- parameter.setNetworkProvider( ConnectionCorePlugin.getDefault().getDefaultNetworkProvider() );
- }
}
}
diff --git a/plugins/ldapservers.apacheds/src/main/java/org/apache/directory/studio/ldapservers/apacheds/CreateConnectionAction.java b/plugins/ldapservers.apacheds/src/main/java/org/apache/directory/studio/ldapservers/apacheds/CreateConnectionAction.java
index 9d9b4e1..3ff652f 100644
--- a/plugins/ldapservers.apacheds/src/main/java/org/apache/directory/studio/ldapservers/apacheds/CreateConnectionAction.java
+++ b/plugins/ldapservers.apacheds/src/main/java/org/apache/directory/studio/ldapservers/apacheds/CreateConnectionAction.java
@@ -195,9 +195,6 @@ public class CreateConnectionAction implements IObjectActionDelegate
// Name
connectionParameter.setName( server.getName() );
- // Network Provider
- connectionParameter.setNetworkProvider( ConnectionCorePlugin.getDefault().getDefaultNetworkProvider() );
-
// Extended Properties
connectionParameter.setExtendedProperty( DetectedConnectionProperties.CONNECTION_PARAMETER_SERVER_TYPE,
ConnectionServerType.APACHEDS.toString() );
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java
index f2ebc1d..625c3dd 100644
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java
+++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ConnectionWrapperTestBase.java
@@ -72,7 +72,6 @@ import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionParameter;
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.core.IReferralHandler;
import org.apache.directory.studio.connection.core.Utils;
import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
@@ -97,16 +96,9 @@ import org.junit.runner.RunWith;
public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
{
- protected NetworkProvider provider;
protected ConnectionWrapper connectionWrapper;
- public ConnectionWrapperTestBase( NetworkProvider provider )
- {
- this.provider = provider;
- }
-
-
@Before
public void setUp() throws Exception
{
@@ -175,7 +167,7 @@ public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
{
StudioProgressMonitor monitor = getProgressMonitor();
ConnectionParameter connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(),
- EncryptionMethod.NONE, NetworkProvider.JNDI, AuthenticationMethod.NONE, null, null, null, true, null, 30L );
+ EncryptionMethod.NONE, AuthenticationMethod.NONE, null, null, null, true, null, 30L );
Connection connection = new Connection( connectionParameter );
ConnectionWrapper connectionWrapper = connection.getConnectionWrapper();
@@ -206,46 +198,28 @@ public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
// invalid port
monitor = getProgressMonitor();
connectionParameter = new ConnectionParameter( null, LOCALHOST, AvailablePortFinder.getNextAvailable(),
- EncryptionMethod.NONE, provider, AuthenticationMethod.NONE, null, null, null, true, null, 30L );
+ EncryptionMethod.NONE, AuthenticationMethod.NONE, null, null, null, true, null, 30L );
connection = new Connection( connectionParameter );
connectionWrapper = connection.getConnectionWrapper();
connectionWrapper.connect( monitor );
assertFalse( connectionWrapper.isConnected() );
assertNotNull( monitor.getException() );
- if ( provider == NetworkProvider.JNDI && NetworkProvider.JNDI.isSupported() )
- {
- assertTrue( monitor.getException() instanceof CommunicationException );
- assertNotNull( monitor.getException().getCause() );
- assertTrue( monitor.getException().getCause() instanceof ConnectException );
- }
- else
- {
- assertTrue( monitor.getException() instanceof InvalidConnectionException );
- assertNotNull( monitor.getException().getCause() );
- assertTrue( monitor.getException().getCause() instanceof ConnectException );
- }
+ assertTrue( monitor.getException() instanceof InvalidConnectionException );
+ assertNotNull( monitor.getException().getCause() );
+ assertTrue( monitor.getException().getCause() instanceof ConnectException );
// unknown host
monitor = getProgressMonitor();
connectionParameter = new ConnectionParameter( null, "555.555.555.555", ldapServer.getPort(),
- EncryptionMethod.NONE, provider, AuthenticationMethod.NONE, null, null, null, true, null, 30L );
+ EncryptionMethod.NONE, AuthenticationMethod.NONE, null, null, null, true, null, 30L );
connection = new Connection( connectionParameter );
connectionWrapper = connection.getConnectionWrapper();
connectionWrapper.connect( monitor );
assertFalse( connectionWrapper.isConnected() );
assertNotNull( monitor.getException() );
- if ( provider == NetworkProvider.JNDI && NetworkProvider.JNDI.isSupported() )
- {
- assertTrue( monitor.getException() instanceof CommunicationException );
- assertNotNull( monitor.getException().getCause() );
- assertTrue( monitor.getException().getCause() instanceof UnknownHostException );
- }
- else
- {
- assertTrue( monitor.getException() instanceof InvalidConnectionException );
- assertNotNull( monitor.getException().getCause() );
- assertTrue( monitor.getException().getCause() instanceof UnresolvedAddressException );
- }
+ assertTrue( monitor.getException() instanceof InvalidConnectionException );
+ assertNotNull( monitor.getException().getCause() );
+ assertTrue( monitor.getException().getCause() instanceof UnresolvedAddressException );
// TODO: SSL, StartTLS
}
@@ -259,7 +233,7 @@ public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
{
StudioProgressMonitor monitor = getProgressMonitor();
ConnectionParameter connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(),
- EncryptionMethod.NONE, provider, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, true,
+ EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, true,
null, 30L );
Connection connection = new Connection( connectionParameter );
ConnectionWrapper connectionWrapper = connection.getConnectionWrapper();
@@ -291,42 +265,28 @@ public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
// simple auth without principal and credential
monitor = getProgressMonitor();
connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(), EncryptionMethod.NONE,
- provider, AuthenticationMethod.SIMPLE, "uid=admin", "invalid", null, true, null, 30L );
+ AuthenticationMethod.SIMPLE, "uid=admin", "invalid", null, true, null, 30L );
connection = new Connection( connectionParameter );
connectionWrapper = connection.getConnectionWrapper();
connectionWrapper.connect( monitor );
connectionWrapper.bind( monitor );
assertFalse( connectionWrapper.isConnected() );
assertNotNull( monitor.getException() );
- if ( provider == NetworkProvider.JNDI && NetworkProvider.JNDI.isSupported() )
- {
- assertTrue( monitor.getException() instanceof NamingException );
- }
- else
- {
- assertTrue( monitor.getException() instanceof Exception );
- assertTrue( monitor.getException().getMessage().contains( "error code 49 - INVALID_CREDENTIALS" ) );
- }
+ assertTrue( monitor.getException() instanceof Exception );
+ assertTrue( monitor.getException().getMessage().contains( "error code 49 - INVALID_CREDENTIALS" ) );
// simple auth with invalid principal and credential
monitor = getProgressMonitor();
connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(), EncryptionMethod.NONE,
- provider, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "bar", null, true, null, 30L );
+ AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "bar", null, true, null, 30L );
connection = new Connection( connectionParameter );
connectionWrapper = connection.getConnectionWrapper();
connectionWrapper.connect( monitor );
connectionWrapper.bind( monitor );
assertFalse( connectionWrapper.isConnected() );
assertNotNull( monitor.getException() );
- if ( provider == NetworkProvider.JNDI && NetworkProvider.JNDI.isSupported() )
- {
- assertTrue( monitor.getException() instanceof AuthenticationException );
- }
- else
- {
- assertTrue( monitor.getException() instanceof Exception );
- assertTrue( monitor.getException().getMessage().contains( "error code 49 - INVALID_CREDENTIALS" ) );
- }
+ assertTrue( monitor.getException() instanceof Exception );
+ assertTrue( monitor.getException().getMessage().contains( "error code 49 - INVALID_CREDENTIALS" ) );
}
@@ -722,7 +682,7 @@ public abstract class ConnectionWrapperTestBase extends AbstractLdapTestUnit
{
// simple auth without principal and credential
ConnectionParameter connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(),
- EncryptionMethod.NONE, provider, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, false,
+ EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, false,
null, 30000L );
Connection connection = new Connection( connectionParameter );
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java
index a7940b6..53cb937 100644
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java
+++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java
@@ -49,7 +49,6 @@ import org.apache.directory.studio.connection.core.Connection.AliasDereferencing
import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
import org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper;
import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeRootDSERunnable;
@@ -65,13 +64,6 @@ import org.junit.Test;
*/
public class DirectoryApiConnectionWrapperTest extends ConnectionWrapperTestBase
{
-
- public DirectoryApiConnectionWrapperTest()
- {
- super( NetworkProvider.APACHE_DIRECTORY_LDAP_API );
- }
-
-
// see tests in super class
@Test
@@ -103,7 +95,7 @@ public class DirectoryApiConnectionWrapperTest extends ConnectionWrapperTestBase
{
StudioProgressMonitor monitor = getProgressMonitor();
ConnectionParameter connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(),
- EncryptionMethod.NONE, NetworkProvider.APACHE_DIRECTORY_LDAP_API, AuthenticationMethod.SIMPLE,
+ EncryptionMethod.NONE, AuthenticationMethod.SIMPLE,
"uid=admin,ou=system", "secret", null, true, null, 30L );
Connection connection = new Connection( connectionParameter );
BrowserConnection browserConnection = new BrowserConnection( connection );
@@ -124,7 +116,7 @@ public class DirectoryApiConnectionWrapperTest extends ConnectionWrapperTestBase
{
final StudioProgressMonitor monitor = getProgressMonitor();
final ConnectionParameter connectionParameter = new ConnectionParameter( null, LOCALHOST, ldapServer.getPort(),
- EncryptionMethod.NONE, NetworkProvider.APACHE_DIRECTORY_LDAP_API, AuthenticationMethod.SIMPLE,
+ EncryptionMethod.NONE, AuthenticationMethod.SIMPLE,
"uid=admin,ou=system", "secret", null, true, null, 30L );
final Connection connection = new Connection( connectionParameter );
final BrowserConnection browserConnection = new BrowserConnection( connection );
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/JNDIConnectionWrapperTest.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/JNDIConnectionWrapperTest.java
deleted file mode 100644
index bec9ca5..0000000
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/JNDIConnectionWrapperTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.directory.studio.test.integration.core;
-
-
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
-import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
-
-
-/**
- * Tests the {@link JNDIConnectionWrapper}.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public class JNDIConnectionWrapperTest extends ConnectionWrapperTestBase
-{
-
- public JNDIConnectionWrapperTest()
- {
- super( NetworkProvider.JNDI );
- }
-
- // see tests in super class
-
-}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
index f5a8f7e..9c28622 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
@@ -31,7 +31,6 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
-import java.nio.charset.StandardCharsets;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.server.annotations.CreateLdapServer;
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
index 81f5bdf..fe2eee4 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
@@ -35,7 +35,6 @@ import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
index 74983c2..cc39443 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
@@ -22,8 +22,6 @@ package org.apache.directory.studio.test.integration.ui.bots;
import static org.apache.directory.studio.test.integration.ui.Constants.LOCALHOST;
-import java.util.Random;
-
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionFolder;
@@ -32,7 +30,6 @@ import org.apache.directory.studio.connection.core.ConnectionManager;
import org.apache.directory.studio.connection.core.ConnectionParameter;
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
-import org.apache.directory.studio.connection.core.ConnectionParameter.NetworkProvider;
import org.apache.directory.studio.connection.core.Messages;
import org.apache.directory.studio.connection.core.jobs.OpenConnectionsRunnable;
import org.apache.directory.studio.connection.core.jobs.StudioConnectionJob;
@@ -56,17 +53,6 @@ public class ConnectionsViewBot
{
ContextMenuHelper.clickContextMenu( getConnectionsTree(), "New Connection..." );
NewConnectionWizardBot newConnectionWizardBot = new NewConnectionWizardBot();
-
- // choose random network provider to test both, LDAP API and JNDI
- if ( new Random().nextBoolean() && NetworkProvider.JNDI.isSupported() )
- {
- newConnectionWizardBot.selectJndiProvider();
- }
- else
- {
- newConnectionWizardBot.selectLdapApiProvider();
- }
-
return newConnectionWizardBot;
}
@@ -181,9 +167,6 @@ public class ConnectionsViewBot
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
ConnectionParameter connectionParameter = new ConnectionParameter();
- // choose random network provider to test both, LDAP API and JNDI
- connectionParameter
- .setNetworkProvider( NetworkProvider.values()[new Random().nextInt( NetworkProvider.values().length )] );
connectionParameter.setName( name );
connectionParameter.setHost( LOCALHOST );
connectionParameter.setPort( port );
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
index 2fd5307..59cb804 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
@@ -34,9 +34,6 @@ public class NewConnectionWizardBot extends WizardBot
private static final String CONNECTION_NAME = "Connection name:";
private static final String HOSTNAME = "Hostname:";
private static final String PORT = "Port:";
- private static final String PROVIDER = "Provider:";
- private static final String JNDI = "JNDI (Java Naming and Directory Interface)";
- private static final String LDAP_API = "Apache Directory LDAP Client API";
private static final String CHECK_AUTHENTICATION = "Check Authentication";
private static final String CHECK_NETWORK_PARAMETER = "Check Network Parameter";
private static final String BASE_DN = "Base DN:";
@@ -107,20 +104,6 @@ public class NewConnectionWizardBot extends WizardBot
}
- public void selectJndiProvider()
- {
- SWTBotCombo providerCombo = bot.comboBoxWithLabel( PROVIDER );
- providerCombo.setSelection( JNDI );
- }
-
-
- public void selectLdapApiProvider()
- {
- SWTBotCombo providerCombo = bot.comboBoxWithLabel( PROVIDER );
- providerCombo.setSelection( LDAP_API );
- }
-
-
public boolean isSimpleAuthenticationSelected()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );