You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2011/12/08 15:20:32 UTC
svn commit: r1211901 - in /directory/studio/trunk/plugins:
connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/
connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/
connection.ui/src/main/java/...
Author: pamarcelot
Date: Thu Dec 8 14:20:31 2011
New Revision: 1211901
URL: http://svn.apache.org/viewvc?rev=1211901&view=rev
Log:
Fix for DIRSTUDIO-659 (Studio prompts for password even when "No Authentication" is selected).
Modified:
directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java
Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java?rev=1211901&r1=1211900&r2=1211901&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java (original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java Thu Dec 8 14:20:31 2011
@@ -178,8 +178,6 @@ public class DirectoryApiConnectionWrapp
ldapConnectionConfig = new LdapConnectionConfig();
ldapConnectionConfig.setLdapHost( connection.getHost() );
ldapConnectionConfig.setLdapPort( connection.getPort() );
- ldapConnectionConfig.setName( connection.getBindPrincipal() );
- ldapConnectionConfig.setCredentials( connection.getBindPassword() );
if ( ( connection.getEncryptionMethod() == EncryptionMethod.LDAPS )
|| ( connection.getEncryptionMethod() == EncryptionMethod.START_TLS ) )
{
@@ -320,111 +318,125 @@ public class DirectoryApiConnectionWrapp
{
BindResponse bindResponse = null;
- // Setup credentials
- IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
- if ( authHandler == null )
- {
- Exception exception = new Exception( Messages.model__no_auth_handler );
- monitor.setCanceled( true );
- monitor.reportError( Messages.model__no_auth_handler, exception );
- throw exception;
- }
- ICredentials credentials = authHandler.getCredentials( connection.getConnectionParameter() );
- if ( credentials == null )
- {
- Exception exception = new Exception();
- monitor.setCanceled( true );
- monitor.reportError( Messages.model__no_credentials, exception );
- throw exception;
- }
- if ( credentials.getBindPrincipal() == null || credentials.getBindPassword() == null )
- {
- Exception exception = new Exception( Messages.model__no_credentials );
- monitor.reportError( Messages.model__no_credentials, exception );
- throw exception;
- }
- bindPrincipal = credentials.getBindPrincipal();
- bindPassword = credentials.getBindPassword();
-
- // Simple Authentication
- if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE )
+ // No Authentication
+ if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.NONE )
{
BindRequest bindRequest = new BindRequestImpl();
- bindRequest.setName( new Dn( bindPrincipal ) );
- bindRequest.setCredentials( bindPassword );
bindResponse = ldapConnection.bind( bindRequest );
}
- // CRAM-MD5 Authentication
- else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5 )
- {
- CramMd5Request cramMd5Request = new CramMd5Request();
- cramMd5Request.setUsername( bindPrincipal );
- cramMd5Request.setCredentials( bindPassword );
- cramMd5Request.setQualityOfProtection( connection.getConnectionParameter().getSaslQop() );
- cramMd5Request.setSecurityStrength( connection.getConnectionParameter()
- .getSaslSecurityStrength() );
- cramMd5Request.setMutualAuthentication( connection.getConnectionParameter()
- .isSaslMutualAuthentication() );
-
- bindResponse = ldapConnection.bind( cramMd5Request );
- }
- // DIGEST-MD5 Authentication
- else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5 )
- {
- DigestMd5Request digestMd5Request = new DigestMd5Request();
- digestMd5Request.setUsername( bindPrincipal );
- digestMd5Request.setCredentials( bindPassword );
- digestMd5Request.setRealmName( connection.getConnectionParameter().getSaslRealm() );
- digestMd5Request.setQualityOfProtection( connection.getConnectionParameter().getSaslQop() );
- digestMd5Request.setSecurityStrength( connection.getConnectionParameter()
- .getSaslSecurityStrength() );
- digestMd5Request.setMutualAuthentication( connection.getConnectionParameter()
- .isSaslMutualAuthentication() );
-
- bindResponse = ldapConnection.bind( digestMd5Request );
- }
- // GSSAPI Authentication
- else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_GSSAPI )
+ else
{
- GssApiRequest gssApiRequest = new GssApiRequest();
+ // Setup credentials
+ IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
+ if ( authHandler == null )
+ {
+ Exception exception = new Exception( Messages.model__no_auth_handler );
+ monitor.setCanceled( true );
+ monitor.reportError( Messages.model__no_auth_handler, exception );
+ throw exception;
+ }
+ ICredentials credentials = authHandler.getCredentials( connection.getConnectionParameter() );
+ if ( credentials == null )
+ {
+ Exception exception = new Exception();
+ monitor.setCanceled( true );
+ monitor.reportError( Messages.model__no_credentials, exception );
+ throw exception;
+ }
+ if ( credentials.getBindPrincipal() == null || credentials.getBindPassword() == null )
+ {
+ Exception exception = new Exception( Messages.model__no_credentials );
+ monitor.reportError( Messages.model__no_credentials, exception );
+ throw exception;
+ }
+ bindPrincipal = credentials.getBindPrincipal();
+ bindPassword = credentials.getBindPassword();
- Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences();
- boolean useKrb5SystemProperties = preferences
- .getBoolean( ConnectionCoreConstants.PREFERENCE_USE_KRB5_SYSTEM_PROPERTIES );
- String krb5LoginModule = preferences
- .getString( ConnectionCoreConstants.PREFERENCE_KRB5_LOGIN_MODULE );
+ // Simple Authentication
+ if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE )
+ {
+ BindRequest bindRequest = new BindRequestImpl();
+ bindRequest.setName( new Dn( bindPrincipal ) );
+ bindRequest.setCredentials( bindPassword );
+ bindResponse = ldapConnection.bind( bindRequest );
+ }
+ // CRAM-MD5 Authentication
+ else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5 )
+ {
+ CramMd5Request cramMd5Request = new CramMd5Request();
+ cramMd5Request.setUsername( bindPrincipal );
+ cramMd5Request.setCredentials( bindPassword );
+ cramMd5Request
+ .setQualityOfProtection( connection.getConnectionParameter().getSaslQop() );
+ cramMd5Request.setSecurityStrength( connection.getConnectionParameter()
+ .getSaslSecurityStrength() );
+ cramMd5Request.setMutualAuthentication( connection.getConnectionParameter()
+ .isSaslMutualAuthentication() );
- if ( !useKrb5SystemProperties )
+ bindResponse = ldapConnection.bind( cramMd5Request );
+ }
+ // DIGEST-MD5 Authentication
+ else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5 )
{
- gssApiRequest.setUsername( bindPrincipal );
- gssApiRequest.setCredentials( bindPassword );
- gssApiRequest.setQualityOfProtection( connection
- .getConnectionParameter().getSaslQop() );
- gssApiRequest.setSecurityStrength( connection
- .getConnectionParameter()
+ DigestMd5Request digestMd5Request = new DigestMd5Request();
+ digestMd5Request.setUsername( bindPrincipal );
+ digestMd5Request.setCredentials( bindPassword );
+ digestMd5Request.setRealmName( connection.getConnectionParameter().getSaslRealm() );
+ digestMd5Request.setQualityOfProtection( connection.getConnectionParameter()
+ .getSaslQop() );
+ digestMd5Request.setSecurityStrength( connection.getConnectionParameter()
.getSaslSecurityStrength() );
- gssApiRequest.setMutualAuthentication( connection
- .getConnectionParameter()
+ digestMd5Request.setMutualAuthentication( connection.getConnectionParameter()
.isSaslMutualAuthentication() );
- gssApiRequest
- .setLoginModuleConfiguration( new InnerConfiguration(
- krb5LoginModule ) );
- switch ( connection.getConnectionParameter().getKrb5Configuration() )
+ bindResponse = ldapConnection.bind( digestMd5Request );
+ }
+ // GSSAPI Authentication
+ else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_GSSAPI )
+ {
+ GssApiRequest gssApiRequest = new GssApiRequest();
+
+ 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 )
{
- case FILE:
- gssApiRequest.setKrb5ConfFilePath( connection.getConnectionParameter()
- .getKrb5ConfigurationFile() );
- break;
- case MANUAL:
- gssApiRequest.setRealmName( connection.getConnectionParameter().getKrb5Realm() );
- gssApiRequest.setKdcHost( connection.getConnectionParameter().getKrb5KdcHost() );
- gssApiRequest.setKdcPort( connection.getConnectionParameter().getKrb5KdcPort() );
- break;
+ gssApiRequest.setUsername( bindPrincipal );
+ gssApiRequest.setCredentials( bindPassword );
+ gssApiRequest.setQualityOfProtection( connection
+ .getConnectionParameter().getSaslQop() );
+ gssApiRequest.setSecurityStrength( connection
+ .getConnectionParameter()
+ .getSaslSecurityStrength() );
+ gssApiRequest.setMutualAuthentication( connection
+ .getConnectionParameter()
+ .isSaslMutualAuthentication() );
+ gssApiRequest
+ .setLoginModuleConfiguration( new InnerConfiguration(
+ krb5LoginModule ) );
+
+ switch ( connection.getConnectionParameter().getKrb5Configuration() )
+ {
+ case FILE:
+ gssApiRequest.setKrb5ConfFilePath( connection.getConnectionParameter()
+ .getKrb5ConfigurationFile() );
+ break;
+ case MANUAL:
+ gssApiRequest.setRealmName( connection.getConnectionParameter()
+ .getKrb5Realm() );
+ gssApiRequest.setKdcHost( connection.getConnectionParameter()
+ .getKrb5KdcHost() );
+ gssApiRequest.setKdcPort( connection.getConnectionParameter()
+ .getKrb5KdcPort() );
+ break;
+ }
}
- }
- bindResponse = ldapConnection.bind( gssApiRequest );
+ bindResponse = ldapConnection.bind( gssApiRequest );
+ }
}
checkResponse( bindResponse );
Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=1211901&r1=1211900&r2=1211901&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java (original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java Thu Dec 8 14:20:31 2011
@@ -974,30 +974,39 @@ public class JNDIConnectionWrapper imple
authMethod = AUTHMETHOD_GSSAPI;
}
- // 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;
+ // No Authentication
+ if ( authMethod == AUTHMETHOD_NONE )
+ {
+ bindPrincipal = "";
+ bindCredentials = "";
+ }
+ 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();
}
- bindPrincipal = credentials.getBindPrincipal();
- bindCredentials = credentials.getBindPassword();
InnerRunnable runnable = new InnerRunnable()
{
Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java?rev=1211901&r1=1211900&r2=1211901&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java (original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java Thu Dec 8 14:20:31 2011
@@ -44,7 +44,6 @@ public class UIAuthHandler implements IA
*/
public ICredentials getCredentials( final ConnectionParameter connectionParameter )
{
-
if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) ) //$NON-NLS-1$
{
return new Credentials( "", "", connectionParameter ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -87,7 +86,5 @@ public class UIAuthHandler implements IA
return new Credentials( connectionParameter.getBindPrincipal(), pw[0], connectionParameter );
}
}
-
}
-
}