directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckopp...@apache.org
Subject svn commit: r560714 - in /directory/studio/trunk: studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/...
Date Sun, 29 Jul 2007 12:07:47 GMT
Author: ckoppelt
Date: Sun Jul 29 05:07:46 2007
New Revision: 560714

URL: http://svn.apache.org/viewvc?view=rev&rev=560714
Log:
Added DIGEST-MD5 and CRAM-MD5 authentication to the user interface

Modified:
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ConnectionPageWrapper.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionAuthWizardPage.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionWizard.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Connection.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionParameter.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IConnection.java
    directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ConnectionPropertyPage.java

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ConnectionPageWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ConnectionPageWrapper.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ConnectionPageWrapper.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ConnectionPageWrapper.java
Sun Jul 29 05:07:46 2007
@@ -111,12 +111,9 @@
 
     /** The checkbox to choose wether the connection should be opened when finishing the
wizard */
     private Button openConnectionButton;
-
-    /** The radio to select anonymous authentication */
-    private Button anonymousAuthButton;
-
-    /** The radio to select simple authentication */
-    private Button simpleAuthButton;
+    
+    /** The combo to select the authentication method */
+    private Combo authenticationMethodCombo;
 
     /** The bind user combo with the history of recently used bind users */
     private Combo simpleAuthBindPrincipalCombo;
@@ -131,7 +128,7 @@
     private Button saveSimpleAuthBindPasswordButton;
 
     /** The button to check the authentication parameters */
-    private Button checkSimpleAuthButton;
+    private Button checkPrincipalPasswordAuthButton;
 
     /** The list of listerns that are interested in modifications in this page */
     private List<ConnectionPageModifyListener> listenerList;
@@ -337,25 +334,31 @@
      */
     public int getAuthenticationMethod()
     {
-        if ( anonymousAuthButton.getSelection() )
-        {
-            return IConnection.AUTH_ANONYMOUS;
-        }
-        else if ( simpleAuthButton.getSelection() )
+        if ( authenticationMethodCombo != null )
         {
-            return IConnection.AUTH_SIMPLE;
+            switch ( authenticationMethodCombo.getSelectionIndex() )
+            {
+                case 1:
+                    return IConnection.AUTH_SIMPLE;
+                case 2:
+                    return IConnection.AUTH_SASL_DIGMD5;
+                case 3:
+                    return IConnection.AUTH_SASL_CRAMD5;
+                default:
+                    return IConnection.AUTH_ANONYMOUS;
+            }
         }
-
         return IConnection.AUTH_ANONYMOUS;
     }
+    
 
 
     /**
-     * Gets the simple auth bind principal.
+     * Gets the simple auth, digest md5 or cram md5 bind principal.
      * 
      * @return the simple auth bind principal
      */
-    public String getSimpleAuthBindPrincipal()
+    public String getAuthBindPrincipal()
     {
         return simpleAuthBindPrincipalCombo != null ? simpleAuthBindPrincipalCombo.getText()
             : simpleAuthBindPrincipalText.getText();
@@ -363,11 +366,11 @@
 
 
     /**
-     * Gets the simple auth bind password.
+     * Gets the simple, digest md5 or cram md5 auth bind password.
      * 
-     * @return the simple auth bind password
+     * @return the auth bind password
      */
-    public String getSimpleAuthBindPassword()
+    public String getAuthBindPassword()
     {
         return simpleAuthBindPasswordText.getText();
     }
@@ -624,31 +627,23 @@
         Group group = BaseWidgetUtils.createGroup( composite, "Authentication Method", 1
);
         Composite groupComposite = BaseWidgetUtils.createColumnContainer( group, 1, 1 );
 
-        anonymousAuthButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Anonymous
Authentication", 1 );
-        anonymousAuthButton.setSelection( authMethod == IConnection.AUTH_ANONYMOUS );
-        anonymousAuthButton.addSelectionListener( this );
-
-        simpleAuthButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Simple Authentication",
1 );
-        simpleAuthButton.setSelection( authMethod == IConnection.AUTH_SIMPLE );
-        simpleAuthButton.addSelectionListener( this );
-
-        // saslAuthButton = new Button(authenticationMethodGroup, SWT.RADIO);
-        // saslAuthButton.setText("SASL Authentication");
-        // saslAuthButton.setSelection(authMethod ==
-        // ConnectionParameter.AUTH_SASL);
-        // saslAuthButton.addSelectionListener(this);
+        String[] authMethods = new String[]
+                                         { "Anonymous Authentication", "Simple Authentication",
"DIGEST-MD5 (SASL)", "CRAM-MD5 (SASL)" };
+        
+        authenticationMethodCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite,
authMethods, authMethod, 2 );
+        authenticationMethodCombo.addSelectionListener( this );
     }
 
 
     /**
-     * Adds the simple auth input.
+     * Adds inputs for principal and pasword.
      * 
      * @param saveBindPassword the initial save bind password flag
      * @param bindPrincipal the initial bind principal
      * @param bindPassword the initial bind password
      * @param parent the parent
      */
