Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 671489BEA for ; Thu, 8 Dec 2011 14:20:59 +0000 (UTC) Received: (qmail 74849 invoked by uid 500); 8 Dec 2011 14:20:59 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 74815 invoked by uid 500); 8 Dec 2011 14:20:59 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 74808 invoked by uid 99); 8 Dec 2011 14:20:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Dec 2011 14:20:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Dec 2011 14:20:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 31EF223889EC for ; Thu, 8 Dec 2011 14:20:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/... Date: Thu, 08 Dec 2011 14:20:32 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111208142032.31EF223889EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 ); } } - } - }