Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/.classpath7
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/.options6
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/.project28
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/META-INF/MANIFEST.MF18
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/build.properties6
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/plugin.properties2
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/plugin.xml21
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/Activator.java147
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/R4EString.properties28
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceConstants.java164
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceInitializer.java119
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/R4ELdapPreferencePage.java848
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/QueryGlobalLdapDirectory.java287
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/UserData.java107
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/util/R4EString.java96
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/IQueryUser.java39
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/QueryUserFactory.java17
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/IUserInfo.java66
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/UserInformationFactory.java30
19 files changed, 2036 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/.classpath b/org.eclipse.mylyn.reviews.r4e.ldap/.classpath
new file mode 100644
index 00000000..2d1a4302
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/.options b/org.eclipse.mylyn.reviews.r4e.ldap/.options
new file mode 100644
index 00000000..c7d79400
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/.options
@@ -0,0 +1,6 @@
+org.eclipse.mylyn.reviews.r4e.ldap/error=true
+org.eclipse.mylyn.reviews.r4e.ldap/warning=true
+org.eclipse.mylyn.reviews.r4e.ldap/info=true
+org.eclipse.mylyn.reviews.r4e.ldap/debug=true
+org.eclipse.mylyn.reviews.r4e.ldap/consoleLog=true
+org.eclipse.mylyn.reviews.r4e.ldap/logfile=test.log \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/.project b/org.eclipse.mylyn.reviews.r4e.ldap/.project
new file mode 100644
index 00000000..8b88769f
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.mylyn.reviews.ldap</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/META-INF/MANIFEST.MF b/org.eclipse.mylyn.reviews.r4e.ldap/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..7b5e3702
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.mylyn.reviews.ldap;singleton:=true
+Bundle-Version: 0.2.0.qualifier
+Bundle-Activator: org.eclipse.mylyn.reviews.ldap.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.mylyn.reviews.frame.core;bundle-version="0.1.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Export-Package: org.eclipse.mylyn.reviews.ldap,
+ org.eclipse.mylyn.reviews.ldap.internal.preferences;x-internal:=true,
+ org.eclipse.mylyn.reviews.ldap.internal.queryUtility;x-internal:=true,
+ org.eclipse.mylyn.reviews.ldap.internal.util;x-internal:=true,
+ org.eclipse.mylyn.reviews.userSearch.query,
+ org.eclipse.mylyn.reviews.userSearch.userInfo
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/build.properties b/org.eclipse.mylyn.reviews.r4e.ldap/build.properties
new file mode 100644
index 00000000..db652eb6
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ plugin.properties
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/plugin.properties b/org.eclipse.mylyn.reviews.r4e.ldap/plugin.properties
new file mode 100644
index 00000000..c60c462f
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/plugin.properties
@@ -0,0 +1,2 @@
+pluginName = Mylyn Reviews R4E LDAP
+providerName = Eclipse Mylyn
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/plugin.xml b/org.eclipse.mylyn.reviews.r4e.ldap/plugin.xml
new file mode 100644
index 00000000..f46d47dd
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.mylyn.reviews.r4e.ui.preferences.R4EPreferencePage"
+ class="org.eclipse.mylyn.reviews.ldap.internal.preferences.R4ELdapPreferencePage"
+ id="org.eclipse.mylyn.reviews.r4e.ldap.page1"
+ name="R4E LDAP settings" >
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.mylyn.reviews.ldap.internal.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+
+
+</plugin>
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/Activator.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/Activator.java
new file mode 100644
index 00000000..219be084
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/Activator.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson
+ *
+ * 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
+ *
+ * Description:
+ *
+ * Contributors:
+ * Jacques Bouthillier - Initial Implementation of the R4E LDAP preferences
+ ********************************************************************************/
+package org.eclipse.mylyn.reviews.ldap;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylyn.reviews.frame.core.utils.Tracer;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+/**
+ * @author Jacques Bouthillier
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ // The plug-in ID
+ public static final String FPLUGIN_ID = "org.eclipse.mylyn.reviews.ldap"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Member variables
+ // ------------------------------------------------------------------------
+ // The shared instance
+ private static Activator FPlugin;
+
+ /**
+ * Field Tracer.
+ */
+ public static Tracer FTracer;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * The constructor
+ */
+ public Activator() {
+ // Empty constructor
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method start.
+ *
+ * @param aContext
+ * BundleContext
+ * @throws Exception
+ * @see org.osgi.framework.BundleActivator#start(BundleContext)
+ */
+ public void start(BundleContext aContext) throws Exception {
+ super.start(aContext);
+ FPlugin = this;
+ FTracer = new Tracer();
+ FTracer.traceDebug("plugin started: " + FPLUGIN_ID);
+ }
+
+ /**
+ * Method stop.
+ *
+ * @param aContext
+ * BundleContext
+ * @throws Exception
+ * @see org.osgi.framework.BundleActivator#stop(BundleContext)
+ */
+ public void stop(BundleContext aContext) throws Exception {
+ FPlugin = null;
+ super.stop(aContext);
+ FTracer.traceDebug("plugin stopped");
+ }
+
+ /**
+ * Gets the plug-in
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return FPlugin;
+ }
+
+ /**
+ * Method logError.
+ *
+ * @param aMsg
+ * String
+ * @param aE
+ * Exception
+ */
+ public void logError(String aMsg, Exception aE) {
+ getLog().log(new Status(IStatus.ERROR, FPLUGIN_ID, IStatus.OK, aMsg, aE));
+ }
+
+ /**
+ * Method logWarning.
+ *
+ * @param aMsg
+ * String
+ * @param aE
+ * Exception
+ */
+ public void logWarning(String aMsg, Exception aE) {
+ getLog().log(new Status(IStatus.WARNING, FPLUGIN_ID, IStatus.OK, aMsg, aE));
+ }
+
+ /**
+ * Method logInfo.
+ *
+ * @param aMsg
+ * String
+ * @param aE
+ * Exception
+ */
+ public void logInfo(String aMsg, Exception aE) {
+ getLog().log(new Status(IStatus.INFO, FPLUGIN_ID, IStatus.OK, aMsg, aE));
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given plug-in relative path.
+ *
+ * @param aPath
+ * the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String aPath) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(FPLUGIN_ID, aPath);
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/R4EString.properties b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/R4EString.properties
new file mode 100644
index 00000000..a073d9b7
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/R4EString.properties
@@ -0,0 +1,28 @@
+#
+# File describing the string use in the LDAP R4E plug-in
+#
+#
+#
+# Server Information
+fhostTooltip= Hostname.server
+fPortTooltip= 389
+fBaseTooltip = DC=abc, DC=se
+#
+# Security section
+#
+fUserNameTooltip = Enter the user Id or domain\\userId;
+#
+# Field Description
+#
+defaultDescription = Default value: {0}
+#
+# Message error
+#
+messageError1=R4E - Unable to perform operation: \n
+messageError2=R4E Password error UnsupportedEncodingException: \n
+messageError3=R4E Password error NoSuchAlgorithmException: \n
+messageError4=Server information not defined
+
+noHostOrPort=Host or Port not set
+noUserIdProvided=Cannot perform search when no user Identification is provided
+noUserNameProvided=Cannot perform search when no user Name is provided \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceConstants.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceConstants.java
new file mode 100644
index 00000000..75798120
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceConstants.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class holds R4E LDAP preferences constants
+ *
+ * Contributors:
+ * Jacques Bouthillier - Created for Mylyn Review R4E LDAP project
+ *
+ *******************************************************************************/
+
+
+
+package org.eclipse.mylyn.reviews.ldap.internal.preferences;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class PreferenceConstants {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * The preferences description text
+ */
+ public static final String FP_DESC = "R4E LDAP Preferences";
+
+ /**
+ * Server information
+ */
+
+ /**
+ * The group to keep the information about the LDAP server
+ */
+ public static final String FP_SERVER_GROUP = " Server Information";
+
+ // The value is : ldap://, ldaps://
+ public static final String FP_SERVER_TYPE_LABEL = "Type";
+ public static final String FP_SERVER_TYPE_ID = "serverType";
+ public static final String FP_SERVER_BASIC = "ldap://";
+ public static final String FP_SERVER_SECURE = "ldaps://";
+
+ public static final String[][] FP_SERVER_TYPE_VALUES = { { "ldap", FP_SERVER_BASIC },
+ { "ldaps", FP_SERVER_SECURE } };
+ /**
+ * The Host ID preference name ex: hostname.server
+ */
+ public static final String FP_HOST_ID = "hostIdPreference";
+ public static final String FP_HOST_LABEL = "Host: ";
+
+ /**
+ * The base ID ex: DC=cie, DC=se
+ */
+ public static final String FP_BASE_ID = "baseIdPreference";
+ public static final String FP_BASE_LABEL = "Base: DN=";
+
+ /**
+ * The port ID
+ */
+ public static final String FP_PORT_ID = "portIdPreference";
+ public static final String FP_PORT_LABEL = "Port:";
+
+
+ /**
+ * Security section
+ */
+
+ /**
+ * The group to keep the user name and password
+ */
+ public static final String FP_SECURITY_GROUP = "Security ";
+
+ public static final String FP_SECURITY_AUTHENTICATION_LABEL = "Authentication";
+
+ // The value is : none simple or strong
+ public static final String FP_SECURITY_AUTHENTICATION_ID = "authentication";
+ public static final String FP_NONE = "none";
+ public static final String FP_SIMPLE = "simple";
+ public static final String FP_STRONG = "strong";
+
+ public static final String[][] FP_AUTHENTICATION_RADIO_VALUES = { { "None", FP_NONE },
+ {"Simple",FP_SIMPLE}, {"Strong",FP_STRONG} };
+
+ /**
+ * The user name id to connect to the LDAP server
+ */
+ public static final String FP_SECURITY_USER_NAME_ID = "userNamePreference";
+ public static final String FP_SECURITY_USER_NAME_LABEL = "User Name: ";
+
+ /**
+ * The password ID to connect to the LDAP database
+ */
+ public static final String FP_SECURITY_PASSWORD_ID = "passwordIdPreference";
+ public static final String FP_SECURITY_PASSWORD_LABEL = "Password: ";
+
+ /**
+ * LDAP fields definition section
+ */
+
+ /**
+ * The group to keep the LDAP field definition
+ */
+ public static final String FP_FIELD_GROUP = "LDAP field definition ";
+ public static final String FP_FIELD_MANDATORY_GROUP = "Mandatory ";
+ public static final String FP_FIELD_OPTIONAL_GROUP = "Optional ";
+
+ public static final String FP_UID_ID = "cn";
+ public static final String FP_UID_LABEL = "User Id:";
+
+ public static final String FP_NAME_ID = "displayName";
+ public static final String FP_NAME_LABEL = "Name:";
+
+ public static final String FP_TELEPHONE_ID = "telephoneNumber";
+ public static final String FP_TELEPHONE_LABEL = "Telephone:";
+
+ public static final String FP_MOBILE_ID = "mobile";
+ public static final String FP_MOBILE_LABEL = "Mobile:";
+
+ public static final String FP_ECN_ID = "otherTelephone";
+ public static final String FP_ECN_LABEL = "ECN:";
+
+ public static final String FP_COMPANY_ID = "company";
+ public static final String FP_COMPANY_LABEL = "Company";
+
+ public static final String FP_DEPARTMENT_ID = "department";
+ public static final String FP_DEPARTMENT_LABEL = "Department";
+
+ public static final String FP_OFFICE_NAME_ID = "physicalDeliveryOfficeName";
+ public static final String FP_OFFICE_ROOM_Label = "Office";
+
+ public static final String FP_ROOM_NUMBER_ID = "extensionAttribute2";
+ public static final String FP_ROOM_NUMBER_LABEL = "Room";
+
+ public static final String FP_CITY_ID = "l";
+ public static final String FP_CITY_LABEL = "City";
+
+ public static final String FP_COUNTRY_ID = "co";
+ public static final String FP_COUNTRY_LABEL = "Country";
+
+ public static final String FP_EMAIL_ID = "mail";
+ public static final String FP_EMAIL_LABEL = "E-Mail";
+
+ // Fields that we could use as well
+ public static final String FP_DOMAIN_ID = "userPrincipalName";
+ public static final String FP_DOMAIN_LABEL = "Domain";
+
+ public static final String FP_TITLE_ID = "title";
+ public static final String FP_TITLE_LABEL = "Title";
+
+ public static final String FP_STREET_ADDRESS_ID = "streetAddress";
+ public static final String FP_STREET_ADDRESS_LABEL = "Address";
+
+ public static final String FP_POSTAL_CODE_ID = "postalCode";
+ public static final String FP_POSTAL_CODE_LABEL = "Postal Code";
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceInitializer.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceInitializer.java
new file mode 100644
index 00000000..475cdf3e
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/PreferenceInitializer.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class is used to initialize R4E LDAP preferences
+ *
+ * Contributors:
+ * Jacques Bouthillier - Created for Mylyn Review R4E LDAP project
+ *
+ *******************************************************************************/
+
+
+
+package org.eclipse.mylyn.reviews.ldap.internal.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.mylyn.reviews.ldap.Activator;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method initializeDefaultPreferences.
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+
+ // Default Server Information
+ store.setDefault(PreferenceConstants.FP_SERVER_TYPE_ID, PreferenceConstants.FP_SERVER_BASIC);
+ store.setDefault(PreferenceConstants.FP_HOST_ID, "");
+ store.setDefault(PreferenceConstants.FP_PORT_ID, "389");
+ store.setDefault(PreferenceConstants.FP_BASE_ID, "");
+
+
+ // Store the default authentication to "none";
+ store.setDefault(PreferenceConstants.FP_SECURITY_AUTHENTICATION_ID, PreferenceConstants.FP_NONE);
+ store.setDefault(PreferenceConstants.FP_SECURITY_USER_NAME_ID, "");
+ store.setDefault(PreferenceConstants.FP_SECURITY_PASSWORD_ID, "");
+
+ /**
+ * The group to keep the LDAP default field definition EX: KEY,VALUE
+ */
+ store.setDefault(PreferenceConstants.FP_UID_ID, PreferenceConstants.FP_UID_ID);
+ store.setDefault(PreferenceConstants.FP_NAME_ID, PreferenceConstants.FP_NAME_ID);
+ store.setDefault(PreferenceConstants.FP_TELEPHONE_ID, PreferenceConstants.FP_TELEPHONE_ID);
+ store.setDefault(PreferenceConstants.FP_MOBILE_ID, PreferenceConstants.FP_MOBILE_ID);
+ store.setDefault(PreferenceConstants.FP_ECN_ID, PreferenceConstants.FP_ECN_ID);
+ store.setDefault(PreferenceConstants.FP_COMPANY_ID, PreferenceConstants.FP_COMPANY_ID);
+ store.setDefault(PreferenceConstants.FP_DEPARTMENT_ID, PreferenceConstants.FP_DEPARTMENT_ID);
+ store.setDefault(PreferenceConstants.FP_OFFICE_NAME_ID, PreferenceConstants.FP_OFFICE_NAME_ID);
+ store.setDefault(PreferenceConstants.FP_ROOM_NUMBER_ID, PreferenceConstants.FP_ROOM_NUMBER_ID);
+ store.setDefault(PreferenceConstants.FP_CITY_ID, PreferenceConstants.FP_CITY_ID);
+ store.setDefault(PreferenceConstants.FP_COUNTRY_ID, PreferenceConstants.FP_COUNTRY_ID);
+ store.setDefault(PreferenceConstants.FP_EMAIL_ID, PreferenceConstants.FP_EMAIL_ID);
+ // Fields that we could use as well
+ store.setDefault(PreferenceConstants.FP_DOMAIN_ID, PreferenceConstants.FP_DOMAIN_ID);
+ store.setDefault(PreferenceConstants.FP_TITLE_ID, PreferenceConstants.FP_TITLE_ID);
+ store.setDefault(PreferenceConstants.FP_STREET_ADDRESS_ID, PreferenceConstants.FP_STREET_ADDRESS_ID);
+ store.setDefault(PreferenceConstants.FP_POSTAL_CODE_ID, PreferenceConstants.FP_POSTAL_CODE_ID);
+
+ }
+
+ /**
+ * Load the default value to the store value Use in Junit to reset the value
+ */
+ public void storeDefaultPreferences() {
+ final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ // Default Server Information
+ store.setValue(PreferenceConstants.FP_SERVER_TYPE_ID, PreferenceConstants.FP_SERVER_BASIC);
+ store.setValue(PreferenceConstants.FP_HOST_ID, "");
+ store.setValue(PreferenceConstants.FP_PORT_ID, "389");
+ store.setValue(PreferenceConstants.FP_BASE_ID, "");
+
+ // Store the default authentication to "none";
+ store.setValue(PreferenceConstants.FP_SECURITY_AUTHENTICATION_ID, PreferenceConstants.FP_NONE);
+ store.setValue(PreferenceConstants.FP_SECURITY_USER_NAME_ID, "");
+ store.setValue(PreferenceConstants.FP_SECURITY_PASSWORD_ID, "");
+
+ /**
+ * The group to keep the LDAP default field definition EX: KEY,VALUE
+ */
+ store.setValue(PreferenceConstants.FP_UID_ID, PreferenceConstants.FP_UID_ID);
+ store.setValue(PreferenceConstants.FP_NAME_ID, PreferenceConstants.FP_NAME_ID);
+ store.setValue(PreferenceConstants.FP_TELEPHONE_ID, PreferenceConstants.FP_TELEPHONE_ID);
+ store.setValue(PreferenceConstants.FP_MOBILE_ID, PreferenceConstants.FP_MOBILE_ID);
+ store.setValue(PreferenceConstants.FP_ECN_ID, PreferenceConstants.FP_ECN_ID);
+ store.setValue(PreferenceConstants.FP_COMPANY_ID, PreferenceConstants.FP_COMPANY_ID);
+ store.setValue(PreferenceConstants.FP_DEPARTMENT_ID, PreferenceConstants.FP_DEPARTMENT_ID);
+ store.setValue(PreferenceConstants.FP_OFFICE_NAME_ID, PreferenceConstants.FP_OFFICE_NAME_ID);
+ store.setValue(PreferenceConstants.FP_ROOM_NUMBER_ID, PreferenceConstants.FP_ROOM_NUMBER_ID);
+ store.setValue(PreferenceConstants.FP_CITY_ID, PreferenceConstants.FP_CITY_ID);
+ store.setValue(PreferenceConstants.FP_COUNTRY_ID, PreferenceConstants.FP_COUNTRY_ID);
+ store.setValue(PreferenceConstants.FP_EMAIL_ID, PreferenceConstants.FP_EMAIL_ID);
+ // Fields that we could use as well
+ store.setValue(PreferenceConstants.FP_DOMAIN_ID, PreferenceConstants.FP_DOMAIN_ID);
+ store.setValue(PreferenceConstants.FP_TITLE_ID, PreferenceConstants.FP_TITLE_ID);
+ store.setValue(PreferenceConstants.FP_STREET_ADDRESS_ID, PreferenceConstants.FP_STREET_ADDRESS_ID);
+ store.setValue(PreferenceConstants.FP_POSTAL_CODE_ID, PreferenceConstants.FP_POSTAL_CODE_ID);
+
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/R4ELdapPreferencePage.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/R4ELdapPreferencePage.java
new file mode 100644
index 00000000..dfdb40df
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/preferences/R4ELdapPreferencePage.java
@@ -0,0 +1,848 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class represents a preference page that is contributed to the Preferences dialog. By
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can be accessed directly via the preference store.
+ *
+ * Contributors:
+ * Jacques Bouthillier - Created for Mylyn Review R4E LDAP project
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.ldap.internal.preferences;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.NoSuchAlgorithmException;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.mylyn.reviews.ldap.Activator;
+import org.eclipse.mylyn.reviews.ldap.internal.util.R4EString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class R4ELdapPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ private static IPreferenceStore FStore = Activator.getDefault().getPreferenceStore();
+ private static final String FP_PORT_SEPARATOR = ":";
+
+ /**
+ * Field PREFS_CONTAINER_DATA_SPAN. (value is 1)
+ */
+ private static final int PREFS_CONTAINER_DATA_SPAN = 1;
+ /**
+ * Field PREFS_CONTAINER_DATA_NUM_COLUMNS. (value is 4)
+ */
+ private static final int PREFS_CONTAINER_DATA_NUM_COLUMNS = 4;
+
+ /**
+ * Field R4E_PREFS_CONTAINER_DATA_SPAN. (value is 2)
+ */
+ private static final int R4E_GROUP_PREFS_SERVER_DATA_SPAN = 2;
+
+ /**
+ * Field R4E_GROUP_PREFS_CONTAINER_DATA_SPAN. (value is 2)
+ */
+ private static final int R4E_GROUP_PREFS_SECURITY_DATA_SPAN = 2;
+ /**
+ * Field R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS. (value is 4)
+ */
+ private static final int R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS = 4;
+ /**
+ * Field R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS. (value is 2)
+ */
+ private static final int R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS = 2;
+
+
+ // ------------------------------------------------------------------------
+ // Member Variables
+ // ------------------------------------------------------------------------
+ // Server Information
+ private RadioGroupFieldEditor fLdapSelectBtn;
+ private StringFieldEditor fHostFieldEditor;
+ private StringFieldEditor fPortFieldEditor;
+ private StringFieldEditor fBaseFieldEditor;
+
+ // Security Information
+ private RadioGroupFieldEditor fAuthenficationBtn;
+ private StringFieldEditor fUserNamedEditor;
+ private StringFieldEditor fPasswordEditor;
+
+ // LDAP fields definition
+ private StringFieldEditor fUserIdEditor;
+ private StringFieldEditor fUserNameEditor;
+ private StringFieldEditor fEmailEditor;
+ private StringFieldEditor fTelephoneEditor;
+ private StringFieldEditor fMobileEditor;
+ private StringFieldEditor fEcnEditor;
+ private StringFieldEditor fCieEditor;
+ private StringFieldEditor fDeptEditor;
+ private StringFieldEditor fOfficeEditor;
+ private StringFieldEditor fRoomEditor;
+ private StringFieldEditor fCityEditor;
+ private StringFieldEditor fCountryEditor;
+ private StringFieldEditor fDomainEditor;
+ private StringFieldEditor fTitleEditor;
+ private StringFieldEditor fStreetAddrEditor;
+ private StringFieldEditor fPostalCodeEditor;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public R4ELdapPreferencePage() {
+ super(GRID);
+ setPreferenceStore(FStore);
+ setDescription(PreferenceConstants.FP_DESC);
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ @Override
+ protected void createFieldEditors() {
+ Activator.FTracer.traceInfo("Build R4E LDPA Preference page");
+
+ // The Main preferences composite
+ final Composite prefsContainer = new Composite(getFieldEditorParent(), SWT.NONE);
+ final GridData prefsContainerData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ prefsContainerData.horizontalSpan = PREFS_CONTAINER_DATA_SPAN;
+ prefsContainer.setLayoutData(prefsContainerData);
+ final GridLayout prefsLayout = new GridLayout(PREFS_CONTAINER_DATA_NUM_COLUMNS, false);
+ prefsContainer.setLayout(prefsLayout);
+
+ // Create the Server information area
+ createServerInformation(prefsContainer);
+
+ // Create the Security information area
+ createSecurityInformation(prefsContainer);
+
+ // Create the LDAP Fields definition information area
+ createFieldDefinitionInformation(prefsContainer);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /**
+ * Method performOk.
+ *
+ * @return boolean
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+
+ /**
+ * Need to store the radio selection before using the parent store (store.performOK())
+ */
+
+ // Server Information
+ fLdapSelectBtn.store();
+
+ // Security information
+ // Need to store the radio button selection
+ fAuthenficationBtn.store();
+
+ // LDAP Fields definition
+
+ // For field editors, all are saved with performOk() method
+ return super.performOk();
+ }
+
+ /**
+ * The field editor preference page implementation of a <code>PreferencePage</code> method loads all the field
+ * editors with their default values.
+ */
+ public void performDefaults() {
+ // Need to handle in extra the radio button
+ // Server Information
+ if (fLdapSelectBtn != null) {
+ fLdapSelectBtn.setPreferenceStore(getPreferenceStore());
+ fLdapSelectBtn.loadDefault();
+ }
+
+ // Security information
+ if (fAuthenficationBtn != null) {
+ fAuthenficationBtn.setPreferenceStore(getPreferenceStore());
+ fAuthenficationBtn.loadDefault();
+ }
+
+ super.performDefaults();
+ }
+
+ /**
+ * Create the Server information GUI
+ *
+ * @param Composite
+ * aPrefsContainer
+ */
+ private void createServerInformation(Composite aPrefsContainer) {
+ // Create a Group to hold LDAP user preferences
+ final Group r4ELdapHoostPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID);
+ final GridData r4eLdapHostPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4eLdapHostPrefsGroupData.horizontalSpan = R4E_GROUP_PREFS_SERVER_DATA_SPAN;
+ r4ELdapHoostPrefsGroup.setText(PreferenceConstants.FP_SERVER_GROUP);
+ r4ELdapHoostPrefsGroup.setLayoutData(r4eLdapHostPrefsGroupData);
+ r4ELdapHoostPrefsGroup.setLayout(new GridLayout(R4E_GROUP_PREFS_SERVER_DATA_SPAN, false));
+
+ // dummy spacer label
+ final Label r4ELdapPrefsSpacer = new Label(r4ELdapHoostPrefsGroup, SWT.FILL);
+ final GridData r4EUserPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EUserPrefsSpacerData.horizontalSpan = R4E_GROUP_PREFS_SERVER_DATA_SPAN;
+ r4ELdapPrefsSpacer.setLayoutData(r4EUserPrefsSpacerData);
+
+ // Create Radio buttons to define the type of Server
+ int numberRadio = 2;
+ fLdapSelectBtn = new RadioGroupFieldEditor(PreferenceConstants.FP_SERVER_TYPE_ID,
+ PreferenceConstants.FP_SERVER_TYPE_LABEL, numberRadio, PreferenceConstants.FP_SERVER_TYPE_VALUES,
+ r4ELdapHoostPrefsGroup, false);
+ fLdapSelectBtn.setPreferenceStore(getPreferenceStore());
+
+ fLdapSelectBtn.load();
+
+ // Test fields definitions
+ fHostFieldEditor = new StringFieldEditor(PreferenceConstants.FP_HOST_ID,
+ PreferenceConstants.FP_HOST_LABEL, StringFieldEditor.UNLIMITED, r4ELdapHoostPrefsGroup);
+ fHostFieldEditor.getTextControl(r4ELdapHoostPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", R4EString.getString("fhostTooltip")));
+ addField(fHostFieldEditor);
+
+
+ fPortFieldEditor = new StringFieldEditor(PreferenceConstants.FP_PORT_ID,
+ PreferenceConstants.FP_PORT_LABEL, StringFieldEditor.UNLIMITED, r4ELdapHoostPrefsGroup);
+ fPortFieldEditor.getTextControl(r4ELdapHoostPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", R4EString.getString("fPortTooltip")));
+ addField(fPortFieldEditor);
+
+ fBaseFieldEditor = new StringFieldEditor(PreferenceConstants.FP_BASE_ID,
+ PreferenceConstants.FP_BASE_LABEL, StringFieldEditor.UNLIMITED, r4ELdapHoostPrefsGroup);
+ fBaseFieldEditor.getTextControl(r4ELdapHoostPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", R4EString.getString("fBaseTooltip")));
+ addField(fBaseFieldEditor);
+
+ }
+
+ /**
+ * Create the Security information GUI
+ *
+ * @param Composite
+ * aPrefsContainer
+ */
+ private void createSecurityInformation(Composite aPrefsContainer) {
+ // Create a Group to hold R4E Security preferences
+ final Group r4ESecurityPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID);
+ final GridData r4EGroupPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EGroupPrefsGroupData.horizontalSpan = R4E_GROUP_PREFS_SECURITY_DATA_SPAN;
+ r4ESecurityPrefsGroup.setText(PreferenceConstants.FP_SECURITY_GROUP);
+ r4ESecurityPrefsGroup.setLayoutData(r4EGroupPrefsGroupData);
+ r4ESecurityPrefsGroup.setLayout(new GridLayout(R4E_GROUP_PREFS_SECURITY_DATA_SPAN, false));
+
+ // dummy spacer label
+ Label r4ESecurityGroupPrefsSpacer = new Label(r4ESecurityPrefsGroup, SWT.FILL);
+
+ // Create Radio buttons to define the type of AUTHENTICATION
+ int numberRadio = 3;
+ fAuthenficationBtn = new RadioGroupFieldEditor(PreferenceConstants.FP_SECURITY_AUTHENTICATION_ID,
+ PreferenceConstants.FP_SECURITY_AUTHENTICATION_LABEL, numberRadio,
+ PreferenceConstants.FP_AUTHENTICATION_RADIO_VALUES, r4ESecurityPrefsGroup, false);
+ fAuthenficationBtn.setPreferenceStore(getPreferenceStore());
+ fAuthenficationBtn.load();
+
+ // dummy spacer label
+ Label r4EFieldPrefsSpacer = new Label(r4ESecurityPrefsGroup, SWT.FILL);
+
+ final GridData r4EFieldPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EFieldPrefsSpacerData.horizontalSpan = R4E_GROUP_PREFS_SECURITY_DATA_SPAN;
+ r4EFieldPrefsSpacer.setLayoutData(r4EFieldPrefsSpacerData);
+
+ final GridData r4EGroupPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EGroupPrefsSpacerData.horizontalSpan = R4E_GROUP_PREFS_SECURITY_DATA_SPAN;
+ r4ESecurityGroupPrefsSpacer.setLayoutData(r4EGroupPrefsSpacerData);
+
+ // Test fields definitions
+ fUserNamedEditor = new StringFieldEditor(PreferenceConstants.FP_SECURITY_USER_NAME_ID,
+ PreferenceConstants.FP_SECURITY_USER_NAME_LABEL, StringFieldEditor.UNLIMITED, r4ESecurityPrefsGroup);
+ fUserNamedEditor.getTextControl(r4ESecurityPrefsGroup).setToolTipText(R4EString.getString("fUserNameTooltip"));
+ addField(fUserNamedEditor);
+
+ fPasswordEditor = new StringFieldEditor(PreferenceConstants.FP_SECURITY_PASSWORD_ID,
+ PreferenceConstants.FP_SECURITY_PASSWORD_LABEL, StringFieldEditor.UNLIMITED, r4ESecurityPrefsGroup);
+ addField(fPasswordEditor);
+ fPasswordEditor.getTextControl(r4ESecurityPrefsGroup).addModifyListener(new ModifyListener() {
+
+ // Echo * when typing a new password
+ public void modifyText(ModifyEvent e) {
+ fPasswordEditor.getTextControl(r4ESecurityPrefsGroup).setEchoChar('*');
+ }
+ });
+ }
+
+ /**
+ * Create the LDAP fields description information GUI
+ *
+ * @param Composite
+ * aPrefsContainer
+ */
+ private void createFieldDefinitionInformation(Composite aPrefsContainer) {
+ // Create a Group to hold R4E LDAP Field preferences
+ final Group r4EFieldPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID);
+ final GridData r4EFieldPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EFieldPrefsGroupData.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS;
+ r4EFieldPrefsGroup.setText(PreferenceConstants.FP_FIELD_GROUP);
+ r4EFieldPrefsGroup.setLayoutData(r4EFieldPrefsGroupData);
+ r4EFieldPrefsGroup.setLayout(new GridLayout(R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false));
+
+ // dummy spacer label
+ Label r4EFieldPrefsSpacer = new Label(r4EFieldPrefsGroup, SWT.FILL);
+ final GridData r4EFieldPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EFieldPrefsSpacerData.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS;
+ r4EFieldPrefsSpacer.setLayoutData(r4EFieldPrefsSpacerData);
+
+ // Create a Group to hold R4E LDAP Mandatory Field preferences
+ final Group r4EFieldMandatoryPrefsGroup = new Group(r4EFieldPrefsGroup, SWT.BORDER_SOLID);
+ final GridData r4EFieldMandatoryPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EFieldMandatoryPrefsGroupData.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS;
+ r4EFieldMandatoryPrefsGroup.setText(PreferenceConstants.FP_FIELD_MANDATORY_GROUP);
+ r4EFieldMandatoryPrefsGroup.setLayoutData(r4EFieldMandatoryPrefsGroupData);
+ r4EFieldMandatoryPrefsGroup.setLayout(new GridLayout(R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false));
+
+ fUserIdEditor = new StringFieldEditor(PreferenceConstants.FP_UID_ID,
+ PreferenceConstants.FP_UID_LABEL, StringFieldEditor.UNLIMITED, r4EFieldMandatoryPrefsGroup);
+ fUserIdEditor.setEmptyStringAllowed(false);
+ fUserIdEditor.getTextControl(r4EFieldMandatoryPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_UID_ID));
+ addField(fUserIdEditor);
+
+ fUserNameEditor = new StringFieldEditor(PreferenceConstants.FP_NAME_ID,
+ PreferenceConstants.FP_NAME_LABEL, StringFieldEditor.UNLIMITED, r4EFieldMandatoryPrefsGroup);
+ fUserNameEditor.setEmptyStringAllowed(false);
+ fUserNameEditor.getTextControl(r4EFieldMandatoryPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_NAME_ID));
+ addField(fUserNameEditor);
+
+ fEmailEditor = new StringFieldEditor(PreferenceConstants.FP_EMAIL_ID,
+ PreferenceConstants.FP_EMAIL_LABEL, StringFieldEditor.UNLIMITED, r4EFieldMandatoryPrefsGroup);
+ fEmailEditor.setEmptyStringAllowed(false);
+ fEmailEditor.getTextControl(r4EFieldMandatoryPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_EMAIL_ID));
+ addField(fEmailEditor);
+
+ // dummy spacer label
+ Label r4EFieldPrefsSpacer2 = new Label(r4EFieldPrefsGroup, SWT.FILL);
+ final GridData r4EFieldPrefsSpacer2Data = new GridData(GridData.FILL, GridData.FILL, true, false);
+ r4EFieldPrefsSpacer2Data.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS;
+ r4EFieldPrefsSpacer2.setLayoutData(r4EFieldPrefsSpacer2Data);
+
+ // Create a Group to hold R4E LDAP Optional Field preferences
+ final Group r4EFieldOptionalPrefsGroup = new Group(r4EFieldPrefsGroup, SWT.BORDER_SOLID);
+ final GridData r4EFieldOptionalPrefsGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
+
+ r4EFieldOptionalPrefsGroupData.horizontalSpan = R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS;
+ r4EFieldOptionalPrefsGroup.setText(PreferenceConstants.FP_FIELD_OPTIONAL_GROUP);
+ r4EFieldOptionalPrefsGroup.setLayoutData(r4EFieldOptionalPrefsGroupData);
+ r4EFieldOptionalPrefsGroup
+ .setLayout(new GridLayout(R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false));
+
+ fTelephoneEditor = new StringFieldEditor(PreferenceConstants.FP_TELEPHONE_ID,
+ PreferenceConstants.FP_TELEPHONE_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fTelephoneEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_TELEPHONE_ID));
+ addField(fTelephoneEditor);
+
+ fMobileEditor = new StringFieldEditor(PreferenceConstants.FP_MOBILE_ID, PreferenceConstants.FP_MOBILE_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fMobileEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_MOBILE_ID));
+ addField(fMobileEditor);
+
+ fEcnEditor = new StringFieldEditor(PreferenceConstants.FP_ECN_ID, PreferenceConstants.FP_ECN_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fEcnEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_ECN_ID));
+ addField(fEcnEditor);
+
+ fCieEditor = new StringFieldEditor(PreferenceConstants.FP_COMPANY_ID, PreferenceConstants.FP_COMPANY_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fCieEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_COMPANY_ID));
+ addField(fCieEditor);
+
+ fDeptEditor = new StringFieldEditor(PreferenceConstants.FP_DEPARTMENT_ID,
+ PreferenceConstants.FP_DEPARTMENT_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fDeptEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_DEPARTMENT_ID));
+ addField(fDeptEditor);
+
+ fDomainEditor = new StringFieldEditor(PreferenceConstants.FP_DOMAIN_ID, PreferenceConstants.FP_DOMAIN_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fDomainEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_DOMAIN_ID));
+ addField(fDomainEditor);
+
+ fTitleEditor = new StringFieldEditor(PreferenceConstants.FP_TITLE_ID, PreferenceConstants.FP_TITLE_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup);
+ fTitleEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_TITLE_ID));
+ addField(fTitleEditor);
+
+ // Create a second optional group to maintain the remaining LDAP fields definition
+ final Group r4EFieldOptionalPrefsGroup2 = new Group(r4EFieldPrefsGroup, SWT.BORDER_SOLID);
+ final GridData r4EFieldOptionalPrefsGroupRightData2 = new GridData(GridData.FILL, GridData.FILL, true,
+ false);
+
+ r4EFieldOptionalPrefsGroupRightData2.horizontalSpan = R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS;
+ r4EFieldOptionalPrefsGroup2.setText(PreferenceConstants.FP_FIELD_OPTIONAL_GROUP);
+ r4EFieldOptionalPrefsGroup2.setLayoutData(r4EFieldOptionalPrefsGroupRightData2);
+ r4EFieldOptionalPrefsGroup2.setLayout(new GridLayout(R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS,
+ false));
+
+ // Fields editor
+ fOfficeEditor = new StringFieldEditor(PreferenceConstants.FP_OFFICE_NAME_ID,
+ PreferenceConstants.FP_OFFICE_ROOM_Label, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2);
+ fOfficeEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_OFFICE_NAME_ID));
+ addField(fOfficeEditor);
+
+ fRoomEditor = new StringFieldEditor(PreferenceConstants.FP_ROOM_NUMBER_ID,
+ PreferenceConstants.FP_ROOM_NUMBER_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2);
+ fRoomEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_ROOM_NUMBER_ID));
+ addField(fRoomEditor);
+
+ fStreetAddrEditor = new StringFieldEditor(PreferenceConstants.FP_STREET_ADDRESS_ID,
+ PreferenceConstants.FP_STREET_ADDRESS_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2);
+ fStreetAddrEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_STREET_ADDRESS_ID));
+ addField(fStreetAddrEditor);
+
+ fCityEditor = new StringFieldEditor(PreferenceConstants.FP_CITY_ID, PreferenceConstants.FP_CITY_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2);
+ fCityEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_CITY_ID));
+ addField(fCityEditor);
+
+ fCountryEditor = new StringFieldEditor(PreferenceConstants.FP_COUNTRY_ID, PreferenceConstants.FP_COUNTRY_LABEL,
+ StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2);
+ fCountryEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_COUNTRY_ID));
+ addField(fCountryEditor);
+
+ fPostalCodeEditor = new StringFieldEditor(PreferenceConstants.FP_POSTAL_CODE_ID,
+ PreferenceConstants.FP_POSTAL_CODE_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2);
+ fPostalCodeEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText(
+ R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_POSTAL_CODE_ID));
+ addField(fPostalCodeEditor);
+
+ }
+
+ /********************************* */
+ /* */
+ /* Read the preference information */
+ /* */
+ /********************************* */
+
+ /**
+ * Get the Host Id ex: hostname.server
+ *
+ * @return String
+ */
+ public String getHostId() {
+ return FStore.getString(PreferenceConstants.FP_HOST_ID);
+ }
+
+ /**
+ * Get the Port Id
+ *
+ * @return String
+ */
+ public String getPortId() {
+ return FStore.getString(PreferenceConstants.FP_PORT_ID);
+ }
+
+ /**
+ * Get the Base DN Id ex: "DC=cie,DC=se"
+ *
+ * @return String
+ */
+ public String getBaseId() {
+ return FStore.getString(PreferenceConstants.FP_BASE_ID);
+ }
+
+ /**
+ * Get the server type uri ex: ldap://, ldaps://
+ *
+ * @return String
+ */
+ public String getServerType() {
+ return FStore.getString(PreferenceConstants.FP_SERVER_TYPE_ID);
+ }
+
+ /**
+ * Build the server information from the host and the port Create a string representing the URI. ex:
+ * ldap://hostname.server:port
+ *
+ * @return String
+ * @throws IOException
+ */
+ public String getServerInfo() throws IOException {
+ String host = getHostId();
+ String port = getPortId();
+ StringBuilder sb = new StringBuilder();
+ sb.append(getServerType());
+ sb.append(host);
+ sb.append(FP_PORT_SEPARATOR);
+ sb.append(port);
+ if (host.equals("") || port.equals("")) {
+ Activator.FTracer.traceWarning("Warning " + "Host or port is empty");
+
+ throw new IOException(R4EString.getString("messageError1") + R4EString.getString("noHostOrPort"));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Get the Security section fields. It could be "none", "simple" or "strong"
+ *
+ * @return String
+ */
+
+ public String getAuthentication () {
+ return FStore.getString(PreferenceConstants.FP_SECURITY_AUTHENTICATION_ID);
+ }
+
+ /**
+ * Get the user name to log to the LDAP database if needed depending of the Authentication selected. It can be
+ * domain\\userId
+ *
+ * @return String
+ */
+ public String getUserName() {
+ return FStore.getString(PreferenceConstants.FP_SECURITY_USER_NAME_ID);
+ }
+
+ /**
+ * Get the user password to log to the LDAP database if needed depending of the Authentication selected.
+ *
+ * @return String
+ */
+ public String getPassword() {
+ String encodedPwd = "";
+ try {
+ encodedPwd = encodePassword();
+ } catch (UnsupportedEncodingException aE) {
+ Activator.getDefault().logError(R4EString.getString("messageError2"), aE);
+
+ } catch (NoSuchAlgorithmException aE) {
+ Activator.getDefault().logError(R4EString.getString("messageError3"), aE);
+ }
+ return encodedPwd;
+ }
+
+ /**
+ * Get the LDAP fields description
+ */
+
+ /**
+ * Get the user id field definition defined in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldUserId() {
+ return FStore.getString(PreferenceConstants.FP_UID_ID);
+ }
+
+ /**
+ * Get the user name field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldUserName() {
+ return FStore.getString(PreferenceConstants.FP_NAME_ID);
+ }
+
+ /**
+ * Get the e-mail id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldEmail() {
+ return FStore.getString(PreferenceConstants.FP_EMAIL_ID);
+ }
+
+ /**
+ * Get the telephone id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldTelephone() {
+ return FStore.getString(PreferenceConstants.FP_TELEPHONE_ID);
+ }
+
+ /**
+ * Get the mobile id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldMobile() {
+ return FStore.getString(PreferenceConstants.FP_MOBILE_ID);
+ }
+
+ /**
+ * Get the ECN id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldECN() {
+ return FStore.getString(PreferenceConstants.FP_ECN_ID);
+ }
+
+ /**
+ * Get the company id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldCompany() {
+ return FStore.getString(PreferenceConstants.FP_COMPANY_ID);
+ }
+
+ /**
+ * Get the department id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldDepartment() {
+ return FStore.getString(PreferenceConstants.FP_DEPARTMENT_ID);
+ }
+
+ /**
+ * Get the office name id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldOfficeName() {
+ return FStore.getString(PreferenceConstants.FP_OFFICE_NAME_ID);
+ }
+
+ /**
+ * Get the room id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldRoom() {
+ return FStore.getString(PreferenceConstants.FP_ROOM_NUMBER_ID);
+ }
+
+ /**
+ * Get the city name id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldCity() {
+ return FStore.getString(PreferenceConstants.FP_CITY_ID);
+ }
+
+ /**
+ * Get the country name id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldCountry() {
+ return FStore.getString(PreferenceConstants.FP_COUNTRY_ID);
+ }
+
+ /**
+ * Get the domain name id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldDomain() {
+ return FStore.getString(PreferenceConstants.FP_DOMAIN_ID);
+ }
+
+ /**
+ * Get the title name id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldTitle() {
+ return FStore.getString(PreferenceConstants.FP_TITLE_ID);
+ }
+
+ /**
+ * Get the street address id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldStreetAddress() {
+ return FStore.getString(PreferenceConstants.FP_STREET_ADDRESS_ID);
+ }
+
+ /**
+ * Get the postal code id field definition in the current LDAP.
+ *
+ * @return String
+ */
+ public String getFieldPostalCode() {
+ return FStore.getString(PreferenceConstants.FP_POSTAL_CODE_ID);
+ }
+
+ /**
+ * Encode the user password uses to connect to LDAP.
+ *
+ * @return String
+ * @throws NoSuchAlgorithmException
+ * @throws UnsupportedEncodingException
+ */
+ private String encodePassword() throws NoSuchAlgorithmException, UnsupportedEncodingException {
+ // String algorith = "SHA";
+ // String algorith = "MD5";
+ // String algorith = "SHA-1";
+
+ String storePwd = FStore.getString(PreferenceConstants.FP_SECURITY_PASSWORD_ID);
+
+ // If we return the password with not SHA encoding
+ // Activator.FTracer.traceInfo("Info: " + storePwd + "\n\t UTF-8: " + storePwd.getBytes("UTF-8"));
+
+ // Not encrypted
+ return storePwd;
+
+ // ENCRYPTED password
+ // MessageDigest mesDigest = MessageDigest.getInstance(algorith);
+ // mesDigest.update(FStore.getString(PreferenceConstants.FP_SECURITY_PASSWORD_ID).getBytes("UTF-8"));
+ // byte[] bytes = mesDigest.digest();
+ // Activator.FTracer.traceInfo("Info: SHA bytes length: " + bytes.length);
+ //
+ // // Debug purpose
+ // // for (int i = 0; i < bytes.length; i++) {
+ // // System.out.print(bytes[i] + " ");
+ // // }
+ // // System.out.println("");
+ //
+ // // Convert from UTF-8 to String
+ // String shaStr = Convert.fromUTF8(bytes);
+ // // Activator.FTracer.traceInfo("Info SHA init str: " + shaStr);
+ //
+ // // Print the value in Base64 encoding
+ // Base64 base64 = new Base64();
+ // byte[] encodeByte = base64.encode(bytes);
+ //
+ // // Debug purpose
+ // // System.out.println("Uncoded bytes:");
+ // // for (int i = 0; i < encodeByte.length; i++) {
+ // // System.out.print(encodeByte[i] + " ");
+ // // }
+ // // System.out.println("");
+ //
+ // // Convert from UTF-8 to String
+ // String generatedStr = Convert.fromUTF8(encodeByte);
+ // Activator.FTracer.traceInfo("Info encode str: " + generatedStr);
+ // String encodeString = '{' + algorith + '}' + generatedStr;
+ // Activator.FTracer.traceInfo("Info: pwd: " + encodeString);
+ //
+ // return encodeString;
+ }
+
+ /************ */
+ /* */
+ /* Set method */
+ /* */
+ /************ */
+
+ /**
+ * Set the Host Id ex: hostname.server
+ *
+ */
+ public void setHostId(String aHost) {
+ FStore.setValue(PreferenceConstants.FP_HOST_ID, aHost);
+ }
+
+ /**
+ * Set the Port Id
+ *
+ */
+ public void setPortId(String aPort) {
+ FStore.setValue(PreferenceConstants.FP_PORT_ID, aPort);
+ }
+
+ /**
+ * Set the Base DN Id ex: "DC=cie,DC=se"
+ *
+ */
+ public void setBaseId(String aBase) {
+ FStore.setValue(PreferenceConstants.FP_BASE_ID, aBase);
+ }
+
+ /**
+ * Set the server type uri ex: ldap://, ldaps://
+ *
+ */
+ public void setServerType(String aServerType) {
+ FStore.setValue(PreferenceConstants.FP_SERVER_TYPE_ID, aServerType);
+ }
+
+ /**
+ * Set the Security section fields. It could be "none", "simple" or "strong"
+ *
+ */
+
+ public void setAuthentication(String aAuthentication) {
+ FStore.setValue(PreferenceConstants.FP_SECURITY_AUTHENTICATION_ID, aAuthentication);
+ }
+
+ /**
+ * Set the user name to log to the LDAP database if needed depending of the Authentication selected. It can be
+ * domain\\userId
+ *
+ */
+ public void setUserName(String aUserName) {
+ FStore.setValue(PreferenceConstants.FP_SECURITY_USER_NAME_ID, aUserName);
+ }
+
+ /**
+ * Set the user password to log to the LDAP database if needed depending of the Authentication selected.
+ *
+ */
+ public void setPassword(String aPasswd) {
+ FStore.setValue(PreferenceConstants.FP_SECURITY_PASSWORD_ID, aPasswd);
+ }
+
+ /**
+ * @param args
+ */
+ public void main(String[] args) {
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/QueryGlobalLdapDirectory.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/QueryGlobalLdapDirectory.java
new file mode 100644
index 00000000..41bc7682
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/QueryGlobalLdapDirectory.java
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class accesses the LDAP (Lightweight Directory Access Protocol)
+ * database according to the the database field provided on the
+ * preference store.
+ *
+ * Contributors:
+ * Jacques Bouthillier - Query the LDAP database based on the field description.
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.ldap.internal.queryUtility;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.eclipse.mylyn.reviews.ldap.Activator;
+import org.eclipse.mylyn.reviews.ldap.internal.preferences.R4ELdapPreferencePage;
+import org.eclipse.mylyn.reviews.ldap.internal.util.R4EString;
+import org.eclipse.mylyn.reviews.userSearch.query.IQueryUser;
+import org.eclipse.mylyn.reviews.userSearch.userInfo.IUserInfo;
+import org.eclipse.mylyn.reviews.userSearch.userInfo.UserInformationFactory;
+
+/**
+ * Allow to search the LDAP employee database
+ */
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class QueryGlobalLdapDirectory implements IQueryUser {
+
+ private R4ELdapPreferencePage fLdap = new R4ELdapPreferencePage();
+
+ /**
+ * Search in the Employee Global Directory with all search parameters having a string different than the empty
+ * string (""). The search is done with a logical AND between parameters and all parameters are searched with the
+ * regular expression *<parameter>*. Search parameters cannot be null and should have an empty String ("") if the
+ * search should skip them.
+ *
+ * @param a_inUserID
+ * @param a_inName
+ * @param a_inCompany
+ * @param a_inOffice
+ * @param a_inDepartement
+ * @param a_inCountry
+ * @param a_inCity
+ *
+ * @return ArrayList<IUserInfo> The max seems to be 1200 users, may be empty.
+ * @throws IOException
+ */
+
+ public ArrayList<IUserInfo> search(String a_inUserID, String a_inName, String a_inCompany, String a_inOffice,
+ String a_inDepartement, String a_inCountry, String a_inCity) throws NamingException, IOException {
+ ArrayList<IUserInfo> userList = new ArrayList<IUserInfo>(
+ 50);
+ Hashtable<String, String> env = new Hashtable<String, String>();
+
+ env = (Hashtable<String, String>) getConnectionProperties();
+ DirContext ctx = new InitialDirContext(env);
+
+ // Grammar filter can be found at http://www.ietf.org/rfc/rfc2254.txt
+ StringBuilder filter = new StringBuilder(150);
+ filter.append('(');
+ if (a_inUserID != null && !a_inUserID.equals("")) {
+ filter.append("&(" + fLdap.getFieldUserId() + "=" + a_inUserID + "*)");
+ }
+ if (a_inName != null && !a_inName.equals("")) {
+ filter.append("&(" + fLdap.getFieldUserName() + "=" + a_inName + "*)");
+ }
+ if (a_inCompany != null && !a_inCompany.equals("")) {
+ filter.append("&(" + fLdap.getFieldCompany() + "=*" + a_inCompany + "*)");
+ }
+ if (a_inOffice != null && !a_inOffice.equals("")) {
+ filter.append("&(" + fLdap.getFieldOfficeName() + "=*" + a_inOffice
+ + "*)");
+ }
+ if (a_inDepartement != null && !a_inDepartement.equals("")) {
+ filter.append("&(" + fLdap.getFieldDepartment() + "=" + a_inDepartement
+ + "*)");
+ }
+ if (a_inCountry != null && !a_inCountry.equals("")) {
+ filter.append("&(" + fLdap.getFieldCountry() + "=*" + a_inCountry + "*)");
+ }
+ if (a_inCity != null && !a_inCity.equals("")) {
+ filter.append("&(" + fLdap.getFieldCity() + "=" + a_inCity + "*)");
+ }
+
+ filter.append(')');
+
+ Activator.FTracer.traceInfo("Filter search:" + filter);
+ // Order of data field received from querying the LDAP database
+ String[] returningAttributes = {
+ fLdap.getFieldUserId(), // uid
+ fLdap.getFieldUserName(),
+ fLdap.getFieldCompany(), // "ou",
+ fLdap.getFieldCity(), // "L"
+ fLdap.getFieldDepartment(), // "departmentNumber",
+ fLdap.getFieldCountry(),
+ fLdap.getFieldOfficeName(), // "physicalDeliveryOfficeName",
+ fLdap.getFieldTelephone(), // "telephoneNumber",
+ fLdap.getFieldECN(),
+ fLdap.getFieldMobile(), // "mobile"
+ fLdap.getFieldRoom(), // "roomNumber"
+ fLdap.getFieldOfficeName(), fLdap.getFieldStreetAddress(), fLdap.getFieldTitle(),
+ fLdap.getFieldEmail(), // "mail"
+ fLdap.getFieldDomain(), fLdap.getFieldTitle() };
+ SearchControls mySearchControl = new SearchControls(2, 0, 30000,
+ returningAttributes, false, false); //
+
+ // String dn = "DC=[cie],DC=se";
+ String dn = fLdap.getBaseId();
+ NamingEnumeration<SearchResult> result = ctx.search(dn,
+ filter.toString(), mySearchControl);
+
+ Attributes userAttribs;
+
+ while (result.hasMore()) {
+ userAttribs = (result.next()).getAttributes();
+
+ // Test if we have an e-mail. If not, we do not
+ // add it since we will not be able to send an e-mail to it
+ if (userAttribs.get(fLdap.getFieldEmail()) != null) {
+ IUserInfo userData = UserInformationFactory.getInstance();
+ userList.add(userData.setData(
+ userAttribs.get(fLdap.getFieldUserId()), // "cn"
+ userAttribs.get(fLdap.getFieldUserName()),
+ userAttribs.get(fLdap.getFieldCompany()),// company "ou"
+ userAttribs.get(fLdap.getFieldOfficeName()), // "L"
+ userAttribs.get(fLdap.getFieldDepartment()), // "departmentNumber"
+ userAttribs.get(fLdap.getFieldCountry()),
+ userAttribs.get(fLdap.getFieldCity()), // "physicalDeliveryOfficeName"
+ userAttribs.get(fLdap.getFieldECN()),
+ userAttribs.get(fLdap.getFieldTelephone()), userAttribs.get(fLdap.getFieldMobile()),
+ userAttribs.get(fLdap.getFieldRoom()), userAttribs.get(fLdap.getFieldEmail()), userAttribs
+ .get(fLdap.getFieldDomain()), userAttribs.get(fLdap.getFieldTitle())));
+
+ } else {
+ // Activator.FTracer
+ // .traceWarning("Warning: " + "No E-mail for " + userAttribs.get(fLdap.getFieldUserId()));
+ }
+ }
+
+ // Close the DirContext
+ ctx.close();
+ env.clear();
+ return userList;
+ }
+
+ /**
+ * Perform a query from the database using the user Id only
+ *
+ * @param aUerId
+ * @return ArrayList<IUserInfo>
+ * @throws NamingException
+ * @throws IOException
+ */
+ public ArrayList<IUserInfo> searchByUserId(String aUserId) throws NamingException, IOException {
+ ArrayList<IUserInfo> list = null;
+ if (aUserId == null || aUserId.equals("")) {
+ throw new IOException(R4EString.getString("messageError1") + R4EString.getString("noUserIdProvided"));
+ }
+ list = search(aUserId, // User Id
+ "", // User Name
+ "", // Company name
+ "", // Office
+ "", // Department
+ "", // Country
+ "");
+ return list;
+
+ }
+
+ /**
+ * Perform a query from the database using the user Name only
+ *
+ * @param aUerId
+ * @return ArrayList<IUserInfo>
+ * @throws NamingException
+ * @throws IOException
+ */
+ public ArrayList<IUserInfo> searchByUserName(String aUserName) throws NamingException, IOException {
+ ArrayList<IUserInfo> list = null;
+ if (aUserName == null || aUserName.equals("")) {
+ throw new IOException(R4EString.getString("messageError1") + R4EString.getString("noUserNameProvided"));
+ }
+
+ list = search("", // User Id
+ aUserName, // User Name
+ "", // Company name
+ "", // Office
+ "", // Department
+ "", // Country
+ "");
+ return list;
+
+ }
+
+ /**
+ * Get the information about the server information
+ *
+ * @return String
+ * @throws IOException
+ */
+ private String getProviderURL() throws IOException {
+ // "ldap://localhost:389"
+ final StringBuffer sb = new StringBuffer(150);
+
+ // Server information
+ String serverInfo = fLdap.getServerInfo();
+ if (serverInfo != null) {
+ sb.append(serverInfo); // New LDAP
+ } else {
+ // XX May log an error here since the LDAP server is not defined in the property
+ Activator.FTracer.traceWarning("Warning " + R4EString.getString("messageError4"));
+ }
+ // sb.append("ldap://127.0.0.1:3268"); // To test internally
+
+ return sb.toString();
+ }
+
+ /**
+ * Set the environment properties
+ *
+ * @return Map environment
+ * @throws IOException
+ */
+ private Map<String, String> getConnectionProperties() throws IOException {
+ final Map<String, String> env = new Hashtable<String, String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY,
+ "com.sun.jndi.ldap.LdapCtxFactory"); //$NON-NLS-1$
+ env.put(Context.PROVIDER_URL, getProviderURL());
+
+ // sowieso default
+ // env.put(Context.SECURITY_AUTHENTICATION, "none");
+
+ // Authentication: "none", "simple", "strong".
+ env.put(Context.SECURITY_AUTHENTICATION, fLdap.getAuthentication());
+ Activator.FTracer.traceInfo("Info: " + "User: " + fLdap.getUserName()
+ + "\t Authentication: " + fLdap.getAuthentication());
+ env.put(Context.SECURITY_PRINCIPAL, fLdap.getUserName());
+ env.put(Context.SECURITY_CREDENTIALS, fLdap.getPassword());
+
+ return env;
+ }
+
+ public void main(String argv[]) {
+ ArrayList<IUserInfo> userList = null;
+
+ try {
+ QueryGlobalLdapDirectory ericGlobalDir = new QueryGlobalLdapDirectory();
+ try {
+ userList = ericGlobalDir.search("", "", "", "", "", "", "");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (int i = 0; i < userList.size(); i++) {
+ System.out.println(userList.get(i) + ", "
+ + userList.get(i).getNTDomain());
+ }
+
+ } catch (NamingException exc) {
+ System.out.println("Error when searching in the LDAP Global Directory");
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/UserData.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/UserData.java
new file mode 100644
index 00000000..4cfd1f10
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/queryUtility/UserData.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class represents the user information extracted from the LDAP
+ * database.
+ *
+ * Contributors:
+ * Jacques Bouthillier - User information extracted from an LDAP database
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.ldap.internal.queryUtility;
+
+import javax.naming.directory.Attribute;
+
+import org.eclipse.mylyn.reviews.userSearch.userInfo.IUserInfo;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class UserData implements IUserInfo {
+ private String f_userID;
+ private String f_name;
+ private String f_company;
+ private String f_office;
+ private String f_department;
+ private String f_country;
+ private String f_city;
+ private String f_ecn;
+ private String f_buisnessPhone;
+ private String f_mobilePhone;
+ private String f_room;
+ private String f_email;
+ private String f_ntDomain;
+ private String f_title;
+
+ public UserData() {
+ }
+
+ public UserData setData(Attribute inUserID, Attribute inFullName, Attribute inCompany, Attribute inLocation,
+ Attribute inDepartment, Attribute inCountry, Attribute inCity, Attribute inECN, Attribute inBuisnessPhone,
+ Attribute inMobilePhone, Attribute inRoom, Attribute inEmail, Attribute inNTDomain, Attribute inTitle)
+ throws javax.naming.NamingException {
+ f_userID = null != inUserID ? inUserID.get().toString() : "";
+ f_name = null != inFullName ? inFullName.get().toString() : "";
+ f_company = null != inCompany ? inCompany.get().toString() : "";
+ f_office = null != inLocation ? inLocation.get().toString() : "";
+ f_department = null != inDepartment ? inDepartment.get().toString() : "";
+ f_country = null != inCountry ? inCountry.get().toString() : "";
+ f_city = null != inCity ? inCity.get().toString() : "";
+ f_ecn = null != inECN ? inECN.get().toString() : "";
+ f_buisnessPhone = null != inBuisnessPhone ? inBuisnessPhone.get().toString() : "";
+ f_mobilePhone = null != inMobilePhone ? inMobilePhone.get().toString() : "";
+ f_room = null != inRoom ? inRoom.get().toString() : "";
+ f_email = null != inEmail ? inEmail.get().toString() : "";
+ f_ntDomain = null != inNTDomain ? inNTDomain.get().toString() : "";
+ f_title = null != inTitle ? inTitle.get().toString() : "";
+ return this;
+ }
+
+ public String getUserId() {
+ return f_userID;
+ }
+ public String getName() {return f_name;}
+ public String getCompany() {return f_company;}
+ public String getOffice() {return f_office;}
+ public String getDepartment() {return f_department;}
+ public String getCountry() {return f_country;}
+ public String getCity() {return f_city;}
+ public String getECN() {return f_ecn;}
+ public String getBuisnessPhone() {return f_buisnessPhone;}
+ public String getMobilePhone() {return f_mobilePhone;}
+ public String getRoom() {return f_room;}
+ public String getEmail() {return f_email;}
+ public String getNTDomain() {return f_ntDomain;}
+
+ public String getTitle() {
+ return f_title;
+ }
+
+ public String[] getAttributeValues() {
+ String[] values = { f_userID, f_name, f_room, f_buisnessPhone, f_ecn, f_mobilePhone, f_company, f_office,
+ f_department, f_city, f_country, f_email, f_title };
+ return values;
+ }
+
+ public String[] getAttributeTypes() {
+ String[] types = { "UserID", "Name", "Room", "Business Phone", "ECN", "Mobile Phone", "Company", "Office",
+ "Department", "City", "Country", "E-Mail", "Title" };
+ return types;
+ }
+
+ public String toString() {
+ return f_name + ", " + f_room + ", " + f_buisnessPhone + ", " + f_ecn + ", " + f_mobilePhone + ", " + f_company
+ + "/" + f_office + "/" + f_department + ", " + f_city + ", " + f_country + ", " + f_email + ", "
+ + f_title;
+ }
+
+}
+
+
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/util/R4EString.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/util/R4EString.java
new file mode 100644
index 00000000..5fda93bf
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/ldap/internal/util/R4EString.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * 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
+ *
+ * Description:
+ *
+ * Contributors:
+ * Jacques Bouthillier - Initial Implementation of the international string
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.ldap.internal.util;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.mylyn.reviews.ldap.Activator;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class R4EString {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ private static final String FBUNDLE_NAME = "org.eclipse.mylyn.reviews.ldap.internal.R4EString"; //$NON-NLS-1$
+
+ private static final ResourceBundle FRESOURCE_BUNDLE = ResourceBundle.getBundle(FBUNDLE_NAME);
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Prevents clients from instantiating this class.
+ */
+ private R4EString() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Gets the key from the value, or 'value' if not found.
+ *
+ * @param value
+ * the value to search value.
+ * @return the key from the value, or 'value' if not found.
+ */
+ public static String getString(String aKey) {
+ try {
+ return FRESOURCE_BUNDLE.getString(aKey);
+ } catch (MissingResourceException e) {
+ Activator.FTracer.traceWarning("Warning: " + "EXCEPTION In getString for:" + aKey);
+ return '!' + aKey + '!';
+ }
+ }
+
+ /**
+ * Format the String according to the object pass
+ *
+ * @param aKey
+ * String
+ * @param aArg
+ * Object
+ * @return the key from the value, or 'value' if not found.
+ */
+ public static String getFormattedString(String aKey, Object aArg) {
+ String format = null;
+ try {
+ format = FRESOURCE_BUNDLE.getString(aKey);
+ } catch (MissingResourceException e) {
+ return "!" + aKey + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ if (aArg == null)
+ aArg = ""; //$NON-NLS-1$
+ return MessageFormat.format(format, new Object[] { aArg });
+ }
+
+ /**
+ * Format the String according to the object pass
+ *
+ * @param aKey
+ * String
+ * @param arg
+ * Object array
+ * @return the key from the value, or 'value' if not found.
+ */
+ public static String getFormattedString(String aKey, Object[] aArgs) {
+ return MessageFormat.format(FRESOURCE_BUNDLE.getString(aKey), aArgs);
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/IQueryUser.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/IQueryUser.java
new file mode 100644
index 00000000..043a0104
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/IQueryUser.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This interface define method used to query the employee database
+ *
+ * Contributors:
+ * Jacques Bouthillier - Interface to define the type of allowed query
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.userSearch.query;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.naming.NamingException;
+
+import org.eclipse.mylyn.reviews.userSearch.userInfo.IUserInfo;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public interface IQueryUser {
+
+ public abstract ArrayList<IUserInfo> search(String a_inUserID, String a_inName, String a_inCompany,
+ String a_inOffice,
+ String a_inDepartement, String a_inCountry, String a_inCity) throws NamingException, IOException;
+
+ public abstract ArrayList<IUserInfo> searchByUserId(String aUserId) throws NamingException, IOException;
+
+ public abstract ArrayList<IUserInfo> searchByUserName(String aUserName) throws NamingException, IOException;
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/QueryUserFactory.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/QueryUserFactory.java
new file mode 100644
index 00000000..7d88acc5
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/query/QueryUserFactory.java
@@ -0,0 +1,17 @@
+/**
+ *
+ */
+package org.eclipse.mylyn.reviews.userSearch.query;
+
+import org.eclipse.mylyn.reviews.ldap.internal.queryUtility.QueryGlobalLdapDirectory;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class QueryUserFactory {
+
+ public IQueryUser getInstance() {
+ return new QueryGlobalLdapDirectory();
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/IUserInfo.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/IUserInfo.java
new file mode 100644
index 00000000..f7c2137c
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/IUserInfo.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class represents the interface to read user information.
+ *
+ * Contributors:
+ * Jacques Bouthillier - Interface to extract User information
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.userSearch.userInfo;
+
+import javax.naming.directory.Attribute;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public interface IUserInfo {
+
+
+ public IUserInfo setData(Attribute inUserID, Attribute inFullName, Attribute inCompany, Attribute inLocation,
+ Attribute inDepartment, Attribute inCountry, Attribute inCity, Attribute inECN, Attribute inBuisnessPhone,
+ Attribute inMobilePhone, Attribute inRoom, Attribute inEmail, Attribute inNTDomain, Attribute inTitle)
+ throws javax.naming.NamingException;
+
+ public abstract String getUserId();
+
+ public abstract String getName();
+
+ public abstract String getCompany();
+
+ public abstract String getOffice();
+
+ public abstract String getDepartment();
+
+ public abstract String getCountry();
+
+ public abstract String getCity();
+
+ public abstract String getECN();
+
+ public abstract String getBuisnessPhone();
+
+ public abstract String getMobilePhone();
+
+ public abstract String getRoom();
+
+ public abstract String getEmail();
+
+ public abstract String getNTDomain();
+
+ public abstract String getTitle();
+
+ public abstract String[] getAttributeValues();
+
+ public abstract String[] getAttributeTypes();
+
+ public abstract String toString();
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/UserInformationFactory.java b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/UserInformationFactory.java
new file mode 100644
index 00000000..f0fd3122
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ldap/src/org/eclipse/mylyn/reviews/userSearch/userInfo/UserInformationFactory.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class represents the factory to get user information.
+ *
+ * Contributors:
+ * Jacques Bouthillier - Class to extract User information
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.userSearch.userInfo;
+
+import org.eclipse.mylyn.reviews.ldap.internal.queryUtility.UserData;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class UserInformationFactory {
+
+ public static IUserInfo getInstance() {
+ return new UserData();
+ }
+
+}

Back to the top