Author: pamarcelot
Date: Thu Oct 14 14:45:16 2010
New Revision: 1022552
URL: http://svn.apache.org/viewvc?rev=1022552&view=rev
Log:
Added an option to select the Network Provider on a connection (either JNDI or the Apache
Directory LDAP API).
Modified:
directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
directory/studio/branches/studio-connection-refactoring/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java?rev=1022552&r1=1022551&r2=1022552&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
Thu Oct 14 14:45:16 2010
@@ -24,6 +24,7 @@ package org.apache.directory.studio.conn
import org.apache.directory.shared.ldap.util.LdapURL;
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.jndi.JNDIConnectionWrapper;
import org.eclipse.core.runtime.IAdaptable;
@@ -190,7 +191,7 @@ public class Connection implements Conne
public Object clone()
{
ConnectionParameter cp = new ConnectionParameter( getName(), getHost(), getPort(),
getEncryptionMethod(),
- getAuthMethod(), getBindPrincipal(), getBindPassword(), getSaslRealm(), isReadOnly(),
+ getNetworkProvider(), getAuthMethod(), getBindPrincipal(), getBindPassword(),
getSaslRealm(), isReadOnly(),
getConnectionParameter().getExtendedProperties() );
Connection clone = new Connection( cp );
@@ -282,6 +283,17 @@ public class Connection implements Conne
/**
+ * Gets the network provider.
+ *
+ * @return the network provider
+ */
+ public NetworkProvider getNetworkProvider()
+ {
+ return connectionParameter.getNetworkProvider();
+ }
+
+
+ /**
* Gets the id.
*
* @return the id
Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java?rev=1022552&r1=1022551&r2=1022552&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionParameter.java
Thu Oct 14 14:45:16 2010
@@ -34,7 +34,6 @@ import java.util.UUID;
*/
public class ConnectionParameter
{
-
/**
* Enum for the used encryption method.
*
@@ -42,7 +41,6 @@ public class ConnectionParameter
*/
public enum EncryptionMethod
{
-
/** No encryption. */
NONE,
@@ -54,13 +52,26 @@ public class ConnectionParameter
}
/**
+ * Enum for the network provider.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+ public enum NetworkProvider
+ {
+ /** No encryption. */
+ JNDI,
+
+ /** SSL encryption. */
+ APACHE_DIRECTORY_LDAP_API
+ }
+
+ /**
* Enum for the used authentication method.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum AuthenticationMethod
{
-
/** No authentication, anonymous bind. */
NONE,
@@ -113,6 +124,9 @@ public class ConnectionParameter
/** The encryption method. */
private EncryptionMethod encryptionMethod;
+ /** The network provider. */
+ private NetworkProvider networkProvider;
+
/** The authentication method. */
private AuthenticationMethod authMethod;
@@ -183,14 +197,15 @@ public class ConnectionParameter
* @param extendedProperties the extended properties
*/
public ConnectionParameter( String name, String host, int port, EncryptionMethod encryptionMethod,
- AuthenticationMethod authMethod, String bindPrincipal, String bindPassword, String
saslRealm,
- boolean isReadOnly, Map<String, String> extendedProperties )
+ NetworkProvider networkProvider, AuthenticationMethod authMethod, String bindPrincipal,
String bindPassword,
+ String saslRealm, boolean isReadOnly, Map<String, String> extendedProperties
)
{
this.id = createId();
this.name = name;
this.host = host;
this.port = port;
this.encryptionMethod = encryptionMethod;
+ this.networkProvider = networkProvider;
this.authMethod = authMethod;
this.bindPrincipal = bindPrincipal;
this.bindPassword = bindPassword;
@@ -337,6 +352,28 @@ 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
Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java?rev=1022552&r1=1022551&r2=1022552&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
Thu Oct 14 14:45:16 2010
@@ -35,6 +35,7 @@ import org.apache.directory.studio.conne
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.ConnectionParameter.SaslQop;
import org.apache.directory.studio.connection.core.ConnectionParameter.SaslSecurityStrength;
import org.dom4j.Attribute;
@@ -62,6 +63,7 @@ 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$
@@ -195,6 +197,26 @@ 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( NetworkProvider.JNDI );
+ }
+
// Auth Method
Attribute authMethodAttribute = element.attribute( AUTH_METHOD_TAG );
if ( authMethodAttribute != null )
@@ -380,6 +402,9 @@ 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()
);
Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=1022552&r1=1022551&r2=1022552&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Thu Oct 14 14:45:16 2010
@@ -33,6 +33,7 @@ import org.apache.directory.studio.conne
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;
@@ -64,7 +65,6 @@ import org.eclipse.swt.widgets.Text;
*/
public class NetworkParameterPage extends AbstractConnectionParameterPage
{
-
private static final String X_CONNECTION_NAME = "X-CONNECTION-NAME"; //$NON-NLS-1$
private static final String X_ENCRYPTION = "X-ENCRYPTION"; //$NON-NLS-1$
@@ -73,6 +73,12 @@ public class NetworkParameterPage extend
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;
@@ -85,6 +91,9 @@ public class NetworkParameterPage extend
/** 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;
@@ -150,7 +159,24 @@ public class NetworkParameterPage extend
/**
- * Gets a temporary connection with all conection parameter
+ * Gets the encyrption method.
+ *
+ * @return the encyrption method
+ */
+ private ConnectionParameter.NetworkProvider getNetworkProvider()
+ {
+ switch ( networkProviderCombo.getSelectionIndex() )
+ {
+ case 1:
+ return ConnectionParameter.NetworkProvider.APACHE_DIRECTORY_LDAP_API;
+ default:
+ return ConnectionParameter.NetworkProvider.JNDI;
+ }
+ }
+
+
+ /**
+ * Gets a temporary connection with all connection parameter
* entered in this page.
*
* @return a test connection
@@ -158,7 +184,7 @@ public class NetworkParameterPage extend
private Connection getTestConnection()
{
ConnectionParameter cp = new ConnectionParameter( null, getHostName(), getPort(),
getEncyrptionMethod(),
- ConnectionParameter.AuthenticationMethod.NONE, null, null, null, true, null );
+ getNetworkProvider(), ConnectionParameter.AuthenticationMethod.NONE, null, null,
null, true, null );
Connection conn = new Connection( cp );
return conn;
}
@@ -208,6 +234,11 @@ public class NetworkParameterPage extend
.getString( "NetworkParameterPage.WarningCertificateValidation" ), 2 ); //$NON-NLS-1$
}
+ String[] networkProviders = new String[]
+ { "JNDI (Java Naming and Directory Interface)", "Apache Directory LDAP Client
API" }; //$NON-NLS-1$
+ BaseWidgetUtils.createLabel( groupComposite, "Provider:", 1 ); //$NON-NLS-1$
+ networkProviderCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite, networkProviders,
index, 2 );
+
BaseWidgetUtils.createSpacer( groupComposite, 2 );
checkConnectionButton = new Button( groupComposite, SWT.PUSH );
GridData gd = new GridData();
@@ -263,9 +294,11 @@ public class NetworkParameterPage extend
nameText.setText( parameter.getName() );
hostCombo.setText( parameter.getHost() );
portCombo.setText( Integer.toString( parameter.getPort() ) );
- int index = parameter.getEncryptionMethod() == EncryptionMethod.LDAPS ? 1
+ int encryptionMethodIndex = parameter.getEncryptionMethod() == EncryptionMethod.LDAPS
? 1
: parameter.getEncryptionMethod() == EncryptionMethod.START_TLS ? 2 : 0;
- encryptionMethodCombo.select( index );
+ encryptionMethodCombo.select( encryptionMethodIndex );
+ int networkProviderIndex = parameter.getNetworkProvider() == NetworkProvider.JNDI
? 0 : 1;
+ networkProviderCombo.select( networkProviderIndex );
}
@@ -316,6 +349,14 @@ public class NetworkParameterPage extend
}
} );
+ networkProviderCombo.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ connectionPageModified();
+ }
+ } );
+
checkConnectionButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent event )
@@ -343,6 +384,7 @@ public class NetworkParameterPage extend
parameter.setHost( getHostName() );
parameter.setPort( getPort() );
parameter.setEncryptionMethod( getEncyrptionMethod() );
+ parameter.setNetworkProvider( getNetworkProvider() );
}
@@ -381,7 +423,8 @@ public class NetworkParameterPage extend
{
return connectionParameter == null || !StringUtils.equals( connectionParameter.getHost(),
getHostName() )
|| connectionParameter.getPort() != getPort()
- || connectionParameter.getEncryptionMethod() != getEncyrptionMethod();
+ || connectionParameter.getEncryptionMethod() != getEncyrptionMethod()
+ || connectionParameter.getNetworkProvider() != getNetworkProvider();
}
@@ -408,6 +451,17 @@ public class NetworkParameterPage extend
ldapUrl.getExtensions().add( new Extension( false, X_ENCRYPTION, X_ENCRYPTION_START_TLS
) );
break;
}
+
+ switch ( parameter.getNetworkProvider() )
+ {
+ case JNDI:
+ ldapUrl.getExtensions().add( new Extension( false, X_NETWORK_PROVIDER, X_NETWORK_PROVIDER_JNDI
) );
+ break;
+ case APACHE_DIRECTORY_LDAP_API:
+ ldapUrl.getExtensions().add(
+ new Extension( false, X_NETWORK_PROVIDER, X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API
) );
+ break;
+ }
}
@@ -444,5 +498,17 @@ public class NetworkParameterPage extend
{
parameter.setEncryptionMethod( ConnectionParameter.EncryptionMethod.NONE );
}
+
+ // encryption method, none if unknown or absent
+ String networkProvider = ldapUrl.getExtensionValue( X_NETWORK_PROVIDER );
+ if ( StringUtils.isNotEmpty( encryption ) && X_NETWORK_PROVIDER_JNDI.equalsIgnoreCase(
networkProvider ) )
+ {
+ parameter.setNetworkProvider( ConnectionParameter.NetworkProvider.JNDI );
+ }
+ else if ( StringUtils.isNotEmpty( encryption )
+ && X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API.equalsIgnoreCase( networkProvider
) )
+ {
+ parameter.setNetworkProvider( ConnectionParameter.NetworkProvider.APACHE_DIRECTORY_LDAP_API
);
+ }
}
}
|