summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMalgorzata Janczarska2011-01-10 18:11:00 (EST)
committer Boris Bokowski2011-01-10 18:11:00 (EST)
commit5aa25a062b41d5f832871bdd9087da148157ffa7 (patch)
treecc8549833eb65c2f9175655f3839ea7755e40da7
parent3899dab06f91a67ff36e39e3ca329cd18ab81dff (diff)
downloadorg.eclipse.orion.server-5aa25a062b41d5f832871bdd9087da148157ffa7.zip
org.eclipse.orion.server-5aa25a062b41d5f832871bdd9087da148157ffa7.tar.gz
org.eclipse.orion.server-5aa25a062b41d5f832871bdd9087da148157ffa7.tar.bz2
redesigned login dialog, added gitignore files
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.basic/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.basic/OSGI-INF/component.xml1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.basic/src/org/eclipse/e4/webide/server/authentication/basic/BasicAuthenticationService.java15
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.form.core/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.form.core/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.form.core/OSGI-INF/component.xml5
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.form.core/build.properties17
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.form.core/src/org/eclipse/e4/webide/server/authentication/form/core/FormAuthHelper.java64
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.form/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/openids/DefaultOpenIdProviders.json6
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/FormOpenIdAuthenticationService.java14
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/internal/OpendIdProviderDescription.java106
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/AuthInitServlet.java3
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/FormOpenIdLoginServlet.java3
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/LoginFormServlet.java172
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/auth.html118
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/css/defaultLoginWindow.css127
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/htmlAuth.js14
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/xhrAuth.js32
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.openid.core/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.authentication.openid/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.configurator/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.search/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.search/solrconf/elevate.xml22
-rw-r--r--bundles/org.eclipse.e4.webide.server.search/solrconf/protwords.txt19
-rw-r--r--bundles/org.eclipse.e4.webide.server.servlets/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin.xml/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin.xml/data/users.xml9
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin.xml/src/org/eclipse/e4/webide/internal/server/useradmin/xml/XmlUserAdmin.java5
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/.gitignore1
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/.project5
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/OSGI-INF/component.xml8
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/build.properties17
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdmin.java2
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdminRegistry.java75
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/IEclipseWebUserAdminRegistry.java54
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UnsupportedUserStoreException.java32
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UserAdminActivator.java13
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/AdminFilter.java4
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/UsersAdminServlet.java61
-rw-r--r--bundles/org.eclipse.e4.webide.server.useradmin/static/js/xhrCreateUser.js6
-rw-r--r--bundles/org.eclipse.e4.webide.server/.gitignore1
44 files changed, 811 insertions, 232 deletions
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.basic/.gitignore b/bundles/org.eclipse.e4.webide.server.authentication.basic/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.basic/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.basic/OSGI-INF/component.xml b/bundles/org.eclipse.e4.webide.server.authentication.basic/OSGI-INF/component.xml
index fc14530..f2b5496 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.basic/OSGI-INF/component.xml
+++ b/bundles/org.eclipse.e4.webide.server.authentication.basic/OSGI-INF/component.xml
@@ -5,4 +5,5 @@
<provide interface="org.eclipse.e4.webide.server.authentication.IAuthenticationService"/>
</service>
<property name="Auth-name" type="String" value="Basic"/>
+ <reference bind="setUserAdminRegistry" cardinality="1..1" interface="org.eclipse.e4.webide.server.useradmin.IEclipseWebUserAdminRegistry" name="IEclipseWebUserAdminRegistry" policy="dynamic" unbind="unsetUserAdminRegistry"/>
</scr:component>
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.basic/src/org/eclipse/e4/webide/server/authentication/basic/BasicAuthenticationService.java b/bundles/org.eclipse.e4.webide.server.authentication.basic/src/org/eclipse/e4/webide/server/authentication/basic/BasicAuthenticationService.java
index ff62563..d144a5e 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.basic/src/org/eclipse/e4/webide/server/authentication/basic/BasicAuthenticationService.java
+++ b/bundles/org.eclipse.e4.webide.server.authentication.basic/src/org/eclipse/e4/webide/server/authentication/basic/BasicAuthenticationService.java
@@ -22,13 +22,15 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.e4.webide.server.LogHelper;
import org.eclipse.e4.webide.server.authentication.IAuthenticationService;
import org.eclipse.e4.webide.server.resources.Base64;
-import org.eclipse.e4.webide.server.useradmin.UserAdminActivator;
+import org.eclipse.e4.webide.server.useradmin.IEclipseWebUserAdminRegistry;
import org.osgi.service.useradmin.Authorization;
import org.osgi.service.useradmin.User;
import org.osgi.service.useradmin.UserAdmin;
public class BasicAuthenticationService implements IAuthenticationService {
+ private IEclipseWebUserAdminRegistry userAdminRegistry;
+
public BasicAuthenticationService() {
super();
}
@@ -57,7 +59,7 @@ public class BasicAuthenticationService implements IAuthenticationService {
String password = authString.substring(authString.indexOf(':') + 1);
User user = getUserForCredentials(login, password);
if (user != null) {
- Authorization authorization = UserAdminActivator.getDefault().getUserAdminService().getAuthorization(user);
+ Authorization authorization = userAdminRegistry.getUserStore().getAuthorization(user);
// TODO handle authorization
return login;
}
@@ -76,7 +78,7 @@ public class BasicAuthenticationService implements IAuthenticationService {
}
private User getUserForCredentials(String login, String password) {
- UserAdmin userAdmin = UserAdminActivator.getDefault().getUserAdminService();
+ UserAdmin userAdmin = userAdminRegistry.getUserStore();
if (userAdmin == null) {
LogHelper.log(new Status(IStatus.ERROR, Activator.PI_SERVER_BASICAUTH, "User admin server is not available"));
return null;
@@ -94,4 +96,11 @@ public class BasicAuthenticationService implements IAuthenticationService {
}
+ public void setUserAdminRegistry(IEclipseWebUserAdminRegistry userAdminStore) {
+ this.userAdminRegistry = userAdminStore;
+ }
+
+ public void unsetUserAdminRegistry(IEclipseWebUserAdminRegistry userAdminStore) {
+ this.userAdminRegistry = null;
+ }
}
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.form.core/.gitignore b/bundles/org.eclipse.e4.webide.server.authentication.form.core/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.form.core/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.form.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.webide.server.authentication.form.core/META-INF/MANIFEST.MF
index f80cdbb..c940852 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.form.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.webide.server.authentication.form.core/META-INF/MANIFEST.MF
@@ -14,3 +14,4 @@ Require-Bundle: javax.servlet;bundle-version="2.5.0",
Bundle-ActivationPolicy: lazy
Import-Package: org.osgi.framework;version="1.6.0",
org.osgi.service.useradmin;version="1.1.0"
+Service-Component: OSGI-INF/component.xml
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.form.core/OSGI-INF/component.xml b/bundles/org.eclipse.e4.webide.server.authentication.form.core/OSGI-INF/component.xml
new file mode 100644
index 0000000..e0a713a
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.form.core/OSGI-INF/component.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.e4.webide.server.authentication.form.core">
+ <implementation class="org.eclipse.e4.webide.server.authentication.form.core.FormAuthHelper"/>
+ <reference bind="setUserAdminRegistry" cardinality="1..1" interface="org.eclipse.e4.webide.server.useradmin.IEclipseWebUserAdminRegistry" name="IEclipseWebUserAdminRegistry" policy="dynamic" unbind="unsetUserAdminRegistry"/>
+</scr:component>
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.form.core/build.properties b/bundles/org.eclipse.e4.webide.server.authentication.form.core/build.properties
index 1915e45..7b51aa5 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.form.core/build.properties
+++ b/bundles/org.eclipse.e4.webide.server.authentication.form.core/build.properties
@@ -1,18 +1,9 @@
-###############################################################################
-# Copyright (c) 2010 IBM Corporation and others.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
static/,\
- data/
-output.. = bin/
+ data/,\
+ OSGI-INF/component.xml
+source.. = src/
src.includes = static/
+output.. = bin/
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.form.core/src/org/eclipse/e4/webide/server/authentication/form/core/FormAuthHelper.java b/bundles/org.eclipse.e4.webide.server.authentication.form.core/src/org/eclipse/e4/webide/server/authentication/form/core/FormAuthHelper.java
index 6fc878b..7a04845 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.form.core/src/org/eclipse/e4/webide/server/authentication/form/core/FormAuthHelper.java
+++ b/bundles/org.eclipse.e4.webide.server.authentication.form.core/src/org/eclipse/e4/webide/server/authentication/form/core/FormAuthHelper.java
@@ -11,6 +11,9 @@
package org.eclipse.e4.webide.server.authentication.form.core;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -20,7 +23,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.e4.webide.server.LogHelper;
import org.eclipse.e4.webide.server.useradmin.EclipseWebUserAdmin;
-import org.eclipse.e4.webide.server.useradmin.UserAdminActivator;
+import org.eclipse.e4.webide.server.useradmin.IEclipseWebUserAdminRegistry;
+import org.eclipse.e4.webide.server.useradmin.UnsupportedUserStoreException;
import org.json.JSONException;
import org.json.JSONObject;
import org.osgi.service.useradmin.User;
@@ -32,6 +36,8 @@ import org.osgi.service.useradmin.UserAdmin;
*/
public class FormAuthHelper {
+ private static IEclipseWebUserAdminRegistry userAdminRegistry;
+
/**
* Returns the name of the user stored in session.
*
@@ -78,8 +84,14 @@ public class FormAuthHelper {
* @throws IOException
*/
public static boolean performAuthentication(HttpServletRequest req, HttpServletResponse resp) throws IOException {
- User user = getUserForCredentials((String) req.getParameter("login"), //$NON-NLS-1$
- req.getParameter("password")); //$NON-NLS-1$
+ User user;
+ try {
+ user = getUserForCredentials((String) req.getParameter("login"), //$NON-NLS-1$
+ req.getParameter("password"), req.getParameter("store"));
+ } catch (UnsupportedUserStoreException e) {
+ LogHelper.log(e);
+ return false;
+ } //$NON-NLS-1$
if (user != null) {
req.getSession().setAttribute("user", req.getParameter("login")); //$NON-NLS-1$//$NON-NLS-2$
return true;
@@ -88,8 +100,8 @@ public class FormAuthHelper {
}
}
- private static User getUserForCredentials(String login, String password) {
- UserAdmin userAdmin = UserAdminActivator.getDefault().getUserAdminService();
+ private static User getUserForCredentials(String login, String password, String userStoreId) throws UnsupportedUserStoreException {
+ UserAdmin userAdmin = (userStoreId == null) ? userAdminRegistry.getUserStore() : userAdminRegistry.getUserStore(userStoreId);
User user = userAdmin.getUser("login", login); //$NON-NLS-1$
if (user != null && user.hasCredential("password", password)) { //$NON-NLS-1$
return user;
@@ -104,11 +116,45 @@ public class FormAuthHelper {
}
}
+ public static boolean isSupportedUserStore(String userStoreId) {
+ return getSupportedUserStores().contains(userStoreId);
+ }
+
+ /**
+ *
+ * @param userStoreId if <code>null</code> checks for default user store
+ * @return
+ * @throws UnsupportedUserStoreException
+ */
+ public static boolean canAddUsers(String userStoreId) throws UnsupportedUserStoreException {
+ return userStoreId == null ? userAdminRegistry.getUserStore().canCreateUsers() : userAdminRegistry.getUserStore(userStoreId).canCreateUsers();
+ }
+
+ public static Collection<String> getSupportedUserStores() {
+ List<String> list = new ArrayList<String>(userAdminRegistry.getSupportedUserStores());
+ list.remove(userAdminRegistry.getUserStore().getStoreName());
+ list.add(0, userAdminRegistry.getUserStore().getStoreName());
+ return list;
+ }
+
+ /**
+ * Uses default user store
+ * @return
+ */
public static boolean canAddUsers() {
- if (UserAdminActivator.getDefault().getUserAdminService() instanceof EclipseWebUserAdmin) {
- return ((EclipseWebUserAdmin) UserAdminActivator.getDefault().getUserAdminService()).canCreateUsers();
- }
- return false;
+ return userAdminRegistry.getUserStore().canCreateUsers();
+ }
+
+ public static EclipseWebUserAdmin getDefaultUserAdmin() {
+ return userAdminRegistry.getUserStore();
+ }
+
+ public void setUserAdminRegistry(IEclipseWebUserAdminRegistry userAdminStore) {
+ FormAuthHelper.userAdminRegistry = userAdminStore;
+ }
+
+ public void unsetUserAdminRegistry(IEclipseWebUserAdminRegistry userAdminStore) {
+ FormAuthHelper.userAdminRegistry = null;
}
}
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.form/.gitignore b/bundles/org.eclipse.e4.webide.server.authentication.form/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.form/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/.gitignore b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/openids/DefaultOpenIdProviders.json b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/openids/DefaultOpenIdProviders.json
new file mode 100644
index 0000000..fcde5df
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/openids/DefaultOpenIdProviders.json
@@ -0,0 +1,6 @@
+[
+{name: "AOL", url: "http://openid.aol.com/", image: "/openids/aim-logo.png"},
+{name: "Google", url: "https://www.google.com/accounts/o8/id", image: "/openids/google.png"},
+{name: "myOpenID", url: "http://myopenid.com", image: "/openids/myopenid-logo.png"},
+{name: "Yahoo!", url: "http://me.yahoo.com", image: "/openids/yahoo-logo.png"}
+] \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/FormOpenIdAuthenticationService.java b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/FormOpenIdAuthenticationService.java
index 1073889..74258be 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/FormOpenIdAuthenticationService.java
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/FormOpenIdAuthenticationService.java
@@ -36,6 +36,12 @@ import org.osgi.service.http.NamespaceException;
public class FormOpenIdAuthenticationService implements IAuthenticationService {
private HttpService httpService;
+ private Properties defaultAuthenticationProperties;
+ public static final String OPENIDS_PROPERTY = "openids"; //$NON-NLS-1$
+
+ public Properties getDefaultAuthenticationProperties() {
+ return defaultAuthenticationProperties;
+ }
@Override
public String authenticateUser(HttpServletRequest req, HttpServletResponse resp, Properties properties) throws IOException {
@@ -60,6 +66,7 @@ public class FormOpenIdAuthenticationService implements IAuthenticationService {
}
public void configure(Properties properties) {
+ this.defaultAuthenticationProperties = properties;
try {
httpService.registerServlet("/auth2", new AuthInitServlet( //$NON-NLS-1$
properties), null, new BundleEntryHttpContext(Activator.getBundleContext().getBundle()));
@@ -87,6 +94,9 @@ public class FormOpenIdAuthenticationService implements IAuthenticationService {
resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
RequestDispatcher rd = req.getRequestDispatcher("/mixlogin/login?redirect=" //$NON-NLS-1$
+ req.getRequestURI());
+ if (properties != null) {
+ req.setAttribute(OPENIDS_PROPERTY, properties.get(OPENIDS_PROPERTY));
+ }
try {
rd.forward(req, resp);
} catch (ServletException e) {
@@ -103,9 +113,10 @@ public class FormOpenIdAuthenticationService implements IAuthenticationService {
try {
httpService.registerServlet("/mixlogin", //$NON-NLS-1$
- new LoginFormServlet(), null, httpContext);
+ new LoginFormServlet(this), null, httpContext);
httpService.registerResources("/mixloginstatic", "/static", //$NON-NLS-1$ //$NON-NLS-2$
httpContext);
+ httpService.registerResources("/openids", "/openids", httpContext);
httpService.registerServlet("/login", new FormOpenIdLoginServlet(this), null, httpContext); //$NON-NLS-1$
httpService.registerServlet("/logout", new FormOpenIdLogoutServlet(), null, httpContext); //$NON-NLS-1$
} catch (ServletException e) {
@@ -122,6 +133,7 @@ public class FormOpenIdAuthenticationService implements IAuthenticationService {
httpService.unregister("/mixloginstatic"); //$NON-NLS-1$
httpService.unregister("/login"); //$NON-NLS-1$
httpService.unregister("/logout"); //$NON-NLS-1$
+ httpService.unregister("/openids"); //$NON-NLS-1$
httpService = null;
}
}
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/internal/OpendIdProviderDescription.java b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/internal/OpendIdProviderDescription.java
new file mode 100644
index 0000000..be03e8c
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/internal/OpendIdProviderDescription.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.webide.server.authentication.formopenid.internal;
+
+public class OpendIdProviderDescription {
+
+ private String authSite;
+ private String image;
+ private String name;
+
+ public String getAuthSite() {
+ return authSite;
+ }
+
+ public void setAuthSite(String authSite) {
+ this.authSite = authSite;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public OpendIdProviderDescription(String authSite, String image, String name) {
+ this.authSite = authSite;
+ this.image = image;
+ this.name = name;
+ }
+
+ public OpendIdProviderDescription() {
+ }
+
+ public String toHtmlOption() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<option value=\"");
+ sb.append(authSite);
+ sb.append("\">");
+ sb.append(name == null ? authSite : name);
+ sb.append("</option>");
+ return sb.toString();
+ }
+
+ public String toJsImage(){
+ StringBuilder sb = new StringBuilder();
+ sb.append("<a class=\"loginWindow\" href=\"javascript:confirmOpenId(\\'");
+ sb.append(authSite);
+ sb.append("\\')\">");
+ if(image!=null)
+ {
+ sb.append("<img class=\"loginWindow\" src=\"");
+ sb.append(image);
+ sb.append("\" alt=\"");
+ sb.append(name==null? authSite : name);
+ sb.append("\" title=\"");
+ sb.append(name==null? authSite : name);
+ sb.append("\">");
+ }else{
+ sb.append(name==null? authSite : name);
+ }
+ sb.append("</a>");
+ sb.append("&nbsp;");
+ return sb.toString();
+ }
+
+ public String toHtmlImage(){
+ StringBuilder sb = new StringBuilder();
+ sb.append("<a class=\"loginWindow\" href=\"javascript:confirmOpenId('");
+ sb.append(authSite);
+ sb.append("')\">");
+ if(image!=null)
+ {
+ sb.append("<img class=\"loginWindow\" src=\"");
+ sb.append(image);
+ sb.append("\" alt=\"");
+ sb.append(name==null? authSite : name);
+ sb.append("\" title=\"");
+ sb.append(name==null? authSite : name);
+ sb.append("\">");
+ }else{
+ sb.append(name==null? authSite : name);
+ }
+ sb.append("</a>");
+ sb.append("&nbsp;");
+ return sb.toString();
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/AuthInitServlet.java b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/AuthInitServlet.java
index b0dbcd5..b5f392c 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/AuthInitServlet.java
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/AuthInitServlet.java
@@ -19,6 +19,8 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.e4.webide.server.authentication.formopenid.FormOpenIdAuthenticationService;
+
public class AuthInitServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -44,6 +46,7 @@ public class AuthInitServlet extends HttpServlet {
resp.setStatus(HttpServletResponse.SC_OK);
String putStyle = properties.getProperty(CSS_LINK_PROPERTY) == null ? "" //$NON-NLS-1$
: "&styles=" + properties.getProperty(CSS_LINK_PROPERTY); //$NON-NLS-1$
+ req.setAttribute(FormOpenIdAuthenticationService.OPENIDS_PROPERTY, properties.get(FormOpenIdAuthenticationService.OPENIDS_PROPERTY));
RequestDispatcher rd = req.getRequestDispatcher("/mixlogin/checkuser?redirect=" //$NON-NLS-1$
+ req.getRequestURI() + putStyle);
try {
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/FormOpenIdLoginServlet.java b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/FormOpenIdLoginServlet.java
index 8695048..b05889f 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/FormOpenIdLoginServlet.java
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/FormOpenIdLoginServlet.java
@@ -12,7 +12,6 @@ package org.eclipse.e4.webide.server.authentication.formopenid.servlets;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Properties;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -102,7 +101,7 @@ public class FormOpenIdLoginServlet extends EclipseWebServlet {
}
String user;
- if ((user = authenticationService.getAuthenticatedUser(req, resp, new Properties())) != null) {
+ if ((user = authenticationService.getAuthenticatedUser(req, resp, authenticationService.getDefaultAuthenticationProperties())) != null) {
resp.setStatus(HttpServletResponse.SC_OK);
try {
JSONObject array = new JSONObject();
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/LoginFormServlet.java b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/LoginFormServlet.java
index 6d16c9b..87190c0 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/LoginFormServlet.java
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/src/org/eclipse/e4/webide/server/authentication/formopenid/servlets/LoginFormServlet.java
@@ -10,20 +10,32 @@
*******************************************************************************/
package org.eclipse.e4.webide.server.authentication.formopenid.servlets;
+import static org.eclipse.e4.webide.server.authentication.formopenid.FormOpenIdAuthenticationService.OPENIDS_PROPERTY;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.webide.server.LogHelper;
import org.eclipse.e4.webide.server.authentication.form.core.FormAuthHelper;
import org.eclipse.e4.webide.server.authentication.formopenid.Activator;
+import org.eclipse.e4.webide.server.authentication.formopenid.FormOpenIdAuthenticationService;
+import org.eclipse.e4.webide.server.authentication.formopenid.internal.OpendIdProviderDescription;
import org.eclipse.e4.webide.server.resources.Base64;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.osgi.framework.Version;
/**
@@ -38,6 +50,13 @@ public class LoginFormServlet extends HttpServlet {
private static final long serialVersionUID = -1941415021420599704L;
private String newAccountLink = "/users/create"; //$NON-NLS-1$
private String newAccountJsFunction = "javascript:addUser"; //$NON-NLS-1$
+ private List<OpendIdProviderDescription> defaultOpenids;
+ private FormOpenIdAuthenticationService authenticationService;
+
+ public LoginFormServlet(FormOpenIdAuthenticationService authenticationService) {
+ super();
+ this.authenticationService = authenticationService;
+ }
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@@ -59,10 +78,73 @@ public class LoginFormServlet extends HttpServlet {
// handled by service()
}
+ private OpendIdProviderDescription getOpenidProviderFromJson(JSONObject json) throws JSONException {
+ OpendIdProviderDescription provider = new OpendIdProviderDescription();
+ String url = json.getString("url");
+ provider.setAuthSite(url);
+
+ try {
+ String name = json.getString("name");
+ provider.setName(name);
+ } catch (JSONException e) {
+ // ignore, Name is not mandatory
+ }
+ try {
+ String image = json.getString("image");
+ provider.setImage(image);
+ } catch (JSONException e) {
+ // ignore, Image is not mandatory
+ }
+ return provider;
+ }
+
+ private List<OpendIdProviderDescription> getSupportedOpenIdProviders(String openids) throws JSONException {
+ List<OpendIdProviderDescription> opendIdProviders = new ArrayList<OpendIdProviderDescription>();
+ JSONArray openidArray = new JSONArray(openids);
+ for (int i = 0; i < openidArray.length(); i++) {
+ JSONObject jsonProvider = openidArray.getJSONObject(i);
+ try {
+ opendIdProviders.add(getOpenidProviderFromJson(jsonProvider));
+ } catch (JSONException e) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.PI_FORMOPENID_SERVLETS, "Cannot load OpenId provider, invalid entry " + jsonProvider + " Attribute \"ulr\" is mandatory"));
+ }
+ }
+ return opendIdProviders;
+ }
+
+ private List<OpendIdProviderDescription> getDefaultOpenIdProviders() {
+ try {
+ if (defaultOpenids == null) {
+ defaultOpenids = getSupportedOpenIdProviders(getFileContents("/openids/DefaultOpenIdProviders.json"));
+ }
+ } catch (Exception e) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.PI_FORMOPENID_SERVLETS, "Cannot load default openid list, JSON format expected"));
+ return new ArrayList<OpendIdProviderDescription>();
+ }
+ return defaultOpenids;
+ }
+
+ private String getConfiguredOpenIds() {
+ return (String) (authenticationService.getDefaultAuthenticationProperties() == null ? null : authenticationService.getDefaultAuthenticationProperties().get(OPENIDS_PROPERTY));
+ }
+
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.service(req, resp);
if (!resp.isCommitted()) {
+ List<OpendIdProviderDescription> openidProviders;
+ String customOpenids = req.getAttribute(OPENIDS_PROPERTY) == null ? getConfiguredOpenIds() : (String) req.getAttribute(OPENIDS_PROPERTY);
+ if (customOpenids == null || customOpenids.trim().length() == 0) {
+ openidProviders = getDefaultOpenIdProviders();
+ } else {
+ try {
+ openidProviders = getSupportedOpenIdProviders(customOpenids);
+ } catch (JSONException e) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.PI_FORMOPENID_SERVLETS, "Cannot load openid list, JSON format expected"));
+ openidProviders = getDefaultOpenIdProviders();
+ }
+ }
+
// redirection from FormAuthenticationService.setNotAuthenticated
String versionString = req.getHeader("EclipseWeb-Version"); //$NON-NLS-1$
Version version = versionString == null ? null : new Version(versionString);
@@ -72,14 +154,14 @@ public class LoginFormServlet extends HttpServlet {
String xRequestedWith = req.getHeader("X-Requested-With"); //$NON-NLS-1$
if (version == null && !"XMLHttpRequest".equals(xRequestedWith)) { //$NON-NLS-1$
- writeHtmlResponse(req, resp);
+ writeHtmlResponse(req, resp, openidProviders);
} else {
- writeJavaScriptResponse(req, resp);
+ writeJavaScriptResponse(req, resp, openidProviders);
}
}
}
- private void writeJavaScriptResponse(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ private void writeJavaScriptResponse(HttpServletRequest req, HttpServletResponse resp, List<OpendIdProviderDescription> openids) throws IOException {
resp.setContentType("text/javascript"); //$NON-NLS-1$
PrintWriter writer = resp.getWriter();
writer.print("if(!stylg)\n"); //$NON-NLS-1$
@@ -92,7 +174,10 @@ public class LoginFormServlet extends HttpServlet {
writer.print("if(!divg)\n"); //$NON-NLS-1$
writer.print("var divg = document.createElement(\"span\");\n"); //$NON-NLS-1$
writer.print("divg.innerHTML='"); //$NON-NLS-1$
- writer.print(loadJSResponse(req));
+ writer.print(loadJSResponse(req, openids));
+ writer.print("setUserStore('");
+ writer.print(FormAuthHelper.getDefaultUserAdmin().getStoreName());
+ writer.print("');");
String path = req.getPathInfo();
if (path.startsWith("/login")) { //$NON-NLS-1$
writer.print("login();"); //$NON-NLS-1$
@@ -113,13 +198,15 @@ public class LoginFormServlet extends HttpServlet {
}
}
- private String loadJSResponse(HttpServletRequest req) throws IOException {
+ private String loadJSResponse(HttpServletRequest req, List<OpendIdProviderDescription> openids) throws IOException {
StringBuilder sb = new StringBuilder();
StringBuilder authString = new StringBuilder();
appendFileContentAsJsString(authString, "static/auth.html"); //$NON-NLS-1$
String authSite = replaceNewAccount(authString.toString(), req.getHeader("Referer"), true); //$NON-NLS-1$
authSite = replaceError(authSite, ""); //$NON-NLS-1$
+ authSite = replaceOpenidList(authSite, openids, true);
+ authSite = replaceUserStores(authSite, true);
sb.append(authSite);
sb.append("';\n"); //$NON-NLS-1$
sb.append("var scr = '"); //$NON-NLS-1$
@@ -155,12 +242,17 @@ public class LoginFormServlet extends HttpServlet {
}
}
- private void writeHtmlResponse(HttpServletRequest req, HttpServletResponse response) throws IOException {
+ private void writeHtmlResponse(HttpServletRequest req, HttpServletResponse response, List<OpendIdProviderDescription> openids) throws IOException {
response.setContentType("text/html"); //$NON-NLS-1$
PrintWriter writer = response.getWriter();
writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">"); //$NON-NLS-1$
writer.println("<html>"); //$NON-NLS-1$
writer.println("<head>"); //$NON-NLS-1$
+ writer.println("<meta name=\"copyright\" content=\"Copyright (c) IBM Corporation and others 2010.\" >");
+ writer.println("<meta http-equiv=\"Content-Language\" content=\"en-us\">");
+ writer.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
+ writer.println("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\">");
+
writer.println("<title>Login Page</title>");
if (req.getParameter("styles") == null //$NON-NLS-1$
|| "".equals(req.getParameter("styles"))) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -179,13 +271,17 @@ public class LoginFormServlet extends HttpServlet {
writer.println(getFileContents("static/js/htmlAuth.js")); //$NON-NLS-1$
writer.println("//--></script>"); //$NON-NLS-1$
writer.println("</head>"); //$NON-NLS-1$
- writer.println("<body>"); //$NON-NLS-1$
+ writer.print("<body onLoad=\"javascript:setUserStore('"); //$NON-NLS-1$
+ writer.print(FormAuthHelper.getDefaultUserAdmin().getStoreName());
+ writer.println("');\">"); //$NON-NLS-1$
String authSite = getFileContents("static/auth.html"); //$NON-NLS-1$
authSite = replaceForm(authSite, req.getParameter("redirect")); //$NON-NLS-1$
authSite = replaceNewAccount(authSite, ((req.getParameter("redirect") == null) ? req.getRequestURI() //$NON-NLS-1$
: req.getParameter("redirect")), false); //$NON-NLS-1$
authSite = replaceError(authSite, req.getParameter("error")); //$NON-NLS-1$
+ authSite = replaceOpenidList(authSite, openids, false);
+ authSite = replaceUserStores(authSite, false);
writer.println(authSite);
writer.println("</body>"); //$NON-NLS-1$
@@ -215,22 +311,74 @@ public class LoginFormServlet extends HttpServlet {
formBegin.append(redirect);
}
formBegin.append("\">"); //$NON-NLS-1$
+ formBegin.append("<input id=\"store\" name=\"store\" type=\"hidden\" value=\"" + FormAuthHelper.getDefaultUserAdmin().getStoreName() + "\">");
return authSite.replace("<!--form-->", formBegin.toString()).replace( //$NON-NLS-1$
"<!--/form-->", "</form>"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ private String getNewAccountJsLink(String redirect, String userStore) {
+ return newAccountJsFunction + "(\\'" + redirect + "\\'" + (userStore == null ? ")" : ", \\'" + userStore + "\\')");
+ }
+
+ private String getNewAccountHtmlLink(String redirect, String userStore) {
+ return this.newAccountLink + "?redirect=" //$NON-NLS-1$ //$NON-NLS-2$
+ + redirect + (userStore == null ? "" : ("&store=" + userStore));//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
private String replaceNewAccount(String authSite, String redirect, boolean javascriptResp) {
if (!FormAuthHelper.canAddUsers()) {
return authSite;
}
String newAccountA = ""; //$NON-NLS-1$
- String newAccountLink = javascriptResp ? newAccountJsFunction + "(\\'" //$NON-NLS-1$
- + redirect + "\\')" : this.newAccountLink + "?redirect=" //$NON-NLS-1$ //$NON-NLS-2$
- + redirect;
+ String userStore = FormAuthHelper.getDefaultUserAdmin().getStoreName();
+ String newAccountLink = javascriptResp ? getNewAccountJsLink(redirect, userStore) : getNewAccountHtmlLink(redirect, userStore);
if (newAccountLink != null && !"".equals(newAccountLink)) { //$NON-NLS-1$
- newAccountA = "<a class=\"loginWindow\" href=\"" + newAccountLink //$NON-NLS-1$
- + "\">Create new account</a>"; //$NON-NLS-1$
+ newAccountA = "<div class=\"hrloginWindow\"></div><h3 class=\"loginWindow\">New to EclipseWeb? <a class=\"loginWindow\" href=\"" + newAccountLink //$NON-NLS-1$
+ + "\">Create " + userStore + " account</a></h3>"; //$NON-NLS-1$
}
return authSite.replace("<!--NEW_ACCOUNT_LINK-->", newAccountA); //$NON-NLS-1$
}
+
+ private String replaceUserStores(String authSite, boolean isJsResponce) {
+ StringBuilder sb = new StringBuilder();
+ boolean isFirst = true;
+ for (String store : FormAuthHelper.getSupportedUserStores()) {
+ if (isFirst) {
+ isFirst = false;
+ } else {
+ sb.append(" | ");
+ }
+ if (isJsResponce) {
+ sb.append("<a href=\"javascript:setUserStore(\\\\'");
+ } else {
+ sb.append("<a href=\"javascript:setUserStore('");
+ }
+ sb.append(store);
+ if (isJsResponce) {
+ sb.append("\\\\')\" id=\"Login_");
+ } else {
+ sb.append("')\" id=\"Login_");
+ }
+ sb.append(store);
+ sb.append("\">");
+ sb.append(store);
+ sb.append("</a>");
+ }
+
+ return authSite.replaceAll("<!--LOGIN STORES-->", sb.toString());
+ }
+
+ private String replaceOpenidList(String authSite, List<OpendIdProviderDescription> openids, boolean javascriptResp) {
+ if (openids == null || openids.isEmpty()) {
+ return authSite;
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append("<div class=\"hrloginWindow\"></div>");
+ sb.append("<h3 class=\"loginWindow\">Login with: ");
+ for (OpendIdProviderDescription openid : openids) {
+ sb.append(javascriptResp ? openid.toJsImage() : openid.toHtmlImage());
+ }
+ sb.append("</h3>");
+ return authSite.replace("<!--OpenID list-->", sb.toString());
+ }
}
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/auth.html b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/auth.html
index 0368b2a..582e771 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/auth.html
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/auth.html
@@ -1,71 +1,55 @@
<div id="loginWindow" class="loginWindow">
-<p id="closeLoginWindow" class="closeLoginWindow"
- style="visibility: hidden;"><a title="Close"
- href="javascript:closeLoginWindow()" class="closeLoginWindow"> <img
- class="closeLoginWindow" src="/mixloginstatic/images/close-tab.gif">
-</a></p>
-<!--ERROR-->
-<h2 class="loginWindow">Please sign in:</h2>
-<table class="loginWindow">
- <!--form-->
- <tbody>
- <tr>
- <td class="loginWindow"><label class="loginWindow" id=loginLabel
- for=login>Name:</label></td>
- <td class="loginWindow"><input class="loginWindow" name=login
- id=login tabindex=1><br>
- </td>
- </tr>
- <tr>
- <td class="loginWindow"><label class="loginWindow"
- id=passwordLabel for=password>Password:</label></td>
- <td class="loginWindow"><input class="loginWindow" name=password
- type=password id=password tabindex=2
- onkeypress="var event = window.event ? window.event : event ? event : evt; if (event.keyCode === 13) { confirmLogin(); } else {return true;}"><br>
- </td>
- </tr>
- <tr>
- <td class="loginWindow" colspan=2><!--NEW_ACCOUNT_LINK--></td>
- </tr>
- <tr>
- <td class="loginWindow loginWindowButtonTd" colspan=2>
- <button class="loginWindow" onClick=confirmLogin()
- dojoType=dijit.form.Button type=submit value=OK tabindex=3>Sign
- in</button>
- </td>
- </tr>
- </tbody>
+ <div class="loginWindowToolbar">
+ <div class="loginWindowHeader">
+ <h2 class="loginWindowHeader">
+ Login
+ </h2>
+ </div>
+ <div class="closeLoginWindow">
+ <p id="closeLoginWindow" class="closeLoginWindow"
+ style="visibility: hidden;">
+ <a title="Close" href="javascript:closeLoginWindow()"
+ class="closeLoginWindow"> <img class="closeLoginWindow"
+ src="/mixloginstatic/images/close-tab.gif"> </a>
+ </p>
+ </div>
+ </div>
+ <div style="clear: left; margin: 8px;">
+ <!--ERROR-->
+ <h2 class="loginWindowStores">
+ <!--LOGIN STORES-->
+ </h2>
+ <table class="loginWindow">
+ <!--form-->
+ <tbody>
+ <tr>
+ <td class="loginWindow"><label class="loginWindow"
+ id=loginLabel for=login>Name:</label>
+ </td>
+ <td class="loginWindow"><input class="loginWindow" name=login
+ id=login tabindex=1><br></td>
+ </tr>
+ <tr>
+ <td class="loginWindow"><label class="loginWindow"
+ id=passwordLabel for=password>Password:</label>
+ </td>
+ <td class="loginWindow"><input class="loginWindow"
+ name=password type=password id=password tabindex=2
+ onkeypress="var event = window.event ? window.event : event ? event : evt; if (event.keyCode === 13) { confirmLogin(); } else {return true;}"><br>
+ </td>
+ </tr>
+ <tr>
+ <td class="loginWindow loginWindowButtonTd" colspan=2>
+ <button class="loginWindow" onClick=confirmLogin()
+ dojoType=dijit.form.Button type=submit value=OK tabindex=3>
+ Sign in
+ </button></td>
+ </tr>
+ </tbody>
+ </table>
+ <!--NEW_ACCOUNT_LINK-->
+ <!--OpenID list--></h3>
+ </div>
<!--/form-->
- <tr>
- <td class="loginWindow" colspan=2>
- <h2 class="loginWindow" id="openidLink"><a class="loginWindow"
- href="javascript:openidLogin()">Use OpenID</a></h2>
- </td>
- </tr>
- <tbody id="openidLogin" style="display: none;">
- <tr>
- <td class="loginWindow" colspan=2>
- <h2 class="loginWindow openidLogin">OpenID</h2>
- </td>
- </tr>
- <tr>
- <td class="loginWindow openidLogin">Sign in using:</td>
- <td class="loginWindow openidLogin"><select name=openid id=openidSite
- onkeypress="var event = window.event ? window.event : event ? event : evt; if (event.keyCode === 13) { confirmOpenId(); } else {return true;}">
- <option value="http://openid.aol.com/">AOL</option>
- <option value="https://www.google.com/accounts/o8/id">Google</option>
- <option value="http://myopenid.com">myOpenID</option>
- <option value="http://me.yahoo.com">Yahoo!</option>
- </select><br>
- </td>
- </tr>
- <tr>
- <td class="loginWindow loginWindowButtonTd openidLogin" colspan=2>
- <button class="loginWindow openidLogin" onClick=confirmOpenId()
- dojoType=dijit.form.Button value=OK tabindex=5>OK</button>
- </td>
- </tr>
- </tbody>
-</table>
</div>
<div id="loginWindowMask"></div>
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/css/defaultLoginWindow.css b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/css/defaultLoginWindow.css
index 6c06284..bdc7ad5 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/css/defaultLoginWindow.css
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/css/defaultLoginWindow.css
@@ -1,7 +1,9 @@
.closeLoginWindow {
border: none;
}
-
+div.closeLoginWindow {
+ float: rigth;
+}
p.closeLoginWindow {
text-align: right;
margin: 0px;
@@ -15,6 +17,51 @@ img.closeLoginWindow:hover {
opacity: 1;
}
+div.loginWindowToolbar{
+ clear: both;
+ padding: 8px;
+ background-color: #FFFFFF;
+ background-image: url("/images/titleBar.png");
+ background-position: left top;
+ background-repeat: repeat-x;
+ border-bottom-color: #BFBFBF;
+ border-bottom-style: none;
+ border-bottom-width: 1px;
+ border-left-color-ltr-source: physical;
+ border-left-color-rtl-source: physical;
+ border-left-color-value: #BFBFBF;
+ border-left-style-ltr-source: physical;
+ border-left-style-rtl-source: physical;
+ border-left-style-value: none;
+ border-left-width-ltr-source: physical;
+ border-left-width-rtl-source: physical;
+ border-left-width-value: 1px;
+ border-right-color-ltr-source: physical;
+ border-right-color-rtl-source: physical;
+ border-right-color-value: #BFBFBF;
+ border-right-style-ltr-source: physical;
+ border-right-style-rtl-source: physical;
+ border-right-style-value: none;
+ border-right-width-ltr-source: physical;
+ border-right-width-rtl-source: physical;
+ border-right-width-value: 1px;
+ border-top-color: #BFBFBF;
+ border-top-style: none;
+ border-top-width: 1px;
+ color: #6D6D6D;
+ min-height: 20px;
+}
+
+div.loginWindowHeader{
+ float: left;
+}
+h2.loginWindowHeader{
+ margin-top: 0px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #888;
+ font-size: 1.2em;
+}
+
#errorWin {
backgroud: #bcd5f0;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#bcd5f0'); /* for IE */
@@ -22,7 +69,7 @@ img.closeLoginWindow:hover {
background: -moz-linear-gradient(top, #FFF, #bcd5f0); /* for firefox 3.6+ */
border: 1px solid #8ba0bd;
margin: 10px;
- max-width: 300px;
+ max-width: 30em;
}
#loginError {
@@ -59,7 +106,7 @@ div.loginWindow {
border: 1px solid #cdcdcd;
background-color: #fff;
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.25);
- padding: 8px;
+ padding: 0px;
-webkit-box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.25);
-moz-box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.25);
position: absolute;
@@ -70,62 +117,102 @@ div.loginWindow {
z-index: 1000;
}
-h2.loginWindow {
- font-size: 1.1em;
- font-weight: bold;
- color: #316ac5;
- margin: 0;
+h2.loginWindowStores {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #888;
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 0.9em;
+}
+
+.loginWindowStores a:link, a:VISITED {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #888;
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 0.9em;
+ text-decoration: none;
+}
+
+.loginWindowStores a:hover, a:active {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #444;
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 0.9em;
+ text-decoration: none;
}
+h3.loginWindow {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #888;
+ margin: 0px;
+ font-size: 0.9em;
+ max-width: 30em;
+}
+
+
button.loginWindow {
- border: 1px solid #8ba0bd;
- border-bottom: 1px solid #657c9c;
+ border: none;
padding: 0.1em 0.2em 0.2em 0.2em;
- background: #bcd5f0 url("/mixloginstatic/images/buttonEnabled.png")
- repeat-x top left;
+ background: #EEE;
font-size: 12px;
text-align: center;
- margin-top: 0.7em;
}
button.loginWindow:hover {
- border: 1px solid #8ba0bd;
- border-bottom: 1px solid #657c9c;
+ border: none;
padding: 0.1em 0.2em 0.2em 0.2em;
background: #bcd5f0 url("/mixloginstatic/images/buttonHover.png")
repeat-x top left;
font-size: 12px;
text-align: right;
- margin-top: 0.7em;
}
p.loginWindow {
font-size: 1em;
- line-height: 1.3em;
+ line-height: 1.2em;
}
a.loginWindow {
- font-size: 0.85em;
font-style: italic;
text-decoration: none;
+ font-weight: normal;
color: #316ac5;
}
a.loginWindow:hover {
- font-size: 0.85em;
font-style: italic;
text-decoration: underline;
+ font-weight: normal;
color: #316ac5;
}
td.loginWindowButtonTd {
+ padding-top: 10px;
+ padding-bottom: 10px;
text-align: right;
}
+img.loginWindow{
+ height: 20px;
+ border: 0px;
+}
+
table.loginWindow {
- min-width: 300px;
+ margin-left: 20px;
}
td.loginWindow {
min-width: 10em;
+}
+
+.hrloginWindow {
+ border-top: 1px solid #DDD;
+ background-color: #FFF;
+ heigh: 1px;
+ border-bottom: none;
+ border-left: none;
+ border-right: none;
+ margin: 10px 0 10px 0;
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/htmlAuth.js b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/htmlAuth.js
index 096c68c..13675e8 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/htmlAuth.js
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/htmlAuth.js
@@ -8,6 +8,8 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
+var userStore;
+
function openidLogin() {
document.getElementById('openidLogin').style.display = '';
document.getElementById('openidLink').style.display = 'none';
@@ -16,16 +18,24 @@ function openidLogin() {
}, 0);
}
-function confirmOpenId() {
+function confirmOpenId(openid) {
/* don't wait for the login response, notify anyway */
notify = true;
- var openid = document.getElementById('openidSite').value;
if (openid != "" && openid != null) {
window.location = "/login/openid?openid=" + encodeURIComponent(openid)
+ "&redirect=" + window.location;
}
};
+function setUserStore(userStoreToSet){
+ if(userStore){
+ document.getElementById('Login_'+userStore).style.color = '';
+ }
+ userStore = userStoreToSet;
+ document.getElementById('Login_'+userStore).style.color = '#444';
+ document.getElementById('store').value=userStore;
+}
+
function confirmLogin() {
/* handled by submit form */
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/xhrAuth.js b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/xhrAuth.js
index d6450ac..db23c64 100644
--- a/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/xhrAuth.js
+++ b/bundles/org.eclipse.e4.webide.server.authentication.formopenid/static/js/xhrAuth.js
@@ -8,14 +8,13 @@
******************************************************************************/
var notify = false;
+var userStore;
function login(error) {
notify = false;
dojo.byId('loginWindowMask').style.visibility = 'visible';
dojo.byId('loginWindow').style.visibility = 'visible';
dojo.byId('closeLoginWindow').style.visibility = 'inherit';
- document.getElementById('openidLogin').style.display = 'none';
- document.getElementById('openidLink').style.display = '';
setTimeout(function() {
dojo.byId('login').focus();
}, 0);
@@ -27,18 +26,17 @@ function login(error) {
}
};
-function openidLogin() {
- document.getElementById('openidLogin').style.display = '';
- document.getElementById('openidLink').style.display = 'none';
- setTimeout(function() {
- dojo.byId('openidSite').focus();
- }, 0);
+function setUserStore(userStoreToSet){
+ if(userStore){
+ document.getElementById('Login_'+userStore).style.color = '';
+ }
+ userStore = userStoreToSet;
+ document.getElementById('Login_'+userStore).style.color = '#444';
}
-function confirmOpenId() {
+function confirmOpenId(openid) {
/* don't wait for the login response, notify anyway */
notify = true;
- var openid = dojo.byId('openidSite').value;
if (openid != "" && openid != null) {
win = window.open("/login/openid?openid=" + encodeURIComponent(openid),
"openid_popup", "width=790,height=580");
@@ -63,7 +61,6 @@ function handleOpenIDResponse(openid_args, error) {
*/
if (error) {
login(error);
- openidLogin();
} else {
authDone();
checkUser();
@@ -103,7 +100,8 @@ function confirmLogin() {
},
content : {
login : dojo.byId("login").value,
- password : dojo.byId("password").value
+ password : dojo.byId("password").value,
+ store: userStore
},
handleAs : "json",
timeout : 15000,
@@ -147,7 +145,7 @@ function handleLoginError(error, ioArgs) {
return error;
}
-function addUser(redirectVal) {
+function addUser(redirectVal, userStore) {
dojo.xhrGet({
url : "/users/create",
headers : {
@@ -156,7 +154,8 @@ function addUser(redirectVal) {
handleAs : "text",
content : {
redirect : redirectVal,
- onUserCreated : "userCreated"
+ onUserCreated : "userCreated",
+ store: userStore
},
timeout : 15000,
load : function(javascript, ioArgs) {
@@ -170,7 +169,7 @@ function addUser(redirectVal) {
});
};
-function userCreated(username, password) {
+function userCreated(username, password, store) {
notify = true;
dojo.xhrPost({
url : "/login/form",
@@ -179,7 +178,8 @@ function userCreated(username, password) {
},
content : {
login : username,
- password : password
+ password : password,
+ store: store
},
handleAs : "json",
timeout : 15000,
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.openid.core/.gitignore b/bundles/org.eclipse.e4.webide.server.authentication.openid.core/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.openid.core/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.authentication.openid/.gitignore b/bundles/org.eclipse.e4.webide.server.authentication.openid/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.authentication.openid/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.configurator/.gitignore b/bundles/org.eclipse.e4.webide.server.configurator/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.configurator/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.search/.gitignore b/bundles/org.eclipse.e4.webide.server.search/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.search/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.search/solrconf/elevate.xml b/bundles/org.eclipse.e4.webide.server.search/solrconf/elevate.xml
index b5ccaae..e210025 100644
--- a/bundles/org.eclipse.e4.webide.server.search/solrconf/elevate.xml
+++ b/bundles/org.eclipse.e4.webide.server.search/solrconf/elevate.xml
@@ -1,25 +1,3 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- If this file is found in the config directory, it will only be
- loaded once at startup. If it is found in Solr's data
- directory, it will be re-loaded every commit.
--->
-
<elevate>
</elevate>
diff --git a/bundles/org.eclipse.e4.webide.server.search/solrconf/protwords.txt b/bundles/org.eclipse.e4.webide.server.search/solrconf/protwords.txt
index d027e20..9afe058 100644
--- a/bundles/org.eclipse.e4.webide.server.search/solrconf/protwords.txt
+++ b/bundles/org.eclipse.e4.webide.server.search/solrconf/protwords.txt
@@ -1,18 +1,3 @@
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#-----------------------------------------------------------------------
-# Use a protected word file to protect against the stemmer reducing two
-# unrelated words to the same base word.
-
-# Just list words to protect, one on each line
+# This is used to prevent the stemmer from reduced unrelated words into a base word
+# list words to protect, one on each line
diff --git a/bundles/org.eclipse.e4.webide.server.servlets/.gitignore b/bundles/org.eclipse.e4.webide.server.servlets/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.servlets/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin.xml/.gitignore b/bundles/org.eclipse.e4.webide.server.useradmin.xml/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.useradmin.xml/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin.xml/data/users.xml b/bundles/org.eclipse.e4.webide.server.useradmin.xml/data/users.xml
index 576b60d..67f7a44 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin.xml/data/users.xml
+++ b/bundles/org.eclipse.e4.webide.server.useradmin.xml/data/users.xml
@@ -1,20 +1,19 @@
-<?xml version="1.0"?>
-<WebIdeUsers>
+<?xml version="1.0" encoding="UTF-8"?><WebIdeUsers>
<roles>
<role name="admin"/>
<role name="user"/>
<role name="guest"/>
</roles>
<users>
-<user login="admin" name="WebIde Admin" email="admin@admin.com" password="admin">
+<user email="admin@admin.com" login="admin" name="WebIde Admin" password="admin">
<roles>
<role name="admin"/>
</roles>
</user>
-<user login="test" name="WebIde User" email="test@test.com" password="test">
+<user email="test@test.com" login="test" name="WebIde User" password="test">
<roles>
<role name="user"/>
</roles>
</user>
-</users>
+<user login="test1" name="" password="test"/></users>
</WebIdeUsers> \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin.xml/src/org/eclipse/e4/webide/internal/server/useradmin/xml/XmlUserAdmin.java b/bundles/org.eclipse.e4.webide.server.useradmin.xml/src/org/eclipse/e4/webide/internal/server/useradmin/xml/XmlUserAdmin.java
index e8a0e31..af3d1e3 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin.xml/src/org/eclipse/e4/webide/internal/server/useradmin/xml/XmlUserAdmin.java
+++ b/bundles/org.eclipse.e4.webide.server.useradmin.xml/src/org/eclipse/e4/webide/internal/server/useradmin/xml/XmlUserAdmin.java
@@ -124,4 +124,9 @@ public class XmlUserAdmin extends EclipseWebUserAdmin {
return true;
}
+ @Override
+ public String getStoreName() {
+ return "EclipseWeb";
+ }
+
}
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/.gitignore b/bundles/org.eclipse.e4.webide.server.useradmin/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/.project b/bundles/org.eclipse.e4.webide.server.useradmin/.project
index 71e60b0..b57396d 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/.project
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/.project
@@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.webide.server.useradmin/META-INF/MANIFEST.MF
index a444a32..d6b48da 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/META-INF/MANIFEST.MF
@@ -16,3 +16,4 @@ Require-Bundle: org.eclipse.e4.webide.server.servlets;bundle-version="0.1.0",
org.json;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.6.100",
org.eclipse.e4.webide.server;bundle-version="0.1.0"
+Service-Component: OSGI-INF/component.xml
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/OSGI-INF/component.xml b/bundles/org.eclipse.e4.webide.server.useradmin/OSGI-INF/component.xml
new file mode 100644
index 0000000..b0e3954
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/OSGI-INF/component.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="org.eclipse.e4.webide.server.useradmin">
+ <implementation class="org.eclipse.e4.webide.server.useradmin.EclipseWebUserAdminRegistry"/>
+ <reference bind="setUserAdmin" cardinality="1..n" interface="org.osgi.service.useradmin.UserAdmin" name="EclipseWebUserAdmin" policy="dynamic" unbind="unsetUserAdmin"/>
+ <service>
+ <provide interface="org.eclipse.e4.webide.server.useradmin.IEclipseWebUserAdminRegistry"/>
+ </service>
+</scr:component>
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/build.properties b/bundles/org.eclipse.e4.webide.server.useradmin/build.properties
index e65f70a..e04a3bf 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/build.properties
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/build.properties
@@ -1,16 +1,7 @@
-###############################################################################
-# Copyright (c) 2010 IBM Corporation and others.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
bin.includes = META-INF/,\
.,\
- static/
+ static/,\
+ OSGI-INF/component.xml
+source.. = src/
src.includes = static/
+output.. = bin/
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdmin.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdmin.java
index bd4462b..fd78c52 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdmin.java
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdmin.java
@@ -33,6 +33,8 @@ public abstract class EclipseWebUserAdmin implements UserAdmin {
public org.eclipse.e4.webide.server.useradmin.User createUser(User newUser) {
throw new UnsupportedOperationException();
}
+
+ public abstract String getStoreName();
/**
* Indicates if users' store used by useradmin allows to create new users.
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdminRegistry.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdminRegistry.java
new file mode 100644
index 0000000..118fc88
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/EclipseWebUserAdminRegistry.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.webide.server.useradmin;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.osgi.service.useradmin.UserAdmin;
+
+public class EclipseWebUserAdminRegistry implements IEclipseWebUserAdminRegistry {
+
+ private Map<String, EclipseWebUserAdmin> userStores = new HashMap<String, EclipseWebUserAdmin>();
+ private EclipseWebUserAdmin defaultUserAdmin;
+ private static IEclipseWebUserAdminRegistry singleton;
+
+ public static IEclipseWebUserAdminRegistry getDefault() {
+ return singleton;
+ }
+
+ public void activate() {
+ singleton = this;
+ }
+
+ public void deactivate() {
+ singleton = null;
+ }
+
+ /**
+ * returns name of UserAdmins registered.
+ */
+ public Set<String> getSupportedUserStores() {
+ return userStores.keySet();
+ }
+
+ public void setUserAdmin(UserAdmin userAdmin) {
+ if (userAdmin instanceof EclipseWebUserAdmin) {
+ EclipseWebUserAdmin eclipseWebUserAdmin = (EclipseWebUserAdmin) userAdmin;
+ userStores.put(eclipseWebUserAdmin.getStoreName(), eclipseWebUserAdmin);
+ if (defaultUserAdmin == null || eclipseWebUsrAdminName.equals(eclipseWebUserAdmin.getStoreName())) {
+ defaultUserAdmin = eclipseWebUserAdmin;
+ }
+ }
+ }
+
+ public void unsetUserAdmin(UserAdmin userAdmin) {
+ if (userAdmin instanceof EclipseWebUserAdmin) {
+ EclipseWebUserAdmin eclipseWebUserAdmin = (EclipseWebUserAdmin) userAdmin;
+ userStores.remove(eclipseWebUserAdmin.getStoreName());
+ if (userAdmin.equals(defaultUserAdmin)) {
+ defaultUserAdmin = userStores.values().iterator().next();
+ }
+ }
+
+ }
+
+ @Override
+ public EclipseWebUserAdmin getUserStore(String storeName) {
+ return userStores.get(storeName);
+ }
+
+ @Override
+ public EclipseWebUserAdmin getUserStore() {
+ return defaultUserAdmin;
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/IEclipseWebUserAdminRegistry.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/IEclipseWebUserAdminRegistry.java
new file mode 100644
index 0000000..859b6a8
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/IEclipseWebUserAdminRegistry.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.webide.server.useradmin;
+
+import java.util.Set;
+
+/**
+ * Stores available {@link EclipseWebUserAdmin}s used for authentication.
+ * If a new {@link EclipseWebUserAdmin} service is deployed it is automatically
+ * registered and may be used for authentication.
+ *
+ */
+public interface IEclipseWebUserAdminRegistry {
+
+ /**
+ * If an {@link EclipseWebUserAdmin} of this name exists it will be returned as default by {@link #getUserStore()}
+ */
+ public static String eclipseWebUsrAdminName = "EclipseWeb";
+
+ /**
+ * Lists User stores supported by this instance of Eclipse Web.
+ * <br>Result may be used to obtain {@link EclipseWebUserAdmin} by {@link #getUserStore(String)}.
+ * @return
+ */
+ public Set<String> getSupportedUserStores();
+
+ /**
+ * Returns {@link EclipseWebUserAdmin} handling store of a given name
+ * @param storeName
+ * @return
+ * @throws UnsupportedUserStoreException if there is no {@link EclipseWebUserAdmin} service deployed with given name
+ *
+ * @see EclipseWebUserAdmin#getStoreName()
+ */
+ public EclipseWebUserAdmin getUserStore(String storeName) throws UnsupportedUserStoreException;
+
+ /**
+ * Returns {@link EclipseWebUserAdmin} handling default store.<br>
+ * If there is only one {@link EclipseWebUserAdmin} service available it will be this service.
+ * If there are more than one {@link EclipseWebUserAdmin} services available the first to be
+ * registered is returned or the service having {@link #eclipseWebUsrAdminName} name.
+ * @return
+ */
+ public EclipseWebUserAdmin getUserStore();
+
+}
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UnsupportedUserStoreException.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UnsupportedUserStoreException.java
new file mode 100644
index 0000000..56bcccb
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UnsupportedUserStoreException.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.webide.server.useradmin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Exception thrown when requested {@link EclipseWebUserAdmin} is not registered.
+ *
+ */
+public class UnsupportedUserStoreException extends CoreException {
+
+ public UnsupportedUserStoreException(String storeName) {
+ super(new Status(IStatus.ERROR, UserAdminActivator.PI_USERADMIN, "Given user store is not found: " + storeName));
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -269798742696785135L;
+
+}
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UserAdminActivator.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UserAdminActivator.java
index 85b37ae..acef54c 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UserAdminActivator.java
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/UserAdminActivator.java
@@ -16,7 +16,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
-import org.osgi.service.useradmin.UserAdmin;
import org.osgi.util.tracker.ServiceTracker;
public class UserAdminActivator implements BundleActivator {
@@ -37,7 +36,6 @@ public class UserAdminActivator implements BundleActivator {
return singleton;
}
- private ServiceTracker<UserAdmin, UserAdmin> userAdminServiceTracker;
private ServiceTracker<IAuthenticationService, IAuthenticationService> authServiceTracker;
/*
@@ -51,9 +49,6 @@ public class UserAdminActivator implements BundleActivator {
singleton = this;
this.bundleContext = bundleContext;
- userAdminServiceTracker = new ServiceTracker<UserAdmin, UserAdmin>(bundleContext, UserAdmin.class, null);
- userAdminServiceTracker.open();
-
Filter authFilter = FrameworkUtil.createFilter("(&(" + Constants.OBJECTCLASS + "=" + IAuthenticationService.class.getName() + ")(configured=true))");
authServiceTracker = new ServiceTracker<IAuthenticationService, IAuthenticationService>(bundleContext, authFilter, null);
@@ -72,17 +67,9 @@ public class UserAdminActivator implements BundleActivator {
authServiceTracker = null;
}
- if (userAdminServiceTracker != null) {
- userAdminServiceTracker.close();
- userAdminServiceTracker = null;
- }
this.bundleContext = null;
}
- public UserAdmin getUserAdminService() {
- return userAdminServiceTracker.getService();
- }
-
public IAuthenticationService getAuthenticationService() {
return authServiceTracker.getService();
}
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/AdminFilter.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/AdminFilter.java
index 15e9a34..881001f 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/AdminFilter.java
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/AdminFilter.java
@@ -21,6 +21,7 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.e4.webide.server.useradmin.EclipseWebUserAdminRegistry;
import org.eclipse.e4.webide.server.useradmin.UserAdminActivator;
import org.osgi.service.useradmin.Authorization;
import org.osgi.service.useradmin.UserAdmin;
@@ -52,7 +53,8 @@ public class AdminFilter implements Filter {
// TODO: We need a better way to get the authentication service that is configured
String user = UserAdminActivator.getDefault().getAuthenticationService().authenticateUser(httpRequest, httpResponse, null);
- UserAdmin userAdmin = UserAdminActivator.getDefault().getUserAdminService();
+ UserAdmin userAdmin;
+ userAdmin = EclipseWebUserAdminRegistry.getDefault().getUserStore();
Authorization authorization = userAdmin.getAuthorization(userAdmin.getUser("login", user));
if (authorization.hasRole(ADMIN_ROLE)) {
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/UsersAdminServlet.java b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/UsersAdminServlet.java
index 1245211..a2646b3 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/UsersAdminServlet.java
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/src/org/eclipse/e4/webide/server/useradmin/servlets/UsersAdminServlet.java
@@ -29,6 +29,8 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.e4.webide.server.servlets.EclipseWebServlet;
import org.eclipse.e4.webide.server.useradmin.EclipseWebUserAdmin;
+import org.eclipse.e4.webide.server.useradmin.EclipseWebUserAdminRegistry;
+import org.eclipse.e4.webide.server.useradmin.UnsupportedUserStoreException;
import org.eclipse.e4.webide.server.useradmin.User;
import org.eclipse.e4.webide.server.useradmin.UserAdminActivator;
import org.json.JSONException;
@@ -87,8 +89,7 @@ public class UsersAdminServlet extends EclipseWebServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String pathInfo = req.getPathInfo();
if (pathInfo == null || "/".equals(pathInfo)) {
-
- String createError = createUser(req.getParameter("login"), req.getParameter("name"), req.getParameter("email"), req.getParameter("workspace"), req.getParameter("password"), req.getParameter("roles"));
+ String createError = createUser(req.getParameter("store"), req.getParameter("login"), req.getParameter("name"), req.getParameter("email"), req.getParameter("workspace"), req.getParameter("password"), req.getParameter("roles"));
if (createError != null) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, createError);
@@ -105,7 +106,7 @@ public class UsersAdminServlet extends EclipseWebServlet {
displayCreateUserForm(req, resp, errors);
return;
}
- String createError = createUser(req.getParameter("login"), req.getParameter("name"), req.getParameter("email"), req.getParameter("workspace"), req.getParameter("password"), req.getParameter("roles"));
+ String createError = createUser(req.getParameter("store"), req.getParameter("login"), req.getParameter("name"), req.getParameter("email"), req.getParameter("workspace"), req.getParameter("password"), req.getParameter("roles"));
if (createError != null) {
List<String> errors = new ArrayList<String>();
errors.add(createError);
@@ -122,17 +123,24 @@ public class UsersAdminServlet extends EclipseWebServlet {
// Redirecting to login page only for plain calls
}
} else {
- RequestDispatcher rd = getServletContext().getRequestDispatcher("/login?redirect=" + req.getParameter("redirect"));
+ RequestDispatcher rd = getServletContext().getRequestDispatcher("/login/form?redirect=" + req.getParameter("redirect"));
rd.forward(req, resp);
+ return;
}
}
}
- private String createUser(String login, String name, String email, String workspace, String password, String roles) {
+ private String createUser(String userStore, String login, String name, String email, String workspace, String password, String roles) {
if (login == null || login.length() == 0) {
return "User login is required";
}
- if (getUserAdmin().getUser("login", login) != null) {
+ EclipseWebUserAdmin userAdmin;
+ try {
+ userAdmin = (userStore == null || "".equals(userStore)) ? getUserAdmin() : getUserAdmin(userStore);
+ } catch (UnsupportedUserStoreException e) {
+ return "User store is not available: " + userStore;
+ }
+ if (userAdmin.getUser("login", login) != null) {
return "User " + login + " already exists";
}
User newUser = new User(login, name == null ? "" : name, password == null ? "" : password);
@@ -140,10 +148,10 @@ public class UsersAdminServlet extends EclipseWebServlet {
StringTokenizer tokenizer = new StringTokenizer(roles, ",");
while (tokenizer.hasMoreTokens()) {
String role = tokenizer.nextToken();
- newUser.addRole(getUserAdmin().getRole(role));
+ newUser.addRole(userAdmin.getRole(role));
}
}
- if (getUserAdmin().createUser(newUser) == null) {
+ if (userAdmin.createUser(newUser) == null) {
return "User could not be created";
}
return null;
@@ -173,7 +181,14 @@ public class UsersAdminServlet extends EclipseWebServlet {
} else if (pathString.startsWith("/")) {
String login = pathString.substring(1);
- User user = (User) getUserAdmin().getUser("login", login);
+ EclipseWebUserAdmin userAdmin;
+ try {
+ userAdmin = req.getParameter("store") == null ? getUserAdmin() : getUserAdmin(req.getParameter("store"));
+ } catch (UnsupportedUserStoreException e) {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "User store not be found: " + req.getParameter("store"));
+ return;
+ }
+ User user = (User) userAdmin.getUser("login", login);
if (user == null) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "User could not be found");
return;
@@ -194,11 +209,11 @@ public class UsersAdminServlet extends EclipseWebServlet {
StringTokenizer tokenizer = new StringTokenizer(roles, ",");
while (tokenizer.hasMoreTokens()) {
String role = tokenizer.nextToken();
- user.addRole(getUserAdmin().getRole(role));
+ user.addRole(userAdmin.getRole(role));
}
}
}
- getUserAdmin().updateUser(login, user);
+ userAdmin.updateUser(login, user);
}
}
@@ -223,15 +238,26 @@ public class UsersAdminServlet extends EclipseWebServlet {
}
} else if (pathString.startsWith("/")) {
String login = pathString.substring(1);
- if (getUserAdmin().deleteUser((User) getUserAdmin().getUser("login", login)) == false) {
+ EclipseWebUserAdmin userAdmin;
+ try {
+ userAdmin = req.getParameter("store") == null ? getUserAdmin() : getUserAdmin(req.getParameter("store"));
+ } catch (UnsupportedUserStoreException e) {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "User store could not be found: " + req.getParameter("store"));
+ return;
+ }
+ if (userAdmin.deleteUser((User) userAdmin.getUser("login", login)) == false) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "User could not be found");
}
}
}
+ private EclipseWebUserAdmin getUserAdmin(String userStoreId) throws UnsupportedUserStoreException {
+ return EclipseWebUserAdminRegistry.getDefault().getUserStore(userStoreId);
+ }
+
private EclipseWebUserAdmin getUserAdmin() {
- return (EclipseWebUserAdmin) UserAdminActivator.getDefault().getUserAdminService();
+ return EclipseWebUserAdminRegistry.getDefault().getUserStore();
}
private JSONObject formJson(User user) throws JSONException {
@@ -298,6 +324,10 @@ public class UsersAdminServlet extends EclipseWebServlet {
writer.print("?redirect=");
writer.print(req.getParameter("redirect"));
}
+ if (req.getParameter("store") != null && !req.getParameter("store").equals("")) {
+ writer.print("&store=");
+ writer.print(req.getParameter("store"));
+ }
writer.println("\">");
writer.println(addErrors(getFileContents("static/createUser.html"), errors));
@@ -324,7 +354,10 @@ public class UsersAdminServlet extends EclipseWebServlet {
writer.print("divf.innerHTML='");
writer.print(loadJSResponse(req));
if (req.getParameter("onUserCreated") != null && req.getParameter("onUserCreated").length() > 0) {
- writer.print("userCreatedNotifier=" + req.getParameter("onUserCreated"));
+ writer.println("userCreatedNotifier=" + req.getParameter("onUserCreated") + ";");
+ }
+ if (req.getParameter("store") != null && req.getParameter("store").length() > 0) {
+ writer.println("userStore='" + req.getParameter("store") + "';");
}
writer.flush();
}
diff --git a/bundles/org.eclipse.e4.webide.server.useradmin/static/js/xhrCreateUser.js b/bundles/org.eclipse.e4.webide.server.useradmin/static/js/xhrCreateUser.js
index 3d34e1c..7d7554d 100644
--- a/bundles/org.eclipse.e4.webide.server.useradmin/static/js/xhrCreateUser.js
+++ b/bundles/org.eclipse.e4.webide.server.useradmin/static/js/xhrCreateUser.js
@@ -23,7 +23,8 @@ function closeCreateUserForm() {
dojo.byId('createUserErrorsList').innerHTML = ''
}
-var userCreatedNotifier = function(userLogin, userPassword) {};
+var userCreatedNotifier = function(userLogin, userPassword, userStore) {};
+var userStore;
function confirmCreateUser() {
var userLogin = dojo.byId("loginCreateUser").value;
@@ -36,12 +37,13 @@ function confirmCreateUser() {
content : {
login : userLogin,
password : userPassword,
+ store: userStore,
passwordConf : dojo.byId("passwordConfCreateUser").value
},
handleAs : "text",
timeout : 15000,
load : function(response, ioArgs) {
- userCreatedNotifier(userLogin, userPassword);
+ userCreatedNotifier(userLogin, userPassword, userStore);
dojo.byId('createUserForm').style.visibility = 'hidden';
dojo.byId('createUserFormMask').style.visibility = 'hidden';
dojo.byId('createUserErrorsList').innerHTML = '';
diff --git a/bundles/org.eclipse.e4.webide.server/.gitignore b/bundles/org.eclipse.e4.webide.server/.gitignore
new file mode 100644
index 0000000..c5e82d7
--- /dev/null
+++ b/bundles/org.eclipse.e4.webide.server/.gitignore
@@ -0,0 +1 @@
+bin \ No newline at end of file