directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1466945 [2/2] - in /directory/studio/trunk/plugins: connection.core/src/main/java/org/apache/directory/studio/connection/core/ connection.ui/ connection.ui/src/main/java/org/apache/directory/studio/connection/ui/ connection.ui/src/main/jav...
Date Thu, 11 Apr 2013 16:23:24 GMT
Added: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/PasswordsKeystorePreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/PasswordsKeystorePreferencePage.java?rev=1466945&view=auto
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/PasswordsKeystorePreferencePage.java (added)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/preferences/PasswordsKeystorePreferencePage.java Thu Apr 11 16:23:23 2013
@@ -0,0 +1,682 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.connection.ui.preferences;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.studio.common.ui.CommonUIUtils;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.core.ConnectionManager;
+import org.apache.directory.studio.connection.core.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
+import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.apache.directory.studio.connection.ui.dialogs.PasswordDialog;
+import org.apache.directory.studio.connection.ui.dialogs.ResetPasswordDialog;
+import org.apache.directory.studio.connection.ui.dialogs.SetupPasswordDialog;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * The passwords keystore preference page contains the settings for keystore 
+ * where we store the connections passwords.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PasswordsKeystorePreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+    /** The filename for the temporary keystore */
+    private static final String TEMPORARY_KEYSTORE_FILENAME = "passwords-prefs-temp.jks";
+
+    /** The passwords keystore manager */
+    private PasswordsKeyStoreManager passwordsKeyStoreManager;
+
+    /** The map used to backup connections passwords */
+    private Map<String, String> connectionsPasswordsBackup = new HashMap<String, String>();
+
+    /** The connection manager */
+    private ConnectionManager connectionManager;
+
+    // UI Widgets
+    private Button enableKeystoreCheckbox;
+    private Button changeMasterPasswordButton;
+
+    // Listeners
+    private SelectionListener enableKeystoreCheckboxListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Boolean selected = enableKeystoreCheckbox.getSelection();
+
+            try
+            {
+                if ( selected )
+                {
+                    if ( !enablePasswordsKeystore() )
+                    {
+                        enableKeystoreCheckbox.setSelection( !selected );
+                    }
+                }
+                else
+                {
+                    if ( !disablePasswordsKeystore() )
+                    {
+                        enableKeystoreCheckbox.setSelection( !selected );
+                    }
+                }
+            }
+            catch ( KeyStoreException kse )
+            {
+                CommonUIUtils.openErrorDialog( "An error occurred when enabled/disabling the keystore.\n\n"
+                    + kse.getMessage() );
+
+                enableKeystoreCheckbox.setSelection( !selected );
+            }
+
+            updateButtonsEnabledState();
+        }
+    };
+    private SelectionListener changeMasterPasswordButtonListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            changeMasterPassword();
+        }
+    };
+
+
+    /**
+     * Creates a new instance of PasswordsKeyStorePreferencePage.
+     */
+    public PasswordsKeystorePreferencePage()
+    {
+        super( "Passwords KeyStore" );
+        super.setDescription( "General settings for Passwords Keystore:" );
+        super.noDefaultAndApplyButton();
+
+        passwordsKeyStoreManager = new PasswordsKeyStoreManager( TEMPORARY_KEYSTORE_FILENAME );
+        connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init( IWorkbench workbench )
+    {
+        // Getting the keystore file
+        File keystoreFile = ConnectionCorePlugin.getDefault().getPasswordsKeyStoreManager().getKeyStoreFile();
+
+        // If the keystore file exists, let's create a copy of it
+        if ( keystoreFile.exists() )
+        {
+            try
+            {
+                // Copying the file
+                FileUtils.copyFile( keystoreFile, getTemporaryKeystoreFile() );
+            }
+            catch ( IOException e )
+            {
+                ConnectionUIPlugin
+                    .getDefault()
+                    .getLog()
+                    .log(
+                        new Status( Status.ERROR, ConnectionUIConstants.PLUGIN_ID, Status.ERROR,
+                            "Couldn't duplicate the global keystore file.", e ) ); //$NON-NLS-1$
+            }
+        }
+    }
+
+
+    /**
+     * Gets the file for the temporary keystore.
+     *
+     * @return the  file for the temporary keystore
+     */
+    private File getTemporaryKeystoreFile()
+    {
+        return ConnectionCorePlugin.getDefault().getStateLocation().append( TEMPORARY_KEYSTORE_FILENAME ).toFile();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void contributeButtons( Composite parent )
+    {
+        // Increasing the number of columns on the parent layout
+        ( ( GridLayout ) parent.getLayout() ).numColumns++;
+
+        // Change Master Password Button
+        changeMasterPasswordButton = BaseWidgetUtils.createButton( parent, "Change Master Password...", 1 );
+        changeMasterPasswordButton.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) );
+        changeMasterPasswordButton.addSelectionListener( changeMasterPasswordButtonListener );
+
+        updateButtonsEnabledState();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Control createContents( Composite parent )
+    {
+        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+
+        // Enable Keystore Checkbox
+        enableKeystoreCheckbox = new Button( composite, SWT.CHECK | SWT.WRAP );
+        enableKeystoreCheckbox
+            .setText( "Store connections passwords in a password-protected keystore." );
+        enableKeystoreCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
+
+        // Warning Label
+        BaseWidgetUtils.createRadioIndent( composite, 1 );
+        BaseWidgetUtils
+            .createWrappedLabel(
+                composite,
+                "Warning: The passwords keystore requires the definition of a master password which will forbid any access to the connections passwords stored in the keystore if it gets forgotten.\n\nIf you need to change the master password, use the 'Change Master Password...' button at the bottom of this preference page.",
+                1 );
+
+        initUI();
+        addListeners();
+
+        return composite;
+    }
+
+
+    /**
+     * Initializes the UI.
+     */
+    private void initUI()
+    {
+        int connectionsPasswordsKeystore = ConnectionCorePlugin.getDefault().getPluginPreferences()
+            .getInt( ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE );
+
+        if ( connectionsPasswordsKeystore == ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_OFF )
+        {
+            enableKeystoreCheckbox.setSelection( false );
+        }
+        else if ( connectionsPasswordsKeystore == ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_ON )
+        {
+            enableKeystoreCheckbox.setSelection( true );
+        }
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        enableKeystoreCheckbox.addSelectionListener( enableKeystoreCheckboxListener );
+    }
+
+
+    /**
+     * Removes the listeners.
+     */
+    private void removeListeners()
+    {
+        enableKeystoreCheckbox.removeSelectionListener( enableKeystoreCheckboxListener );
+    }
+
+
+    /**
+     * Updates the buttons enabled state.
+     */
+    private void updateButtonsEnabledState()
+    {
+        changeMasterPasswordButton.setEnabled( enableKeystoreCheckbox.getSelection() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void performDefaults()
+    {
+        removeListeners();
+
+        int enablePasswordsKeystore = ConnectionCorePlugin.getDefault().getPluginPreferences()
+            .getDefaultInt( ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE );
+
+        if ( enablePasswordsKeystore == ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_OFF )
+        {
+            enableKeystoreCheckbox.setSelection( false );
+        }
+        else if ( enablePasswordsKeystore == ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_ON )
+        {
+            enableKeystoreCheckbox.setSelection( true );
+        }
+
+        updateButtonsEnabledState();
+        addListeners();
+
+        ConnectionCorePlugin.getDefault().savePluginPreferences();
+        super.performDefaults();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performOk()
+    {
+        PasswordsKeyStoreManager globalPasswordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+            .getPasswordsKeyStoreManager();
+
+        if ( enableKeystoreCheckbox.getSelection() )
+        {
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                // First, let's save the temporary keystore manager
+                try
+                {
+                    passwordsKeyStoreManager.save();
+                }
+                catch ( KeyStoreException e )
+                {
+                    ConnectionUIPlugin
+                        .getDefault()
+                        .getLog()
+                        .log(
+                            new Status( Status.ERROR, ConnectionUIConstants.PLUGIN_ID, Status.ERROR,
+                                "Couldn't save the temporary password keystore.", e ) ); //$NON-NLS-1$
+                }
+
+                // Now, let's copy the temporary keystore as the global keystore
+                try
+                {
+                    FileUtils.copyFile( getTemporaryKeystoreFile(), ConnectionCorePlugin.getDefault()
+                        .getPasswordsKeyStoreManager().getKeyStoreFile() );
+                }
+                catch ( IOException e )
+                {
+                    ConnectionUIPlugin
+                        .getDefault()
+                        .getLog()
+                        .log(
+                            new Status( Status.ERROR, ConnectionUIConstants.PLUGIN_ID, Status.ERROR,
+                                "Couldn't copy the temporary keystore as the global keystore.", e ) ); //$NON-NLS-1$
+                }
+
+                // Finally lets reload the global keystore
+                try
+                {
+                    globalPasswordsKeyStoreManager.reload( passwordsKeyStoreManager.getMasterPassword() );
+                }
+                catch ( KeyStoreException e )
+                {
+                    ConnectionUIPlugin
+                        .getDefault()
+                        .getLog()
+                        .log(
+                            new Status( Status.ERROR, ConnectionUIConstants.PLUGIN_ID, Status.ERROR,
+                                "Couldn't reload the global keystore file.", e ) ); //$NON-NLS-1$
+                }
+
+                // Clearing each connection password
+                for ( Connection connection : connectionManager.getConnections() )
+                {
+                    connection.getConnectionParameter().setBindPassword( null );
+                }
+
+                // Saving the connections
+                ConnectionCorePlugin.getDefault().getConnectionManager().saveConnections();
+
+                // Saving the value to the preferences
+                ConnectionCorePlugin.getDefault().getPluginPreferences()
+                    .setValue( ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE,
+                        ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_ON );
+            }
+        }
+        else
+        {
+            // Reseting the global passwords keystore
+            globalPasswordsKeyStoreManager.reset();
+
+            // Looking for connections passwords in the list
+            if ( connectionsPasswordsBackup.size() > 0 )
+            {
+                // Adding them to the keystore
+                for ( String connectionId : connectionsPasswordsBackup.keySet() )
+                {
+                    Connection connection = connectionManager.getConnectionById( connectionId );
+
+                    if ( connection != null )
+                    {
+                        connection.getConnectionParameter().setBindPassword(
+                            connectionsPasswordsBackup.get( connectionId ) );
+                    }
+                }
+
+                // Saving the connections
+                ConnectionCorePlugin.getDefault().getConnectionManager().saveConnections();
+            }
+
+            // Saving the value to the preferences
+            ConnectionCorePlugin.getDefault().getPluginPreferences()
+                .setValue( ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE,
+                    ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_OFF );
+        }
+
+        ConnectionCorePlugin.getDefault().savePluginPreferences();
+
+        deleteTemporaryKeystore();
+        return true;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performCancel()
+    {
+        deleteTemporaryKeystore();
+        return true;
+    }
+
+
+    /**
+     * Deletes the temporary keystore (if it exists)
+     */
+    private void deleteTemporaryKeystore()
+    {
+        // Getting the temporary keystore file
+        File temporaryKeystoreFile = getTemporaryKeystoreFile();
+
+        // If the temporary keystore file exists, we need to remove it
+        if ( temporaryKeystoreFile.exists() )
+        {
+            // Deleting the file
+            FileUtils.deleteQuietly( temporaryKeystoreFile );
+        }
+    }
+
+
+    /**
+     * Enables the passwords keystore.
+     *
+     * @return <code>true</code> if the passwords keystore was successfully enabled,
+     *         <code>false</code> if not.
+     * @throws KeyStoreException 
+     */
+    private boolean enablePasswordsKeystore() throws KeyStoreException
+    {
+        // Asking the user for a password
+        SetupPasswordDialog setupPasswordDialog = new SetupPasswordDialog(
+            enableKeystoreCheckbox.getShell(),
+            "Setup Master Password",
+            "Please enter a master password to secure the passwords keystore.\n\nIf you forget this master password you will not be able to access information stored in the passwords keystore. The master password cannot be retrieved.",
+            null );
+
+        if ( setupPasswordDialog.open() == SetupPasswordDialog.OK )
+        {
+            // Getting the master password
+            String masterPassword = setupPasswordDialog.getPassword();
+
+            // Loading the keystore
+            passwordsKeyStoreManager.load( masterPassword );
+
+            // Storing each connection password in the keystore
+            for ( Connection connection : connectionManager.getConnections() )
+            {
+                String connectionPassword = connection.getBindPassword();
+
+                if ( connectionPassword != null )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connection, connectionPassword, false );
+                }
+            }
+
+            // Saving the keystore on disk
+            passwordsKeyStoreManager.save();
+
+            return true;
+        }
+
+        return false;
+    }
+
+
+    /**
+     * Disables the passwords keystore.
+     *
+     * @return <code>true</code> if the passwords keystore was successfully disabled,
+     *         <code>false</code> if not.
+     */
+    private boolean disablePasswordsKeystore()
+    {
+        // Asking the user if he wants to keep its connections passwords
+        MessageDialog keepConnectionsPasswordsDialog = new MessageDialog(
+            enableKeystoreCheckbox.getShell(),
+            "Keep Connections Passwords?",
+            null,
+            "Do you want to keep your connections passwords?\n\nAll connections passwords contained in the passwords keystore will be copied and stored as plain text on disk.\nRequires the master password of the passwords keystore.",
+            MessageDialog.QUESTION, new String[]
+                { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
+                    IDialogConstants.CANCEL_LABEL }, 0 );
+        int keepConnectionsPasswordsValue = keepConnectionsPasswordsDialog.open();
+
+        if ( keepConnectionsPasswordsValue == 1 )
+        {
+            // The user chose NOT to keep the connections passwords
+            connectionsPasswordsBackup.clear();
+            passwordsKeyStoreManager.deleteKeystoreFile();
+            return true;
+        }
+        else if ( keepConnectionsPasswordsValue == 0 )
+        {
+            // The user chose to keep the connections passwords
+            connectionsPasswordsBackup.clear();
+
+            while ( true )
+            {
+                // We ask the user for the keystore password
+                PasswordDialog passwordDialog = new PasswordDialog( enableKeystoreCheckbox.getShell(),
+                    "Verify Master Password", "Please enter your master password:",
+                    null );
+
+                if ( passwordDialog.open() == PasswordDialog.CANCEL )
+                {
+                    // The user cancelled the action
+                    return false;
+                }
+
+                // Getting the password
+                String password = passwordDialog.getPassword();
+
+                // Checking the password
+                Exception checkPasswordException = null;
+                try
+                {
+                    if ( passwordsKeyStoreManager.checkMasterPassword( password ) )
+                    {
+                        break;
+                    }
+                }
+                catch ( KeyStoreException e )
+                {
+                    checkPasswordException = e;
+                }
+
+                // Creating the message
+                String message = null;
+
+                if ( checkPasswordException != null )
+                {
+                    message = "The master password verification failed.\n\nThe following exception was raised:\n"
+                        + checkPasswordException.getMessage();
+                }
+                else
+                {
+                    message = "The master password verification failed.";
+                }
+
+                // We ask the user if he wants to retry to unlock the passwords keystore
+                MessageDialog errorDialog = new MessageDialog(
+                    enableKeystoreCheckbox.getShell(),
+                    "Verify Master Password Failed", null, message, MessageDialog.ERROR, new String[]
+                        { IDialogConstants.RETRY_LABEL,
+                            IDialogConstants.CANCEL_LABEL }, 0 );
+
+                if ( errorDialog.open() == MessageDialog.CANCEL )
+                {
+                    // The user cancelled the action
+                    password = null;
+                    return false;
+                }
+            }
+
+            // Getting the connection IDs having their passwords saved in the keystore
+            String[] connectionIds = passwordsKeyStoreManager.getConnectionIds();
+
+            if ( connectionIds != null )
+            {
+                // Adding the passwords to the backup map
+                for ( String connectionId : connectionIds )
+                {
+                    String password = passwordsKeyStoreManager.getConnectionPassword( connectionId );
+
+                    if ( password != null )
+                    {
+                        connectionsPasswordsBackup.put( connectionId, password );
+                    }
+                }
+            }
+
+            passwordsKeyStoreManager.deleteKeystoreFile();
+
+            return true;
+        }
+        else
+        {
+            // The user cancelled the action
+            return false;
+        }
+    }
+
+
+    /**
+     * Changes the master password.
+     *
+     * @return <code>true</code> if the master password was successfully changed,
+     *         <code>false</code> if not.
+     */
+    private void changeMasterPassword()
+    {
+        String newMasterPassword = null;
+
+        while ( true )
+        {
+            // We ask the user to reset his master password
+            ResetPasswordDialog resetPasswordDialog = new ResetPasswordDialog( changeMasterPasswordButton.getShell(),
+                "", null, null );
+
+            if ( resetPasswordDialog.open() != ResetPasswordDialog.OK )
+            {
+                // The user cancelled the action
+                return;
+            }
+
+            // Checking the password
+            Exception checkPasswordException = null;
+            try
+            {
+                if ( passwordsKeyStoreManager.checkMasterPassword( resetPasswordDialog.getCurrentPassword() ) )
+                {
+                    newMasterPassword = resetPasswordDialog.getNewPassword();
+                    break;
+                }
+            }
+            catch ( KeyStoreException e )
+            {
+                checkPasswordException = e;
+            }
+
+            // Creating the message
+            String message = null;
+
+            if ( checkPasswordException != null )
+            {
+                message = "The master password verification failed.\n\nThe following exception was raised:\n"
+                    + checkPasswordException.getMessage();
+            }
+            else
+            {
+                message = "The master password verification failed.";
+            }
+
+            // We ask the user if he wants to retry to unlock the passwords keystore
+            MessageDialog errorDialog = new MessageDialog(
+                enableKeystoreCheckbox.getShell(),
+                "Verify Master Password Failed", null, message, MessageDialog.ERROR, new String[]
+                    { IDialogConstants.RETRY_LABEL,
+                        IDialogConstants.CANCEL_LABEL }, 0 );
+
+            if ( errorDialog.open() == MessageDialog.CANCEL )
+            {
+                // The user cancelled the action
+                return;
+            }
+        }
+
+        if ( newMasterPassword != null )
+        {
+            try
+            {
+                passwordsKeyStoreManager.setMasterPassword( newMasterPassword );
+                passwordsKeyStoreManager.save();
+            }
+            catch ( KeyStoreException e )
+            {
+                ConnectionUIPlugin
+                    .getDefault()
+                    .getLog()
+                    .log(
+                        new Status( Status.ERROR, ConnectionUIConstants.PLUGIN_ID, Status.ERROR,
+                            "Couldn't save the keystore file.", e ) ); //$NON-NLS-1$
+            }
+        }
+    }
+}
\ No newline at end of file

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java (original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/properties/ConnectionPropertyPage.java Thu Apr 11 16:23:23 2013
@@ -23,7 +23,9 @@ package org.apache.directory.studio.conn
 
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.apache.directory.studio.connection.core.ConnectionParameter;
+import org.apache.directory.studio.connection.core.PasswordsKeyStoreManager;
 import org.apache.directory.studio.connection.core.Utils;
 import org.apache.directory.studio.connection.core.jobs.CloseConnectionsRunnable;
 import org.apache.directory.studio.connection.core.jobs.StudioConnectionJob;
@@ -31,6 +33,7 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.ui.ConnectionParameterPageManager;
 import org.apache.directory.studio.connection.ui.ConnectionParameterPageModifyListener;
 import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridLayout;
@@ -50,7 +53,6 @@ import org.eclipse.ui.dialogs.PropertyPa
  */
 public class ConnectionPropertyPage extends PropertyPage implements ConnectionParameterPageModifyListener
 {
-
     /** The tab folder. */
     private TabFolder tabFolder;
 
@@ -188,6 +190,27 @@ public class ConnectionPropertyPage exte
         PlatformUI.getWorkbench().getHelpSystem().setHelp( parent,
             ConnectionUIConstants.PLUGIN_ID + "." + "tools_connection_properties" ); //$NON-NLS-1$ //$NON-NLS-2$
 
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the passwords keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is not loaded 
+            if ( !passwordsKeyStoreManager.isLoaded() )
+            {
+                // Asking the user to load the keystore
+                if ( !PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    // The user failed to load the keystore and cancelled
+                    Label label = BaseWidgetUtils.createLabel( parent,
+                        "Access to the passwords keystore is required to view the properties of a connection.", 1 );
+                    return label;
+                }
+            }
+        }
+
         Connection connection = getConnection( getElement() );
         if ( connection != null )
         {
@@ -228,6 +251,16 @@ public class ConnectionPropertyPage exte
      */
     public boolean performOk()
     {
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Checking if the keystore is not loaded 
+            if ( !ConnectionCorePlugin.getDefault().getPasswordsKeyStoreManager().isLoaded() )
+            {
+                return true;
+            }
+        }
+
         // get current connection parameters
         Connection connection = ( Connection ) getConnection( getElement() );
 
@@ -258,5 +291,4 @@ public class ConnectionPropertyPage exte
 
         return true;
     }
-
 }

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java (original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java Thu Apr 11 16:23:23 2013
@@ -35,10 +35,12 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
 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.PasswordsKeyStoreManager;
 import org.apache.directory.studio.connection.core.jobs.CheckBindRunnable;
 import org.apache.directory.studio.connection.ui.AbstractConnectionParameterPage;
 import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Preferences;
@@ -272,10 +274,6 @@ public class AuthenticationParameterPage
     }
 
 
-    //    {
-    //        krb5
-    //    }
-
     /**
      * Returns true if the bind password should be saved on disk.
      * 
@@ -600,8 +598,29 @@ public class AuthenticationParameterPage
                     : parameter.getAuthMethod() == AuthenticationMethod.SASL_GSSAPI ? 4 : 0;
         authenticationMethodCombo.select( index );
         bindPrincipalCombo.setText( parameter.getBindPrincipal() );
-        bindPasswordText.setText( parameter.getBindPassword() != null ? parameter.getBindPassword() : "" ); //$NON-NLS-1$
-        saveBindPasswordButton.setSelection( parameter.getBindPassword() != null );
+
+        String bindPassword = null;
+
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                bindPassword = passwordsKeyStoreManager.getConnectionPassword( parameter.getId() );
+            }
+        }
+        else
+        {
+            bindPassword = parameter.getBindPassword();
+        }
+
+        bindPasswordText.setText( bindPassword != null ? bindPassword : "" ); //$NON-NLS-1$
+        saveBindPasswordButton.setSelection( bindPassword != null );
 
         saslRealmText.setText( parameter.getSaslRealm() != null ? parameter.getSaslRealm() : "" ); //$NON-NLS-1$
         int qopIndex = parameter.getSaslQop() == SaslQoP.AUTH_INT ? 1
@@ -809,7 +828,24 @@ public class AuthenticationParameterPage
     {
         parameter.setAuthMethod( getAuthenticationMethod() );
         parameter.setBindPrincipal( getBindPrincipal() );
-        parameter.setBindPassword( getBindPassword() );
+
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( parameter.getId(), getBindPassword() );
+            }
+        }
+        else
+        {
+            parameter.setBindPassword( getBindPassword() );
+        }
 
         parameter.setSaslRealm( getSaslRealm() );
         parameter.setSaslQop( getSaslQop() );

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v153/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v153/pom.xml?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v153/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v153/pom.xml Thu Apr 11 16:23:23 2013
@@ -118,6 +118,7 @@
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
  org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
  org.apache.directory.studio.ldapservers,
  org.apache.mina.core;bundle-version="${org.apache.mina.version}",
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
@@ -438,6 +439,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v153/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v153/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v153/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v153/CreateConnectionAction.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v153/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v153/CreateConnectionAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v153/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v153/CreateConnectionAction.java Thu Apr 11 16:23:23 2013
@@ -27,7 +27,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter;
 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.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.views.ServersView;
@@ -164,7 +165,31 @@ public class CreateConnectionAction impl
         }
 
         // Bind password
-        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+            }
+            else
+            {
+                // Asking the user to load the keystore
+                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else
+        {
+            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        }
 
         // Bind principal
         connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v154/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v154/pom.xml?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v154/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v154/pom.xml Thu Apr 11 16:23:23 2013
@@ -118,6 +118,7 @@
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
  org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
  org.apache.directory.studio.ldapservers,
  org.apache.mina.core;bundle-version="${org.apache.mina.version}",
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
@@ -458,6 +459,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v154/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v154/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v154/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v154/CreateConnectionAction.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v154/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v154/CreateConnectionAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v154/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v154/CreateConnectionAction.java Thu Apr 11 16:23:23 2013
@@ -27,7 +27,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter;
 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.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.views.ServersView;
@@ -164,7 +165,31 @@ public class CreateConnectionAction impl
         }
 
         // Bind password
-        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+            }
+            else
+            {
+                // Asking the user to load the keystore
+                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else
+        {
+            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        }
 
         // Bind principal
         connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v155/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v155/pom.xml?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v155/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v155/pom.xml Thu Apr 11 16:23:23 2013
@@ -118,6 +118,7 @@
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
  org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
  org.apache.directory.studio.ldapservers,
  org.apache.mina.core;bundle-version="${org.apache.mina.version}",
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
@@ -468,6 +469,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v155/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v155/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v155/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v155/CreateConnectionAction.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v155/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v155/CreateConnectionAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v155/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v155/CreateConnectionAction.java Thu Apr 11 16:23:23 2013
@@ -27,7 +27,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter;
 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.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.views.ServersView;
@@ -164,7 +165,31 @@ public class CreateConnectionAction impl
         }
 
         // Bind password
-        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+            }
+            else
+            {
+                // Asking the user to load the keystore
+                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else
+        {
+            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        }
 
         // Bind principal
         connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/pom.xml Thu Apr 11 16:23:23 2013
@@ -118,6 +118,7 @@
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
  org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
  org.apache.directory.studio.ldapservers,
  org.apache.mina.core;bundle-version="${org.apache.mina.version}",
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
@@ -563,6 +564,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v156/CreateConnectionAction.java Thu Apr 11 16:23:23 2013
@@ -27,7 +27,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter;
 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.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.views.ServersView;
@@ -164,7 +165,31 @@ public class CreateConnectionAction impl
         }
 
         // Bind password
-        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+            }
+            else
+            {
+                // Asking the user to load the keystore
+                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else
+        {
+            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        }
 
         // Bind principal
         connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v157/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v157/pom.xml?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v157/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v157/pom.xml Thu Apr 11 16:23:23 2013
@@ -118,6 +118,7 @@
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
  org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
  org.apache.directory.studio.ldapservers,
  org.apache.mina.core;bundle-version="${org.apache.mina.version}",
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
@@ -563,6 +564,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v157/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v157/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v157/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v157/CreateConnectionAction.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v157/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v157/CreateConnectionAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v157/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v157/CreateConnectionAction.java Thu Apr 11 16:23:23 2013
@@ -27,6 +27,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter;
 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.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.views.ServersView;
@@ -163,7 +165,31 @@ public class CreateConnectionAction impl
         }
 
         // Bind password
-        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+            }
+            else
+            {
+                // Asking the user to load the keystore
+                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else
+        {
+            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        }
 
         // Bind principal
         connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v200/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/pom.xml?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/pom.xml Thu Apr 11 16:23:23 2013
@@ -121,6 +121,7 @@
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
  org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
  org.apache.directory.studio.ldapservers,
  org.apache.mina.core;bundle-version="${org.apache.mina.version}",
  org.eclipse.core.runtime,
@@ -232,6 +233,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
       <artifactId>ldapservers</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java?rev=1466945&r1=1466944&r2=1466945&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java (original)
+++ directory/studio/trunk/plugins/ldapservers.apacheds.v200/src/main/java/org/apache/directory/studio/ldapservers/apacheds/v200/CreateConnectionAction.java Thu Apr 11 16:23:23 2013
@@ -29,6 +29,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
 import org.apache.directory.studio.connection.core.ConnectionServerType;
 import org.apache.directory.studio.connection.core.DetectedConnectionProperties;
+import org.apache.directory.studio.connection.core.PasswordsKeyStoreManager;
+import org.apache.directory.studio.connection.ui.PasswordsKeyStoreManagerUtils;
 import org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.views.ServersView;
@@ -166,7 +168,31 @@ public class CreateConnectionAction impl
         }
 
         // Bind password
-        connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        // Checking of the connection passwords keystore is enabled
+        if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
+        {
+            // Getting the password keystore manager
+            PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
+                .getPasswordsKeyStoreManager();
+
+            // Checking if the keystore is loaded 
+            if ( passwordsKeyStoreManager.isLoaded() )
+            {
+                passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+            }
+            else
+            {
+                // Asking the user to load the keystore
+                if ( PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
+                {
+                    passwordsKeyStoreManager.storeConnectionPassword( connectionParameter.getId(), "secret" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else
+        {
+            connectionParameter.setBindPassword( "secret" ); //$NON-NLS-1$
+        }
 
         // Bind principal
         connectionParameter.setBindPrincipal( "uid=admin,ou=system" ); //$NON-NLS-1$



Mime
View raw message