directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1028732 - /directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
Date Fri, 29 Oct 2010 13:34:03 GMT
Author: pamarcelot
Date: Fri Oct 29 13:34:02 2010
New Revision: 1028732

URL: http://svn.apache.org/viewvc?rev=1028732&view=rev
Log:
Added code for GSSAPI bind.
Improved error handling of the bind operation.

Modified:
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.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/api/DirectoryApiConnectionWrapper.java?rev=1028732&r1=1028731&r2=1028732&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
Fri Oct 29 13:34:02 2010
@@ -51,6 +51,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.message.AddResponse;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.BindResponse;
 import org.apache.directory.shared.ldap.message.DeleteRequest;
 import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
 import org.apache.directory.shared.ldap.message.DeleteResponse;
@@ -277,6 +278,8 @@ public class DirectoryApiConnectionWrapp
                 {
                     try
                     {
+                        BindResponse bindResponse = null;
+
                         // Setup credentials
                         IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
                         if ( authHandler == null )
@@ -306,19 +309,29 @@ public class DirectoryApiConnectionWrapp
                         // Simple Authentication
                         if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE
)
                         {
-                            getLdapConnection().bind( bindPrincipal, bindPassword );
+                            bindResponse = getLdapConnection().bind( bindPrincipal, bindPassword
);
                         }
                         // CRAM-MD5 Authentication
                         else if ( connection.getConnectionParameter().getAuthMethod() ==
ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5 )
                         {
-                            getLdapConnection().bindCramMd5( bindPrincipal, bindPassword,
null );
+                            bindResponse = getLdapConnection().bindCramMd5( bindPrincipal,
bindPassword, null );
                         }
                         // DIGEST-MD5 Authentication
                         else if ( connection.getConnectionParameter().getAuthMethod() ==
ConnectionParameter.AuthenticationMethod.SASL_DIGEST_MD5 )
                         {
-                            getLdapConnection().bindDigestMd5( bindPrincipal, bindPassword,
null,
+                            bindResponse = getLdapConnection().bindDigestMd5( bindPrincipal,
bindPassword, null,
                                 connection.getConnectionParameter().getSaslRealm() );
                         }
+                        // GSSAPI Authentication
+                        else if ( connection.getConnectionParameter().getAuthMethod() ==
ConnectionParameter.AuthenticationMethod.SASL_GSSAPI )
+                        {
+                            bindResponse = getLdapConnection().bindGssApi( bindPrincipal,
bindPassword,
+                                connection.getConnectionParameter().getSaslRealm(),
+                                connection.getConnectionParameter().getKrb5KdcHost(),
+                                connection.getConnectionParameter().getKrb5KdcPort() );
+                        }
+
+                        checkResponse( bindResponse );
                     }
                     catch ( Exception e )
                     {
@@ -1073,8 +1086,8 @@ public class DirectoryApiConnectionWrapp
                 // Different from SUCCESS, we throw a generic exception
                 else if ( !ResultCodeEnum.SUCCESS.equals( ldapResult.getResultCode() ) )
                 {
-                    throw new Exception( ldapResult.getResultCode().getResultCode() + " "
-                        + ldapResult.getErrorMessage() );
+                    throw new Exception( NLS.bind( "[LDAP: error code {0} - {1}]", new String[]
+                        { ldapResult.getResultCode().getResultCode() + "", ldapResult.getErrorMessage()
} ) );
                 }
             }
         }



Mime
View raw message