-    public void addSimpleAuthInput( boolean saveBindPassword, String bindPrincipal, String
bindPassword,
+    public void addPrincipalPasswordInput( boolean saveBindPassword, String bindPrincipal,
String bindPassword,
         Composite parent )
     {
 
@@ -686,13 +681,13 @@
         saveSimpleAuthBindPasswordButton.setSelection( saveBindPassword );
         saveSimpleAuthBindPasswordButton.addSelectionListener( this );
 
-        checkSimpleAuthButton = new Button( composite, SWT.PUSH );
+        checkPrincipalPasswordAuthButton = new Button( composite, SWT.PUSH );
         GridData gd = new GridData( GridData.FILL_HORIZONTAL );
         gd.horizontalAlignment = SWT.RIGHT;
-        checkSimpleAuthButton.setLayoutData( gd );
-        checkSimpleAuthButton.setText( "Check Authentication" );
-        checkSimpleAuthButton.setEnabled( false );
-        checkSimpleAuthButton.addSelectionListener( new SelectionListener()
+        checkPrincipalPasswordAuthButton.setLayoutData( gd );
+        checkPrincipalPasswordAuthButton.setText( "Check Authentication" );
+        checkPrincipalPasswordAuthButton.setEnabled( false );
+        checkPrincipalPasswordAuthButton.addSelectionListener( new SelectionListener()
         {
             public void widgetSelected( SelectionEvent e )
             {
@@ -748,15 +743,14 @@
                 fetchBaseDnsButton.setEnabled( false );
             }
 
-            if ( anonymousAuthButton != null && simpleAuthButton != null )
+            if ( authenticationMethodCombo != null )
             {
-                anonymousAuthButton.setEnabled( false );
-                simpleAuthButton.setEnabled( false );
+                authenticationMethodCombo.setEnabled( false );
             }
             if ( saveSimpleAuthBindPasswordButton != null && saveSimpleAuthBindPasswordButton
!= null )
             {
                 saveSimpleAuthBindPasswordButton.setEnabled( false );
-                checkSimpleAuthButton.setEnabled( false );
+                checkPrincipalPasswordAuthButton.setEnabled( false );
             }
         }
         else
@@ -787,14 +781,13 @@
             if ( simpleAuthBindPrincipalCombo != null && simpleAuthBindPasswordText
!= null
                 && saveSimpleAuthBindPasswordButton != null )
             {
-                boolean simpleAuthSelected = simpleAuthButton == null || simpleAuthButton.getSelection();
-                simpleAuthBindPrincipalCombo.setEnabled( simpleAuthSelected );
+                simpleAuthBindPrincipalCombo.setEnabled( getPrincipalPasswordEnabled () );
                 simpleAuthBindPasswordText.setEnabled( saveSimpleAuthBindPasswordButton.getSelection()
-                    && simpleAuthSelected );
-                saveSimpleAuthBindPasswordButton.setEnabled( simpleAuthSelected );
-                checkSimpleAuthButton.setEnabled( saveSimpleAuthBindPasswordButton.getSelection()
+                    && getPrincipalPasswordEnabled () );
+                saveSimpleAuthBindPasswordButton.setEnabled( getPrincipalPasswordEnabled
() );
+                checkPrincipalPasswordAuthButton.setEnabled( saveSimpleAuthBindPasswordButton.getSelection()
                     && !simpleAuthBindPrincipalCombo.getText().equals( "" )
-                    && !simpleAuthBindPasswordText.getText().equals( "" ) &&
simpleAuthSelected );
+                    && !simpleAuthBindPasswordText.getText().equals( "" ) &&
getPrincipalPasswordEnabled () );
             }
         }
     }
@@ -808,8 +801,6 @@
         String message = null;
         String errorMessage = null;
 
-        boolean simpleAuthSelected = simpleAuthButton == null || simpleAuthButton.getSelection();
-
         if ( baseDNCombo != null && baseDNCombo.isVisible() )
         {
             try
@@ -821,14 +812,14 @@
                 message = "Please enter a valid base DN.";
             }
         }
-        if ( simpleAuthBindPasswordText != null && simpleAuthSelected &&
simpleAuthBindPasswordText.isVisible() )
+        if ( simpleAuthBindPasswordText != null && getPrincipalPasswordEnabled ()
&& simpleAuthBindPasswordText.isVisible() )
         {
             if ( saveSimpleAuthBindPasswordButton.getSelection() && "".equals( simpleAuthBindPasswordText.getText()
) )
             {
                 message = "Please enter a bind password.";
             }
         }
