Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2012-05-22 08:41:29 +0000
committerMarkus Tiede2012-05-22 08:41:29 +0000
commit886da68a8bc13b71394010e5fc0fa76260cf85f5 (patch)
treeeb0df3311ea0b7322cded9b989e5c09ab3ee8ad8
parent4e744ddcfed5991e55734930aceb6385c77d642c (diff)
downloadorg.eclipse.jubula.core-886da68a8bc13b71394010e5fc0fa76260cf85f5.tar.gz
org.eclipse.jubula.core-886da68a8bc13b71394010e5fc0fa76260cf85f5.tar.xz
org.eclipse.jubula.core-886da68a8bc13b71394010e5fc0fa76260cf85f5.zip
Sprint task - review and apply patch for enhancement 378971.
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java1
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties1
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Persistor.java53
-rw-r--r--org.eclipse.jubula.client.ui.rcp/plugin.xml9
-rw-r--r--org.eclipse.jubula.client.ui/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.jubula.client.ui/plugin.xml5
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/SecurePreferenceBP.java413
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java17
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java182
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractSelectDatabaseHandler.java202
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java3
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties3
-rw-r--r--org.eclipse.jubula.feature/feature.xml1
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java3
14 files changed, 840 insertions, 57 deletions
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java
index 701d2f01b..125ac8a32 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/Messages.java
@@ -114,6 +114,7 @@ public class Messages extends NLS {
public static String CurrenActionNotAvailabelForSelectedToolkit;
public static String DatabaseConnectionInvalidPreferenceString;
public static String DatabaseConnectionEstablished;
+ public static String DatabaseProfileDoesNotExist;
public static String DataEventDispatcherReopenProject;
public static String DataSource;
public static String DBEntryMissingAmbiguous;
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties
index fd087b13f..4ebd04954 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/i18n/messages.properties
@@ -100,6 +100,7 @@ CreatingMessageSharedInstanceFailed=creating a Message sharedInstance failed\: N
CurrenActionNotAvailabelForSelectedToolkit=Current Action not available for selected Toolkit. Please check project properties
DatabaseConnectionEstablished=Database\:\tConnection established.
DatabaseConnectionInvalidPreferenceString=Invalid Database Connection will not be loaded from Preference Store\:\n{0}
+DatabaseProfileDoesNotExist=The Database Profile does not exists anymore.
DataEventDispatcherReopenProject=Please try to open your project again.
DataSource=DataSource
DBEntryMissingAmbiguous=db entry for DBVersion is missing or ambiguous
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Persistor.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Persistor.java
index a3ae7525e..80879fdad 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Persistor.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/Persistor.java
@@ -272,32 +272,39 @@ public class Persistor {
private void buildSessionFactoryWithLoginData(String userName, String pwd,
String url, IProgressMonitor monitor) throws PersistenceException,
PMDatabaseConfException, JBException, DatabaseVersionConflictException {
- monitor.beginTask(
- NLS.bind(Messages.ConnectingToDatabase, new Object[] {
- userName, dbConnectionInfo.getConnectionUrl() }),
- IProgressMonitor.UNKNOWN);
- m_sf = createEntityManagerFactory(dbConnectionInfo, userName, pwd, url);
-
- EntityManager em = null;
- try {
- em = m_sf.createEntityManager();
+ if (userName != null) {
+ monitor.beginTask(
+ NLS.bind(Messages.ConnectingToDatabase, new Object[] {
+ userName, dbConnectionInfo.
+ getConnectionUrl() }),
+ IProgressMonitor.UNKNOWN);
+ m_sf = createEntityManagerFactory(dbConnectionInfo, userName, pwd,
+ url);
+
+ EntityManager em = null;
try {
- validateDBVersion(em);
- monitor.subTask(Messages.DatabaseConnectionEstablished);
- } catch (AmbiguousDatabaseVersionException e) {
- throw new PMDatabaseConfException(
- Messages.DBVersionProblem + StringConstants.DOT,
- MessageIDs.E_NOT_CHECKABLE_DB_VERSION);
- }
- } catch (PersistenceException e) {
+ em = m_sf.createEntityManager();
+ try {
+ validateDBVersion(em);
+ monitor.subTask(Messages.DatabaseConnectionEstablished);
+ } catch (AmbiguousDatabaseVersionException e) {
+ throw new PMDatabaseConfException(Messages.DBVersionProblem
+ + StringConstants.DOT,
+ MessageIDs.E_NOT_CHECKABLE_DB_VERSION);
+ }
+ } catch (PersistenceException e) {
- log.error(Messages.NoOrWrongUsernameOrPassword, e);
- throw new JBException(e.getMessage(),
- MessageIDs.E_NO_DB_CONNECTION);
- } finally {
- if (em != null) {
- em.close();
+ log.error(Messages.NoOrWrongUsernameOrPassword, e);
+ throw new JBException(e.getMessage(),
+ MessageIDs.E_NO_DB_CONNECTION);
+ } finally {
+ if (em != null) {
+ em.close();
+ }
}
+ } else {
+ throw new JBException(Messages.DatabaseProfileDoesNotExist,
+ MessageIDs.E_DB_PROFILE_NOT_EXIST);
}
}
diff --git a/org.eclipse.jubula.client.ui.rcp/plugin.xml b/org.eclipse.jubula.client.ui.rcp/plugin.xml
index bfbb5ada9..3b349aedd 100644
--- a/org.eclipse.jubula.client.ui.rcp/plugin.xml
+++ b/org.eclipse.jubula.client.ui.rcp/plugin.xml
@@ -1570,8 +1570,13 @@
style="push" />
<separator name="JubulaProjectSeparator0" />
<command
- commandId="org.eclipse.jubula.client.ui.commands.SelectDatabase"
- style="push" />
+ commandId="org.eclipse.jubula.client.ui.commands.SelectDatabase"
+ style="push">
+ <parameter
+ name="org.eclipse.jubula.client.ui.selectDatabaseParameter"
+ value="true">
+ </parameter>
+ </command>
<separator
name="JubulaProjectSeparator1"
visible="true" />
diff --git a/org.eclipse.jubula.client.ui/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.ui/META-INF/MANIFEST.MF
index 6f3020407..10f9dd749 100644
--- a/org.eclipse.jubula.client.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.client.ui/META-INF/MANIFEST.MF
@@ -23,8 +23,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
org.eclipse.core.databinding;bundle-version="[1.3.100,2.0.0)",
org.eclipse.core.databinding.beans;bundle-version="[1.2.100,2.0.0)",
org.eclipse.core.databinding.property;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.help;bundle-version="[3.5.0,4.0.0)"
+ org.eclipse.help;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)"
Export-Package: org.eclipse.jubula.client.ui.adapter,
+ org.eclipse.jubula.client.ui.businessprocess,
org.eclipse.jubula.client.ui.constants,
org.eclipse.jubula.client.ui.controllers.propertysources,
org.eclipse.jubula.client.ui.databinding,
diff --git a/org.eclipse.jubula.client.ui/plugin.xml b/org.eclipse.jubula.client.ui/plugin.xml
index 1237f6940..b0adbcfd1 100644
--- a/org.eclipse.jubula.client.ui/plugin.xml
+++ b/org.eclipse.jubula.client.ui/plugin.xml
@@ -209,6 +209,11 @@
<command
categoryId="org.eclipse.jubula.client.ui.commands"
id="org.eclipse.jubula.client.ui.commands.SelectDatabase" name="%SelectDatabase">
+ <commandParameter
+ id="org.eclipse.jubula.client.ui.selectDatabaseParameter"
+ name="explicitSelection"
+ optional="true">
+ </commandParameter>
</command>
<command
categoryId="org.eclipse.jubula.client.ui.commands"
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/SecurePreferenceBP.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/SecurePreferenceBP.java
new file mode 100644
index 000000000..84ef0cba6
--- /dev/null
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/businessprocess/SecurePreferenceBP.java
@@ -0,0 +1,413 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.ui.businessprocess;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jubula.tools.constants.DebugConstants;
+import org.eclipse.jubula.tools.constants.StringConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.eclipse.jubula.client.core.Activator;
+import org.eclipse.jubula.client.core.preferences.database.DatabaseConnection;
+import org.eclipse.jubula.client.core.preferences.database.DatabaseConnectionConverter;
+import org.eclipse.jubula.client.ui.Plugin;
+import org.eclipse.jubula.client.ui.constants.Constants;
+
+/**
+ * @author BREDEX GmbH
+ * @created 03.04.2012
+ */
+public class SecurePreferenceBP {
+ /**
+ * the logger
+ */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SecurePreferenceBP.class);
+
+ /**
+ * the singleton instance
+ */
+ private static SecurePreferenceBP instance;
+
+ /**
+ * private constructor
+ */
+ private SecurePreferenceBP() {
+
+ IEclipsePreferences prefs = InstanceScope.INSTANCE
+ .getNode(Activator.PLUGIN_ID);
+ prefs.addPreferenceChangeListener(
+ new IEclipsePreferences.IPreferenceChangeListener() {
+
+ public void preferenceChange(PreferenceChangeEvent event) {
+ String[] oldProfileName = getProfileName(event, true);
+ String[] newProfileName = getProfileName(event, false);
+
+ // when oldProfileName and newProfileName are empty
+ // ---> new database schema was created
+ if (oldProfileName.length != 0
+ && newProfileName.length != 0) {
+ String oldName = StringConstants.EMPTY;
+ String newName = StringConstants.EMPTY;
+ for (int i = 0; i < oldProfileName.length; i++) {
+ oldName = oldProfileName[i];
+ newName = newProfileName[i];
+ if (oldName != null && newName != null) {
+ renameProfile(oldName,
+ newName);
+ IPreferenceStore store = Plugin.getDefault().
+ getPreferenceStore();
+ if (store.getString(Constants.
+ AUTOMATIC_DATABASE_CONNECTION_KEY).
+ equals(oldName)) {
+ store.setValue(Constants.
+ AUTOMATIC_DATABASE_CONNECTION_KEY,
+ newName);
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * creates the instance of this class or...
+ *
+ * @return returns the instance if already exists
+ */
+ public static SecurePreferenceBP getInstance() {
+ if (instance == null) {
+ instance = new SecurePreferenceBP();
+ }
+ return instance;
+ }
+
+ /**
+ * checks whether save password is activated
+ *
+ * @param profileName the profile name
+ * @return returns true if save password is activated
+ */
+ public boolean isSaveCredentialsActive(String profileName) {
+ boolean saveProfile = false;
+ HashSet<String> setProfiles = new HashSet<String>();
+ setProfiles.clear();
+ setProfiles = (HashSet<String>) splitProfileString(
+ Constants.SAVE_PROFILE_NAMES_KEY);
+
+ if (!setProfiles.isEmpty()) {
+ for (int i = 0; i < setProfiles.size(); i++) {
+ if (setProfiles.contains(profileName)) {
+ saveProfile = true;
+ }
+ }
+ }
+ return saveProfile;
+ }
+
+ /**
+ * Saves the profile names as a String separated by ";" in the preference
+ * store. Is a profile listed in that String a profiled is created in
+ * secure storage.
+ * @see isSaveCredentialsActive
+ *
+ * @param profileName
+ * the profile to save
+ * @param status true sets the save profile feature as active
+ * false sets the feature as inactive
+ */
+ public void setSaveCredentialStatus(String profileName, boolean status) {
+ IPreferenceStore store = Plugin.getDefault().getPreferenceStore();
+ HashSet<String> setProfiles = new HashSet<String>();
+ setProfiles.clear();
+ setProfiles = (HashSet<String>) splitProfileString(
+ Constants.SAVE_PROFILE_NAMES_KEY);
+ StringBuffer bufferProfiles = new StringBuffer();
+ if (status) {
+ setProfiles.add(profileName);
+ bufferProfiles.append(StringConstants.SEMICOLON);
+ for (String profileNames : setProfiles) {
+ bufferProfiles.append(profileNames).append(
+ StringConstants.SEMICOLON);
+ }
+ store.setValue(Constants.SAVE_PROFILE_NAMES_KEY,
+ bufferProfiles.toString());
+ } else {
+ if (setProfiles.contains(profileName)) {
+ setProfiles.remove(profileName);
+ for (String profileNames : setProfiles) {
+ bufferProfiles.append(profileNames).append(
+ StringConstants.SEMICOLON);
+ }
+ store.setValue(Constants.SAVE_PROFILE_NAMES_KEY,
+ bufferProfiles.toString());
+ }
+ }
+ }
+
+ /**
+ * splits the profile preference string value into the several profiles
+ *
+ * @param preferenceKey the preference key for profile names
+ * @return returns the several profile names as a Set to ensure that that
+ * every profile name is individually
+ */
+ private Set<String> splitProfileString(String preferenceKey) {
+ IPreferenceStore store = Plugin.getDefault().getPreferenceStore();
+ String profileNames = store.getString(preferenceKey);
+ String[] arrayProfiles = profileNames.split(StringConstants.SEMICOLON);
+
+ HashSet<String> setProfiles = new HashSet<String>();
+ for (String profile : arrayProfiles) {
+ setProfiles.add(profile);
+ }
+ return setProfiles;
+ }
+
+ /**
+ * creates the profile node in secure storage and saves the passed user name
+ * and password
+ *
+ * @param profileName
+ * the profile name in secure storage
+ * @param userName
+ * the username
+ */
+ public void saveProfile(String profileName, String userName) {
+ ISecurePreferences node = getNodeForProfile(profileName);
+ if (node != null) {
+ try {
+ node.put(Constants.SECURE_STORAGE_USERNAME_KEY, userName,
+ false);
+ } catch (StorageException e1) {
+ LOG.error(DebugConstants.ERROR, e1);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param profileName the profile name in secure storage
+ * @param password the password
+ */
+ public void saveProfilePassword(String profileName, String password) {
+ ISecurePreferences node = getNodeForProfile(profileName);
+ if (node != null) {
+ try {
+ node.put(Constants.SECURE_STORAGE_PASSWORD_KEY, password, true);
+ } catch (StorageException e2) {
+ LOG.error(DebugConstants.ERROR, e2);
+ }
+ }
+ }
+
+ /**
+ * removes the profile from secure storage and its entries
+ *
+ * @param profileName
+ * the profile name in secure storage
+ */
+ public void removeProfile(String profileName) {
+ ISecurePreferences node = getNodeForProfile(profileName);
+ if (node != null) {
+ if (!isSaveCredentialsActive(profileName)) {
+ node.removeNode();
+ }
+ }
+ }
+
+ /**
+ * renames the profile in secure storage and preference store when database
+ * schema was renamed in database preferences
+ *
+ * @param oldProfileName the old profile name
+ * @param newProfileName the new profile name
+ */
+ private void renameProfile(String oldProfileName, String newProfileName) {
+ // rename secure storage
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ if (root == null) {
+ LOG.error(DebugConstants.ERROR);
+ }
+ if (oldProfileName != null) {
+ ISecurePreferences node = root
+ .node(getSecureStorageProfilePath(oldProfileName));
+ String userName = getUserName(oldProfileName);
+ String password = getPassword(oldProfileName);
+ node.removeNode();
+ try {
+ node = root.node(getSecureStorageProfilePath(newProfileName));
+ node.put(Constants.SECURE_STORAGE_USERNAME_KEY, userName,
+ false);
+ } catch (StorageException e1) {
+ LOG.error(DebugConstants.ERROR, e1);
+ }
+ if (isSaveCredentialsActive(oldProfileName)) {
+ try {
+ node.put(Constants.SECURE_STORAGE_PASSWORD_KEY, password,
+ true);
+ } catch (StorageException e2) {
+ LOG.error(DebugConstants.ERROR, e2);
+ }
+ }
+ // rename preference store
+ if (isSaveCredentialsActive(oldProfileName)) {
+ setSaveCredentialStatus(oldProfileName, false);
+ setSaveCredentialStatus(newProfileName, true);
+ }
+ }
+ }
+
+ /**
+ * Returns the new profile name when profile name was renamed.
+ * Returns an empty String[] when a new profile was created
+ *
+ * @param event the fired preference changed event when profile
+ * was renamed
+ * @param oldName true for old profile name and false otherwise
+ * @return returns the old profile name if true and the new profile name otherwise
+ */
+ public String[] getProfileName(PreferenceChangeEvent event,
+ boolean oldName) {
+ String[] profileName = new String[0];
+ if (event.getOldValue() != null) {
+ List<DatabaseConnection> oldConnectionList =
+ DatabaseConnectionConverter.convert(
+ event.getOldValue().toString());
+ if (event.getNewValue() != null) {
+ List<DatabaseConnection> newConnectionList =
+ DatabaseConnectionConverter.convert(
+ event.getNewValue().toString());
+ profileName = new String[oldConnectionList.size()];
+ if (oldConnectionList.size() == newConnectionList.size()) {
+ for (int i = 0; i < oldConnectionList.size(); i++) {
+ String oldProfileName = oldConnectionList.
+ get(i).getName();
+ String newProfileName = newConnectionList.
+ get(i).getName();
+ if (!oldProfileName.equals(newProfileName)) {
+ if (oldName) {
+ profileName[i] = oldProfileName;
+ } else {
+ profileName[i] = newProfileName;
+ }
+ }
+ }
+ }
+ }
+ }
+ return profileName;
+ }
+ /**
+ * readout the username from secure storage
+ *
+ * @param profileName
+ * the profile name in secure storage
+ * @return returns username for given profile
+ */
+ public String getUserName(String profileName) {
+ String userName = StringConstants.EMPTY;
+
+ ISecurePreferences secureStorage = SecurePreferencesFactory
+ .getDefault();
+ try {
+ userName = secureStorage.node(
+ getSecureStorageProfilePath(profileName)).get(
+ Constants.SECURE_STORAGE_USERNAME_KEY,
+ StringConstants.EMPTY);
+
+ } catch (StorageException e) {
+ LOG.error(DebugConstants.ERROR, e);
+ }
+ return userName;
+ }
+
+ /**
+ * readout password from secure storage
+ *
+ * @param profileName
+ * the profile name in secure storage
+ * @return the password for given profile
+ */
+ public String getPassword(String profileName) {
+ // the password
+ String dbPwd = StringConstants.EMPTY;
+ // secure storage
+ ISecurePreferences secureStorage = SecurePreferencesFactory
+ .getDefault();
+ try {
+ dbPwd = secureStorage
+ .node(getSecureStorageProfilePath(profileName)).get(
+ Constants.SECURE_STORAGE_PASSWORD_KEY,
+ StringConstants.EMPTY);
+
+ } catch (StorageException e) {
+ LOG.error(DebugConstants.ERROR, e);
+ }
+ return dbPwd;
+ }
+
+ /**
+ *
+ * @param profileName the profile name in secure storage
+ */
+ public void removePassword(String profileName) {
+ ISecurePreferences node = getNodeForProfile(profileName);
+ if (node != null) {
+ node.remove(Constants.SECURE_STORAGE_PASSWORD_KEY);
+ }
+ }
+
+ /**
+ * Returns the secure storage profile path for the given profile name
+ *
+ * @param dbProfileName
+ * the profile name
+ * @return the secure storage profile path
+ */
+ public String getSecureStorageProfilePath(String dbProfileName) {
+ return new StringBuffer()
+ .append(Constants.ORG_ECLIPSE_JUBULA_SECURE_KEY)
+ .append(StringConstants.SLASH)
+ .append(dbProfileName)
+ .toString();
+ }
+
+ /**
+ * Returns the secure storage node for the given profile name
+ *
+ * @param profileName the profile name
+ * @return the secure storage profile node or null if application was
+ * unable to create secure preferences
+ */
+ private ISecurePreferences getNodeForProfile(String profileName) {
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ ISecurePreferences node = root;
+ if (root == null) {
+ LOG.error(DebugConstants.ERROR);
+ } else if (profileName != null) {
+ node = root
+ .node(getSecureStorageProfilePath(profileName));
+ }
+ return node;
+ }
+}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java
index cdcee795e..c1668876f 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java
@@ -241,6 +241,21 @@ public interface Constants {
/** Key for m_text value to be stored as a resource property */
public static final String DATADIR_PATH_KEY = "DATADIR_PATH_KEY"; //$NON-NLS-1$
+ /** Key for automatically database connection function */
+ public static final String AUTOMATIC_DATABASE_CONNECTION_KEY = "AUTOMATIC_DATABASE_CONNECTION_KEY"; //$NON-NLS-1$
+
+ /** Key for the secure storage plugin id */
+ public static final String SECURE_STORAGE_PLUGIN_ID = "org.eclipse.equinox.security.ui.storage"; //$NON-NLS-1$
+
+ /** Key for secure storage category */
+ public static final String ORG_ECLIPSE_JUBULA_SECURE_KEY = "org.eclipse.jubula.DatabaseProfile"; //$NON-NLS-1$
+
+ /** Key which associate the secure storage value for the database username */
+ public static final String SECURE_STORAGE_USERNAME_KEY = "Username"; //$NON-NLS-1$
+
+ /** Key which associate the secure storage value for the database password */
+ public static final String SECURE_STORAGE_PASSWORD_KEY = "Password"; //$NON-NLS-1$
+
/** Key for m_text value to be stored as a resource property */
public static final String PERSP_CHANGE_KEY = "PERSP_CHANGE_KEY"; //$NON-NLS-1$
/** Key for m_text value to be stored as a resource property */
@@ -249,6 +264,8 @@ public interface Constants {
public static final String USER_KEY = "USER_KEY"; //$NON-NLS-1$
/** Key for m_text value to be stored as a resource property */
public static final String SCHEMA_KEY = "SCHEMA_KEY"; //$NON-NLS-1$
+ /** Key for save profile function */
+ public static final String SAVE_PROFILE_NAMES_KEY = "SAVE_PROFILE_NAMES_KEY"; //$NON-NLS-1$
/** Key for m_text value to be stored as a resource property */
public static final String START_BROWSE_PATH_KEY = "START_BROWSE_PATH_KEY"; //$NON-NLS-1$
/** Key for m_text value to be stored as a resource property */
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java
index 501f0501c..9b8a2b5ee 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/dialogs/DBLoginDialog.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.RowLayoutFactory;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
@@ -28,6 +29,7 @@ import org.eclipse.jubula.client.core.persistence.Persistor;
import org.eclipse.jubula.client.core.preferences.database.DatabaseConnection;
import org.eclipse.jubula.client.core.preferences.database.DatabaseConnectionConverter;
import org.eclipse.jubula.client.ui.Plugin;
+import org.eclipse.jubula.client.ui.businessprocess.SecurePreferenceBP;
import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
@@ -39,6 +41,8 @@ import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+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;
@@ -46,9 +50,11 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
/**
@@ -79,8 +85,6 @@ public class DBLoginDialog extends TitleAreaDialog {
/** horizontal span = 2 */
private static final int HORIZONTAL_SPAN = 2;
- /** The message m_text */
- private String m_message = Messages.DBLoginDialogMessage;
/** the username m_text field */
private Text m_userText;
@@ -92,6 +96,14 @@ public class DBLoginDialog extends TitleAreaDialog {
private Label m_pwdLabel;
/** the connection combobox viewer */
private ComboViewer m_connectionComboViewer;
+ /** save database profile composite*/
+ private Composite m_saveProfileComp;
+ /** save database profile check box */
+ private Button m_profileSave;
+ /** automatic database connection check box */
+ private Button m_automConn;
+ /** save check box description */
+ private Link m_secureStorageLink;
/** the username */
private String m_user;
@@ -104,7 +116,8 @@ public class DBLoginDialog extends TitleAreaDialog {
private List<DatabaseConnection> m_availableConnections;
/** true, if selected db is embedded db */
- private boolean m_isEmbeddedOrNoSelection = false;
+ private boolean m_isEmbeddedOrNoSelection = false;
+
/**
* @param parentShell The parent Shell.
@@ -112,6 +125,8 @@ public class DBLoginDialog extends TitleAreaDialog {
public DBLoginDialog(Shell parentShell) {
super(parentShell);
}
+
+
/**
* {@inheritDoc}
*/
@@ -119,7 +134,7 @@ public class DBLoginDialog extends TitleAreaDialog {
m_availableConnections =
DatabaseConnectionConverter.computeAvailableConnections();
- setMessage(m_message);
+ setMessage(Messages.DBLoginDialogMessage);
setTitle(Messages.DBLoginDialogTitle);
setTitleImage(IconConstants.DB_LOGIN_DIALOG_IMAGE);
getShell().setText(Messages.DBLoginDialogShell);
@@ -148,9 +163,13 @@ public class DBLoginDialog extends TitleAreaDialog {
createSchemaCombobox(area);
createUserTextField(area);
createPasswordTextField(area);
+ createSavePasswordCheckbox(area);
+ createAutomaticConnectionCheckbox(area);
fillConnectionCombobox();
+ fillUserNameAndPasswordField();
+ m_automConn.setEnabled(m_profileSave.getSelection());
- setUserAndPwdVisible(!m_isEmbeddedOrNoSelection);
+ setUserAndPwdAndPwdCheckboxVisible(!m_isEmbeddedOrNoSelection);
LayoutUtil.createSeparator(parent);
@@ -165,7 +184,7 @@ public class DBLoginDialog extends TitleAreaDialog {
* {@inheritDoc}
*/
public int open() {
- setMessage(m_message);
+ setMessage(Messages.DBLoginDialogMessage);
return super.open();
}
@@ -297,21 +316,122 @@ public class DBLoginDialog extends TitleAreaDialog {
checkEmbeddedDbOrNoSchemaSelected(
(DatabaseConnection)sel.getFirstElement());
- m_connectionComboViewer.addSelectionChangedListener(
- new ISelectionChangedListener() {
-
+ m_connectionComboViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+
public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection csel =
- (IStructuredSelection)event.getSelection();
+ IStructuredSelection csel = (IStructuredSelection) event
+ .getSelection();
selectSchemaCbxAction();
- checkEmbeddedDbOrNoSchemaSelected(
- (DatabaseConnection)csel.getFirstElement());
- setUserAndPwdVisible(!m_isEmbeddedOrNoSelection);
+ checkEmbeddedDbOrNoSchemaSelected((DatabaseConnection)
+ csel.getFirstElement());
+ setUserAndPwdAndPwdCheckboxVisible(
+ !m_isEmbeddedOrNoSelection);
}
});
}
/**
+ * Creates the CheckBox to decide saving database password
+ * @param area The parent composite
+ */
+ private void createSavePasswordCheckbox(Composite area) {
+ new Label(area, SWT.NONE).setLayoutData(new GridData(SWT.FILL,
+ SWT.CENTER, false, false,
+ HORIZONTAL_SPAN + 1, 1));
+ new Label(area, SWT.NONE).setText(StringConstants.EMPTY);
+ m_saveProfileComp = new Composite(area, SWT.NONE);
+ m_saveProfileComp.setLayout(RowLayoutFactory.fillDefaults()
+ .spacing(0).create());
+ m_profileSave = new Button(m_saveProfileComp, SWT.CHECK);
+ m_profileSave.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ m_automConn.setEnabled(m_profileSave.getSelection());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ });
+ m_secureStorageLink = new Link(m_saveProfileComp, SWT.NONE);
+ m_secureStorageLink.setText(Messages.DBLoginDialogSaveDBPassword);
+ m_secureStorageLink.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ final String prefPageID =
+ Constants.SECURE_STORAGE_PLUGIN_ID;
+ PreferencesUtil.createPreferenceDialogOn(
+ Plugin.getDefault().getWorkbench().getDisplay()
+ .getActiveShell(), prefPageID,
+ new String[] { prefPageID }, null,
+ PreferencesUtil.OPTION_FILTER_LOCKED).open();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ /** do nothing */
+ }
+ });
+ }
+ /**
+ * Fills the username and the password field
+ */
+ private void fillUserNameAndPasswordField() {
+ SecurePreferenceBP spBP = SecurePreferenceBP.getInstance();
+ IStructuredSelection sel =
+ (IStructuredSelection) m_connectionComboViewer
+ .getSelection();
+ DatabaseConnection conn = (DatabaseConnection)sel.getFirstElement();
+ if (conn != null) {
+ String profileName = conn.getName();
+ m_profileSave.setSelection(spBP
+ .isSaveCredentialsActive(profileName));
+ if (m_profileSave.getSelection()) {
+
+ String userName = spBP.getUserName(profileName);
+ String databasePassword = spBP.getPassword(profileName);
+
+ m_userText.setText(userName);
+ m_pwdText.setText(databasePassword);
+ } else {
+ String userName = spBP.getUserName(profileName);
+
+ m_userText.setText(userName);
+ m_pwdText.setText(StringConstants.EMPTY);
+
+ }
+
+ }
+ }
+
+
+ /**
+ * saves the database profile with username and encrypted password
+ */
+ private void saveDatabaseProfile() {
+ SecurePreferenceBP spBP = SecurePreferenceBP.getInstance();
+ IStructuredSelection sel =
+ (IStructuredSelection) m_connectionComboViewer
+ .getSelection();
+ DatabaseConnection conn = (DatabaseConnection)sel.getFirstElement();
+ String profileName = conn.getName().toString();
+
+ String userName = m_userText.getText();
+
+ spBP.saveProfile(profileName, userName);
+ }
+
+ /**
+ * Creates the check box to decide automatic database connection or not
+ * @param area The parent composite
+ */
+ private void createAutomaticConnectionCheckbox(Composite area) {
+ new Label(area, SWT.NONE).setLayoutData(new GridData(SWT.FILL,
+ SWT.CENTER, false, false,
+ HORIZONTAL_SPAN + 1, 1));
+ new Label(area, SWT.NONE).setText(StringConstants.EMPTY);
+ m_automConn = new Button(area, SWT.CHECK);
+ m_automConn.setText(Messages.DBLoginDialogAutoDbConnection);
+ }
+
+ /**
* Checks whether the given connection is embedded or <code>null</code>
* and sets internal state based on the result.
*
@@ -340,9 +460,8 @@ public class DBLoginDialog extends TitleAreaDialog {
m_pwdText.setText(password);
enableOKButton(true);
} else {
- m_userText.setText(
- Plugin.getDefault().getPreferenceStore().getString(
- Constants.USER_KEY));
+ fillUserNameAndPasswordField();
+ m_automConn.setEnabled(m_profileSave.getSelection());
m_isEmbeddedOrNoSelection = false;
}
}
@@ -351,11 +470,14 @@ public class DBLoginDialog extends TitleAreaDialog {
* set visible state of username and pwd
* @param visible true if user and pw should be visible, false otherwise
*/
- private void setUserAndPwdVisible(boolean visible) {
+ private void setUserAndPwdAndPwdCheckboxVisible(boolean visible) {
m_userText.setVisible(visible);
m_userLabel.setVisible(visible);
m_pwdText.setVisible(visible);
m_pwdLabel.setVisible(visible);
+ m_profileSave.setVisible(visible);
+ m_secureStorageLink.setVisible(visible);
+ m_automConn.setVisible(visible);
}
/**
@@ -399,7 +521,7 @@ public class DBLoginDialog extends TitleAreaDialog {
isCorrect = false;
}
if (isCorrect) {
- setMessage(m_message);
+ setMessage(Messages.DBLoginDialogMessage);
} else {
setErrorMessage(Messages.DBLoginDialogWrongPwd);
}
@@ -446,6 +568,22 @@ public class DBLoginDialog extends TitleAreaDialog {
IPreferenceStore store = Plugin.getDefault().getPreferenceStore();
store.setValue(Constants.USER_KEY, m_user);
store.setValue(Constants.SCHEMA_KEY, m_dbConn.getName());
+ saveDatabaseProfile();
+ SecurePreferenceBP spBP = SecurePreferenceBP.getInstance();
+ if (m_profileSave.getSelection()) {
+ spBP.setSaveCredentialStatus(m_dbConn.getName(), true);
+ String databasePassword = m_pwdText.getText();
+ spBP.saveProfilePassword(m_dbConn.getName(), databasePassword);
+ if (m_automConn.getSelection()) {
+ store.setValue(Constants.AUTOMATIC_DATABASE_CONNECTION_KEY,
+ m_dbConn.getName());
+ } else {
+ store.setToDefault(Constants.AUTOMATIC_DATABASE_CONNECTION_KEY);
+ }
+ } else {
+ spBP.setSaveCredentialStatus(m_dbConn.getName(), false);
+ spBP.removePassword(m_dbConn.getName());
+ }
setReturnCode(OK);
close();
}
@@ -482,4 +620,10 @@ public class DBLoginDialog extends TitleAreaDialog {
public DatabaseConnection getDatabaseConnection() {
return m_dbConn;
}
+ /**
+ * @return Returns the schema combo viewer
+ */
+ public ComboViewer getConnectionComboViewer() {
+ return m_connectionComboViewer;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractSelectDatabaseHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractSelectDatabaseHandler.java
index 17a203061..09023ce0e 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractSelectDatabaseHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/project/AbstractSelectDatabaseHandler.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.persistence.CompNamePM;
import org.eclipse.jubula.client.core.persistence.DatabaseConnectionInfo;
@@ -28,6 +29,9 @@ import org.eclipse.jubula.client.core.persistence.locking.LockManager;
import org.eclipse.jubula.client.core.preferences.database.DatabaseConnection;
import org.eclipse.jubula.client.core.preferences.database.DatabaseConnectionConverter;
import org.eclipse.jubula.client.core.preferences.database.H2ConnectionInfo;
+import org.eclipse.jubula.client.ui.Plugin;
+import org.eclipse.jubula.client.ui.businessprocess.SecurePreferenceBP;
+import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.dialogs.DBLoginDialog;
import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
import org.eclipse.jubula.client.ui.i18n.Messages;
@@ -47,28 +51,33 @@ public abstract class AbstractSelectDatabaseHandler extends AbstractHandler {
/** the logger */
private static Logger log =
LoggerFactory.getLogger(AbstractSelectDatabaseHandler.class);
+ /** the "select database ..." command parameter */
+ private static final String DB_COMMAND_PARAMETER =
+ "org.eclipse.jubula.client.ui.selectDatabaseParameter";
/**
* {@inheritDoc}
*/
public Object executeImpl(ExecutionEvent event) {
+ String explicitSelectionValue = event.getParameter(
+ DB_COMMAND_PARAMETER);
+ boolean explicitSelection = Boolean.valueOf(explicitSelectionValue);
IStatus returnStatus = Status.CANCEL_STATUS;
boolean performLogin = false;
String userName = StringConstants.EMPTY;
String pwd = StringConstants.EMPTY;
DatabaseConnectionInfo dbInfo = null;
+
+ Credential credentials = new Credential(DatabaseConnectionConverter
+ .computeAvailableConnections());
- List<DatabaseConnection> availableConnections =
- DatabaseConnectionConverter
- .computeAvailableConnections();
- if (availableConnections.size() == 1
- && availableConnections.get(0).getConnectionInfo()
- instanceof H2ConnectionInfo) {
- dbInfo = availableConnections.get(0).getConnectionInfo();
- userName = dbInfo.getProperty(PersistenceUnitProperties.JDBC_USER);
- pwd = dbInfo.getProperty(PersistenceUnitProperties.JDBC_PASSWORD);
+ if (credentials.checkH2DatabaseConnection()) {
+ credentials.setH2DatabaseCredentials();
+ dbInfo = credentials.getDatabaseInfo();
+ userName = credentials.getDBusername();
+ pwd = credentials.getDBpassword();
performLogin = true;
- } else {
+ } else if (explicitSelection || !credentials.checkAutoDbConnection()) {
DBLoginDialog dialog = new DBLoginDialog(getActiveShell());
dialog.create();
DialogUtils.setWidgetNameForModalDialog(dialog);
@@ -79,8 +88,13 @@ public abstract class AbstractSelectDatabaseHandler extends AbstractHandler {
dbInfo = dialog.getDatabaseConnection().getConnectionInfo();
performLogin = true;
}
+ } else if (credentials.checkAutoDbConnection()) {
+ credentials.setAutoConnCredentials();
+ dbInfo = credentials.getDatabaseInfo();
+ userName = credentials.getDBusername();
+ pwd = credentials.getDBpassword();
+ performLogin = true;
}
-
if (performLogin) {
try {
returnStatus = connectToDatabase(userName, pwd, dbInfo);
@@ -88,12 +102,135 @@ public abstract class AbstractSelectDatabaseHandler extends AbstractHandler {
log.error(DebugConstants.ERROR, e);
}
}
-
+ while (performLogin && returnStatus == null) {
+ returnStatus = createLoginDialogAgain();
+ }
Persistor.setUser(null);
Persistor.setPw(null);
return returnStatus;
}
+
+ /**
+ *
+ * @author BREDEX GmbH
+ * @created 24.04.2012
+ *
+ */
+ private static class Credential {
+ /** the available database connections */
+ private List<DatabaseConnection> m_availableDbConnections;
+
+ /** database connection type */
+ private DatabaseConnectionInfo m_dbInfo;
+
+ /** the database user name */
+ private String m_userName;
+
+ /** the database password */
+ private String m_pwd;
+ /**
+ * the inner class constructor
+ *
+ * @param connections list of the available database
+ * connections
+ */
+ private Credential(List<DatabaseConnection> connections) {
+ m_availableDbConnections = connections;
+ }
+
+ /**
+ * Checks if only an H2 database connection exists
+ *
+ * @return true if only an H2 database connection
+ * exists and false otherwise
+ */
+ private boolean checkH2DatabaseConnection() {
+ boolean h2DB = false;
+ if (m_availableDbConnections.size() == 1
+ && m_availableDbConnections.get(0).getConnectionInfo()
+ instanceof H2ConnectionInfo) {
+ h2DB = true;
+ }
+ return h2DB;
+ }
+
+ /**
+ * sets the database type, user name and password for
+ * the H2 database connection
+ */
+ private void setH2DatabaseCredentials() {
+ m_dbInfo = m_availableDbConnections.get(0).getConnectionInfo();
+ m_userName = m_dbInfo.getProperty(
+ PersistenceUnitProperties.JDBC_USER);
+ m_pwd = m_dbInfo.getProperty(
+ PersistenceUnitProperties.JDBC_PASSWORD);
+
+ }
+
+ /**
+ * Checks if automatic database login is active
+ *
+ * @return true if active and false otherwise
+ */
+ private boolean checkAutoDbConnection() {
+ boolean autoConn = false;
+ IPreferenceStore store = Plugin.getDefault().getPreferenceStore();
+ if (!StringConstants.EMPTY.equals(store
+ .getString(Constants.AUTOMATIC_DATABASE_CONNECTION_KEY))) {
+ autoConn = true;
+ }
+ return autoConn;
+ }
+
+ /**
+ * Sets the database type, user name and password for the automatic
+ * database connection
+ */
+ private void setAutoConnCredentials() {
+ IPreferenceStore store = Plugin.getDefault().getPreferenceStore();
+ for (DatabaseConnection currentConnection
+ : m_availableDbConnections) {
+ String profileName = currentConnection.getName();
+ if (profileName.equals(store
+ .getString(Constants
+ .AUTOMATIC_DATABASE_CONNECTION_KEY))) {
+ m_dbInfo = currentConnection.getConnectionInfo();
+ SecurePreferenceBP spBP = SecurePreferenceBP.getInstance();
+ m_userName = spBP.getUserName(profileName);
+ m_pwd = spBP.getPassword(profileName);
+ }
+ }
+ }
+
+ /**
+ * Returns the database informations
+ *
+ * @return the database connection type
+ */
+ private DatabaseConnectionInfo getDatabaseInfo() {
+ return m_dbInfo;
+ }
+
+ /**
+ * Returns the database user name
+ *
+ * @return the database user name
+ */
+ private String getDBusername() {
+ return m_userName;
+ }
+
+ /**
+ * Returns the database password
+ *
+ * @return the database password
+ */
+ private String getDBpassword() {
+ return m_pwd;
+ }
+ }
+
/**
*
* @param username
@@ -134,6 +271,11 @@ public abstract class AbstractSelectDatabaseHandler extends AbstractHandler {
Messages.SelectDatabaseConnectSuccessful);
returnStatus.set(Status.OK_STATUS);
} else {
+ IPreferenceStore store = Plugin.getDefault().
+ getPreferenceStore();
+ store.setToDefault(Constants.
+ AUTOMATIC_DATABASE_CONNECTION_KEY);
+ returnStatus.set(null);
writeLineToConsole(
Messages.SelectDatabaseConnectFailed);
}
@@ -150,6 +292,42 @@ public abstract class AbstractSelectDatabaseHandler extends AbstractHandler {
}
/**
+ * Creates a new database login dialog when database
+ * connection failed
+ *
+ * @return returns the status OK when database connection
+ * was successful and null otherwise
+ */
+ private IStatus createLoginDialogAgain() {
+ IStatus returnStatus = Status.CANCEL_STATUS;
+ boolean performLogin = false;
+ String userName = StringConstants.EMPTY;
+ String pwd = StringConstants.EMPTY;
+ DatabaseConnectionInfo dbInfo = null;
+
+ DBLoginDialog dialog = new DBLoginDialog(getActiveShell());
+ dialog.create();
+ dialog.setErrorMessage(Messages.DatabaseConnectionErrorMessage);
+ dialog.getErrorMessage();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ dialog.open();
+ if (dialog.getReturnCode() == Window.OK) {
+ userName = dialog.getUser();
+ pwd = dialog.getPwd();
+ dbInfo = dialog.getDatabaseConnection().getConnectionInfo();
+ performLogin = true;
+ }
+ if (performLogin) {
+ try {
+ returnStatus = connectToDatabase(userName, pwd, dbInfo);
+ } catch (InterruptedException e) {
+ log.error(DebugConstants.ERROR, e);
+ }
+ }
+ return returnStatus;
+ }
+
+ /**
* Clears the ITE of all Project-related elements.
*/
protected abstract void clearClient();
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
index 0cadc8ce3..0dc333a1b 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
@@ -34,16 +34,19 @@ public class Messages extends NLS {
public static String CapGUIPropertySourceStepName;
public static String DatabaseConnectionDialogDefaultName;
public static String DatabaseConnectionDialogTitle;
+ public static String DatabaseConnectionErrorMessage;
public static String DatabaseConnectionPreferencePageAddButtonLabel;
public static String DatabaseConnectionPreferencePageEditButtonLabel;
public static String DatabaseConnectionPreferencePageRemoveButtonLabel;
public static String DatabaseConnectionPrefPageSelecObjIsOfIncorrectType;
+ public static String DBLoginDialogAutoDbConnection;
public static String DBLoginDialogConnectionLabel;
public static String DBLoginDialogEmptyUser;
public static String DBLoginDialogMessage;
public static String DBLoginDialogNoSchemaAvailable;
public static String DBLoginDialogNoSchemaSelected;
public static String DBLoginDialogPwdLabel;
+ public static String DBLoginDialogSaveDBPassword;
public static String DBLoginDialogShell;
public static String DBLoginDialogTitle;
public static String DBLoginDialogUserLabel;
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
index 2a32125f3..014a7a489 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
@@ -20,16 +20,19 @@ CapGUIPropertySourceParamValue=Parameter Value
CapGUIPropertySourceStepName=Test Step Name
DatabaseConnectionDialogDefaultName=New Configuration
DatabaseConnectionDialogTitle=Configure Database Connection
+DatabaseConnectionErrorMessage=Database Connection failed. Please enter a valid username and password and try again.
DatabaseConnectionPreferencePageAddButtonLabel=Add
DatabaseConnectionPreferencePageEditButtonLabel=Edit
DatabaseConnectionPreferencePageRemoveButtonLabel=Remove
DatabaseConnectionPrefPageSelecObjIsOfIncorrectType=Selected element has incorrect type\: {0}.
+DBLoginDialogAutoDbConnection=Perform auto login
DBLoginDialogConnectionLabel=&Connection\:
DBLoginDialogEmptyUser=Username is empty.
DBLoginDialogMessage=Enter a vaild username and password to connect to the Database.
DBLoginDialogNoSchemaAvailable=No (valid) database scheme available,\nplease contact your system administrator.
DBLoginDialogNoSchemaSelected=Select a Database Scheme to connect to the Database.
DBLoginDialogPwdLabel=&Password\:
+DBLoginDialogSaveDBPassword=<a>Secure store</a> database password
DBLoginDialogShell=Database connection
DBLoginDialogTitle=Database login
DBLoginDialogUserLabel=&Username\:
diff --git a/org.eclipse.jubula.feature/feature.xml b/org.eclipse.jubula.feature/feature.xml
index fab3bb049..fec5d24b5 100644
--- a/org.eclipse.jubula.feature/feature.xml
+++ b/org.eclipse.jubula.feature/feature.xml
@@ -52,6 +52,7 @@ BREDEX GmbH - initial API and implementation and/or initial documentation
<import plugin="org.eclipse.core.databinding.property" version="1.3.0" match="compatible"/>
<import plugin="org.eclipse.search" version="3.6.0" match="compatible"/>
<import feature="org.eclipse.persistence.jpa" version="2.2.0" match="compatible"/>
+ <import plugin="org.eclipse.equinox.security" version="1.0.0" match="compatible"/>
</requires>
<plugin
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java
index 4ecf0ec4f..f29e98306 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/messagehandling/MessageIDs.java
@@ -148,6 +148,8 @@ public class MessageIDs {
public static final Integer E_STORE_TESTRESULT = new Integer(2062);
/** if sql exception occured */
public static final Integer E_SQL_EXCEPTION = new Integer(2063);
+ /** if the database profile does not exits anymore */
+ public static final Integer E_DB_PROFILE_NOT_EXIST = new Integer(2064);
// -- GENERAL ERROR IDs ------------------------------------------------
/** if serilization exception */
@@ -820,6 +822,7 @@ public class MessageIDs {
messageMap.put(E_DELETE_TESTRESULT, e, "ErrorMessage.DELETE_TESTRESULT", null); //$NON-NLS-1$
messageMap.put(E_STORE_TESTRESULT, e, "ErrorMessage.STORE_TESTRESULT", null); //$NON-NLS-1$
messageMap.put(E_SQL_EXCEPTION, e, "ErrorMessage.SQL_ERROR", null); //$NON-NLS-1$
+ messageMap.put(E_DB_PROFILE_NOT_EXIST, e, "ErrorMessage.DB_PROFILE_ERROR", null); //$NON-NLS-1$
}
/**

Back to the top