-        if ( simpleAuthBindPrincipalCombo != null && simpleAuthSelected &&
simpleAuthBindPrincipalCombo.isVisible() )
+        if ( simpleAuthBindPrincipalCombo != null && getPrincipalPasswordEnabled
() && simpleAuthBindPrincipalCombo.isVisible() )
         {
             if ( "".equals( simpleAuthBindPrincipalCombo.getText() ) )
             {
@@ -875,6 +866,13 @@
         }
     }
 
+    
+    private boolean getPrincipalPasswordEnabled ()
+    {
+        return ( getAuthenticationMethod() == IConnection.AUTH_SIMPLE )
+        || ( getAuthenticationMethod() == IConnection.AUTH_SASL_DIGMD5 )
+        || ( getAuthenticationMethod() == IConnection.AUTH_SASL_CRAMD5 );
+    }
 
     /**
      * {@inheritDoc}
@@ -917,41 +915,39 @@
      */
     public IConnection getTestConnection()
     {
+        String principal;
+        String password;
+        Connection conn;
+        
         if ( getAuthenticationMethod() == IConnection.AUTH_ANONYMOUS )
         {
-            Connection conn;
-            try
-            {
-                conn = new Connection( null, getHostName(), getPort(), getEncyrptionMethod(),
isAutoFetchBaseDns(),
-                    new DN( getBaseDN() ), getCountLimit(), getTimeLimit(), getAliasesDereferencingMethod(),
-                    getReferralsHandlingMethod(), IConnection.AUTH_ANONYMOUS, null, null
);
-            }
-            catch ( NameException e )
-            {
-                conn = null;
-            }
-            return conn;
+            principal = null;
+            password = null;
         }
-        else if ( getAuthenticationMethod() == IConnection.AUTH_SIMPLE )
+        else if ( getAuthenticationMethod() == IConnection.AUTH_SIMPLE
+            || getAuthenticationMethod() == IConnection.AUTH_SASL_DIGMD5
+            || getAuthenticationMethod() == IConnection.AUTH_SASL_CRAMD5 )
         {
-            Connection conn;
-            try
-            {
-                conn = new Connection( null, getHostName(), getPort(), getEncyrptionMethod(),
isAutoFetchBaseDns(),
-                    new DN( getBaseDN() ), getCountLimit(), getTimeLimit(), getAliasesDereferencingMethod(),
-                    getReferralsHandlingMethod(), IConnection.AUTH_SIMPLE, getSimpleAuthBindPrincipal(),
-                    getSimpleAuthBindPassword() );
-            }
-            catch ( NameException e )
-            {
-                conn = null;
-            }
-            return conn;
+            principal = getAuthBindPrincipal();
+            password = getAuthBindPassword();
         }
-        else
+        else 
         {
             return null;
         }
+        
+        
+        try
+        {
+            conn = new Connection( null, getHostName(), getPort(), getEncyrptionMethod(),
isAutoFetchBaseDns(),
+                new DN( getBaseDN() ), getCountLimit(), getTimeLimit(), getAliasesDereferencingMethod(),
+                getReferralsHandlingMethod(), getAuthenticationMethod(), principal, password
);
+        }
+        catch ( NameException e )
+        {
+            conn = null;
+        }
+        return conn;
     }
 
 

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionAuthWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionAuthWizardPage.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionAuthWizardPage.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionAuthWizardPage.java
Sun Jul 29 05:07:46 2007
@@ -131,8 +131,8 @@
         composite.setLayout( gl );
 
         wizard.getCpw().addAuthenticationMethodInput( IConnection.AUTH_SIMPLE, composite
);
-        wizard.getCpw().addSimpleAuthInput( true, "", "", composite );
-
+        wizard.getCpw().addPrincipalPasswordInput( true, "", "", composite );
+     
         setControl( composite );
     }
 

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionWizard.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionWizard.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewConnectionWizard.java
Sun Jul 29 05:07:46 2007
@@ -129,7 +129,9 @@
         {
             return mainPage.isPageComplete() && optionsPage.isPageComplete();
         }
-        else if ( cpw.getAuthenticationMethod() == IConnection.AUTH_SIMPLE )
+        else if ( cpw.getAuthenticationMethod() == IConnection.AUTH_SIMPLE
+            || cpw.getAuthenticationMethod() == IConnection.AUTH_SASL_CRAMD5
+            || cpw.getAuthenticationMethod() == IConnection.AUTH_SASL_DIGMD5 )
         {
             return mainPage.isPageComplete() && authPage.isPageComplete() &&
optionsPage.isPageComplete();
         }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Connection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Connection.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Connection.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Connection.java
Sun Jul 29 05:07:46 2007
@@ -795,18 +795,6 @@
         EventRegistry.fireConnectionUpdated( new ConnectionUpdateEvent( this,
             ConnectionUpdateEvent.EventDetail.CONNECTION_PARAMETER_UPDATED ), this );
     }
-    
-    public int getSASLMechanism ()
-    {
-    	return this.connectionParameter.getSaslMechanism();
-    }
-    
-    public void setSASLMechanism (int saslMethod)
-    {
-    	this.connectionParameter.setSaslMechanism(saslMethod);
-    	EventRegistry.fireConnectionUpdated(new ConnectionUpdateEvent (this,
-    			ConnectionUpdateEvent.EventDetail.CONNECTION_PARAMETER_UPDATED), this);
-    }
 
 
     public int getTimeLimit()

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionParameter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionParameter.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionParameter.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ConnectionParameter.java
Sun Jul 29 05:07:46 2007
@@ -70,7 +70,8 @@
     /** The referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE or IConnection.HANDLE_REFERRALS_FOLLOW.
*/
     private int referralsHandlingMethod;
 
-    /** The authentication method, one of IConnection.AUTH_ANONYMOUS or IConnection.AUTH_SIMPLE
*/
+    /** The authentication method, one of IConnection.AUTH_ANONYMOUS, IConnection.AUTH_SIMPLE,
+     * IConnection.AUTH_SASL_CRAMD5 or IConnection.AUTH_SASL_DIGMD5 */
     private int authMethod;
 
     /** The bind principal, typically a DN. */
@@ -307,8 +308,8 @@
 
 
     /**
-     * Gets the auth method, one of IConnection.AUTH_ANONYMOUS
-     * or IConnection.AUTH_SIMPLE.
+     * Gets the auth method, one of IConnection.AUTH_ANONYMOUS,
+     * IConnection.AUTH_SIMPLE, IConnection.AUTH_SASL_CRAMD5 or IConnection.AUTH_SASL_DIGMD5.
      * 
      * @return the auth method
      */

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IConnection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IConnection.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IConnection.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IConnection.java
Sun Jul 29 05:07:46 2007
@@ -53,6 +53,8 @@
     public static final int AUTH_SASL_DIGMD5 = 2;
     
     public static final int AUTH_SASL_CRAMD5 = 3;
+    
+    public static final int AUTH_SASL_GSSAPI = 4;
 
     public static final int ENCYRPTION_NONE = 0;
 

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ConnectionPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ConnectionPropertyPage.java?view=diff&rev=560714&r1=560713&r2=560714
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ConnectionPropertyPage.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ConnectionPropertyPage.java
Sun Jul 29 05:07:46 2007
@@ -132,7 +132,7 @@
         gl = new GridLayout( 1, false );
         authComposite.setLayout( gl );
         cpw.addAuthenticationMethodInput( connection.getAuthMethod(), authComposite );
-        cpw.addSimpleAuthInput( ( connection.getBindPassword() != null ) || ( connection.getBindPrincipal()
== null && connection.getBindPassword() == null ),
+        cpw.addPrincipalPasswordInput( ( connection.getBindPassword() != null ) || ( connection.getBindPrincipal()
== null && connection.getBindPassword() == null ),
             connection.getBindPrincipal() != null ? connection.getBindPrincipal().toString()
: "", connection
                 .getBindPassword() != null ? connection.getBindPassword() : "", authComposite
);
         this.authTab = new TabItem( this.tabFolder, SWT.NONE );
@@ -187,13 +187,15 @@
             connection.setBindPrincipal( null );
             connection.setBindPassword( null );
         }
-        if ( connection.getAuthMethod() == IConnection.AUTH_SIMPLE )
+        if ( connection.getAuthMethod() == IConnection.AUTH_SIMPLE
+            || connection.getAuthMethod() == IConnection.AUTH_SASL_CRAMD5
+            || connection.getAuthMethod() == IConnection.AUTH_SASL_DIGMD5 )
         {
             try
             {
-                connection.setBindPrincipal( cpw.getSimpleAuthBindPrincipal() );
+                connection.setBindPrincipal( cpw.getAuthBindPrincipal() );
                 connection
-                    .setBindPassword( cpw.isSaveSimpleAuthBindPassword() ? cpw.getSimpleAuthBindPassword()
: null );
+                    .setBindPassword( cpw.isSaveSimpleAuthBindPassword() ? cpw.getAuthBindPassword()
: null );
             }
             catch ( Exception e )
             {



Mime
View raw message