--- /dev/null
+argeo.osgi.start=\
+org.springframework.osgi.extender,\
+org.argeo.server.ads.server,\
+org.argeo.node.repo.jackrabbit,\
+org.argeo.security.manager.ldap,\
+org.argeo.security.services,\
+com.springsource.javax.servlet,\
+org.argeo.security.equinox,\
+org.eclipse.core.runtime,\
+org.eclipse.equinox.common,\
+org.eclipse.equinox.launcher,\
+org.springframework.osgi.web.extender,\
+org.argeo.dep.osgi.catalina.start,\
+org.argeo.jackrabbit.webapp,\
+org.eclipse.equinox.http.registry,\
+org.argeo.server.osgi.webapp,\
+org.argeo.jcr.ui.explorer,\
+
+org.argeo.security.ui.initialPerspective=org.argeo.jcr.ui.explorer.perspective
+
+log4j.configuration=file:../../log4j.properties
--- /dev/null
+UNIX {
+ org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient
+ extensionId="org.argeo.security.equinox.unixLoginModule";
+};
+
+SPRING {
+ org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient
+ extensionId="org.argeo.security.equinox.springLoginModule";
+};
+
+SPRING_SECURITY_CONTEXT {
+ org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient
+ extensionId="org.argeo.security.equinox.springSecurityContextLoginModule";
+};
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.rap.ui.entrypoint">
+ <entrypoint
+ class="org.argeo.security.ui.rap.SecureEntryPoint"
+ id="org.argeo.security.ui.rap.secureEntryPoint"
+ parameter="secureWebUi">
+ </entrypoint>
+ </extension>
+
+</plugin>
<version>${version.maven-bundle-plugin}</version>
<configuration>
<instructions>
- <!-- <Bundle-Activator>org.argeo.security.ui.rcp.SecureApplicationActivator</Bundle-Activator> -->
+ <Bundle-Activator>org.argeo.security.ui.rap.SecureRapActivator</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Require-Bundle>org.eclipse.rap.ui,org.eclipse.core.runtime</Require-Bundle>
<Import-Package>*</Import-Package>
--- /dev/null
+package org.argeo.security.ui.rap;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+
+public class RapSecureWorkbenchWindowAdvisor extends
+ SecureWorkbenchWindowAdvisor {
+ public RapSecureWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ super(configurer);
+ }
+
+ @Override
+ public ActionBarAdvisor createActionBarAdvisor(
+ IActionBarConfigurer configurer) {
+ return new SecureActionBarAdvisor(configurer, false);
+ }
+
+ public void preWindowOpen() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ configurer.setShowCoolBar(true);
+ configurer.setShowMenuBar(true);
+ configurer.setShowStatusLine(false);
+ configurer.setShowPerspectiveBar(true);
+ configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
+ // Full screen, see
+ // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
+ configurer.setShellStyle(SWT.NONE);
+ Rectangle bounds = Display.getDefault().getBounds();
+ configurer.setInitialSize(new Point(bounds.width, bounds.height));
+ }
+
+}
--- /dev/null
+package org.argeo.security.ui.rap;
+
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.ICoolBarManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+
+public class SecureActionBarAdvisor extends ActionBarAdvisor {
+ private IWorkbenchAction exitAction;
+ private IWorkbenchAction openPerspectiveDialogAction;
+ private IWorkbenchAction showViewMenuAction;
+ private IWorkbenchAction preferences;
+ private IWorkbenchAction saveAction;
+ private IWorkbenchAction saveAllAction;
+ private IWorkbenchAction closeAllAction;
+
+ // private final Boolean isRcp;
+
+ public SecureActionBarAdvisor(IActionBarConfigurer configurer, Boolean isRcp) {
+ super(configurer);
+ // this.isRcp = isRcp;
+ }
+
+ protected void makeActions(IWorkbenchWindow window) {
+ preferences = ActionFactory.PREFERENCES.create(window);
+ register(preferences);
+ openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
+ .create(window);
+ register(openPerspectiveDialogAction);
+ showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
+ register(showViewMenuAction);
+
+ exitAction = ActionFactory.QUIT.create(window);
+ register(exitAction);
+
+ // Save semantiocs
+ saveAction = ActionFactory.SAVE.create(window);
+ register(saveAction);
+ saveAllAction = ActionFactory.SAVE_ALL.create(window);
+ register(saveAllAction);
+ closeAllAction = ActionFactory.CLOSE_ALL.create(window);
+ register(closeAllAction);
+
+ }
+
+ protected void fillMenuBar(IMenuManager menuBar) {
+ MenuManager fileMenu = new MenuManager("&File",
+ IWorkbenchActionConstants.M_FILE);
+ MenuManager editMenu = new MenuManager("&Edit",
+ IWorkbenchActionConstants.M_EDIT);
+ MenuManager windowMenu = new MenuManager("&Window",
+ IWorkbenchActionConstants.M_WINDOW);
+
+ menuBar.add(fileMenu);
+ menuBar.add(editMenu);
+ menuBar.add(windowMenu);
+ // Add a group marker indicating where action set menus will appear.
+ menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ // File
+ fileMenu.add(saveAction);
+ fileMenu.add(saveAllAction);
+ fileMenu.add(closeAllAction);
+ fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ fileMenu.add(new Separator());
+ fileMenu.add(exitAction);
+
+ // Edit
+ editMenu.add(preferences);
+
+ // Window
+ windowMenu.add(openPerspectiveDialogAction);
+ windowMenu.add(showViewMenuAction);
+ }
+
+ @Override
+ protected void fillCoolBar(ICoolBarManager coolBar) {
+ IToolBarManager saveToolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
+ saveToolbar.add(saveAction);
+ saveToolbar.add(saveAllAction);
+ coolBar.add(saveToolbar);
+ }
+
+}
--- /dev/null
+package org.argeo.security.ui.rap;
+
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+
+import org.argeo.eclipse.ui.dialogs.Error;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.rwt.lifecycle.IEntryPoint;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+public class SecureEntryPoint implements IEntryPoint {
+
+ @Override
+ public int createUI() {
+ Integer returnCode = null;
+ Display display = PlatformUI.createDisplay();
+ try {
+ Subject subject = null;
+ Boolean retry = true;
+ while (retry) {
+ try {
+ SecureRapActivator.getLoginContext().login();
+ subject = SecureRapActivator.getLoginContext()
+ .getSubject();
+ retry = false;
+ } catch (LoginException e) {
+ Error.show("Cannot login", e);
+ retry = true;
+ } catch (Exception e) {
+ Error.show("Unexpected exception while trying to login", e);
+ retry = false;
+ }
+ }
+
+ if (subject == null) {
+ // IStatus status = new Status(IStatus.ERROR,
+ // "org.argeo.security.application", "Login is mandatory",
+ // loginException);
+ // ErrorDialog.openError(null, "Error", "Shutdown...", status);
+ // return status.getSeverity();
+
+ // TODO: log as anonymous
+ }
+
+ if (subject != null) {
+ returnCode = (Integer) Subject.doAs(subject,
+ getRunAction(display));
+ SecureRapActivator.getLoginContext().logout();
+ return processReturnCode(returnCode);
+ } else {
+ return -1;
+ }
+ } catch (Exception e) {
+ // e.printStackTrace();
+ IStatus status = new Status(IStatus.ERROR,
+ "org.argeo.security.rcp", "Login failed", e);
+ ErrorDialog.openError(null, "Error", "Shutdown...", status);
+ return returnCode;
+ } finally {
+ display.dispose();
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ private PrivilegedAction getRunAction(final Display display) {
+ return new PrivilegedAction() {
+
+ public Object run() {
+ int result = createAndRunWorkbench(display);
+ return new Integer(result);
+ }
+ };
+ }
+
+ protected Integer createAndRunWorkbench(Display display) {
+ return PlatformUI.createAndRunWorkbench(display,
+ createWorkbenchAdvisor());
+ }
+
+ protected Integer processReturnCode(Integer returnCode) {
+ return returnCode;
+ }
+
+ protected WorkbenchAdvisor createWorkbenchAdvisor() {
+ return new SecureWorkbenchAdvisor() {
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+ IWorkbenchWindowConfigurer configurer) {
+ return new RapSecureWorkbenchWindowAdvisor(configurer);
+ }
+
+ };
+ }
+
+}
--- /dev/null
+package org.argeo.security.ui.rap;
+
+import java.net.URL;
+
+import org.argeo.ArgeoException;
+import org.eclipse.equinox.security.auth.ILoginContext;
+import org.eclipse.equinox.security.auth.LoginContextFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class SecureRapActivator implements BundleActivator {
+
+ public final static String CONTEXT_SPRING = "SPRING";
+ private static final String JAAS_CONFIG_FILE = "/META-INF/jaas_default.txt";
+
+ private static ILoginContext loginContext = null;
+
+ public void start(BundleContext bundleContext) throws Exception {
+ URL configUrl = bundleContext.getBundle().getEntry(JAAS_CONFIG_FILE);
+ loginContext = LoginContextFactory.createContext(CONTEXT_SPRING,
+ configUrl);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ }
+
+ static ILoginContext getLoginContext() {
+ if (loginContext == null)
+ throw new ArgeoException(
+ "No Equinox login context available, check your configuration");
+ return loginContext;
+ }
+}
--- /dev/null
+package org.argeo.security.ui.rap;
+
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+public class SecureWorkbenchAdvisor extends WorkbenchAdvisor {
+
+ static final String DEFAULT_PERSPECTIVE_ID = "org.argeo.security.ui.adminSecurityPerspective"; //$NON-NLS-1$
+
+ public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
+ private String initialPerspective = System.getProperty(
+ INITIAL_PERSPECTIVE_PROPERTY, DEFAULT_PERSPECTIVE_ID);
+
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+ IWorkbenchWindowConfigurer configurer) {
+ return new SecureWorkbenchWindowAdvisor(configurer);
+ }
+
+ public String getInitialWindowPerspectiveId() {
+ return initialPerspective;
+ }
+}
--- /dev/null
+package org.argeo.security.ui.rap;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+public class SecureWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
+
+ public SecureWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ super(configurer);
+ }
+
+ public ActionBarAdvisor createActionBarAdvisor(
+ IActionBarConfigurer configurer) {
+ return new SecureActionBarAdvisor(configurer, true);
+ }
+
+ public void preWindowOpen() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ configurer.setInitialSize(new Point(1200, 900));
+ configurer.setShowCoolBar(true);
+ configurer.setShowMenuBar(true);
+ configurer.setShowStatusLine(false);
+
+ configurer.setShowPerspectiveBar(true);
+ configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
+
+ }
+
+}
name="preferenceCustomization"
value="plugin_customization.ini"/>
</product>
- </extension>
-
- <extension
- id="org.argeo.security.webui.product"
- point="org.eclipse.core.runtime.products">
- <product
- name="ArgeoProduct" application="org.argeo.security.ui.application.secureWebUi">
- <property
- name="appName"
- value="Secure Web UI">
- </property>
- <property
- name="preferenceCustomization"
- value="plugin_customization.ini"/>
- </product>
- </extension>
-
+ </extension>
<extension
id="secureUi"
</run>
</application>
</extension>
- <extension
- id="secureWebUi"
- name="Argeo Secure Web UI"
- point="org.eclipse.core.runtime.applications">
- <application cardinality="singleton-global"
- thread="main"
- visible="true">
- <run
- class="org.argeo.security.ui.rcp.SecureRap">
- </run>
- </application>
- </extension>
- <extension
- id="secureWebUi2"
- name="Argeo Secure Web UI"
- point="org.eclipse.core.runtime.applications">
- <application cardinality="singleton-global"
- thread="main"
- visible="true">
- <run
- class="org.argeo.security.ui.rcp.SecureRap">
- </run>
- </application>
- </extension>
-
</plugin>
+++ /dev/null
-package org.argeo.security.ui.rcp;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.application.ActionBarAdvisor;
-import org.eclipse.ui.application.IActionBarConfigurer;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-
-public class RapSecureWorkbenchWindowAdvisor extends
- SecureWorkbenchWindowAdvisor {
- public RapSecureWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
- super(configurer);
- }
-
- @Override
- public ActionBarAdvisor createActionBarAdvisor(
- IActionBarConfigurer configurer) {
- return new SecureActionBarAdvisor(configurer, false);
- }
-
- public void preWindowOpen() {
- IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
- configurer.setShowCoolBar(true);
- configurer.setShowMenuBar(true);
- configurer.setShowStatusLine(false);
- configurer.setShowPerspectiveBar(true);
- configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
- // Full screen, see
- // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
- configurer.setShellStyle(SWT.NONE);
- Rectangle bounds = Display.getDefault().getBounds();
- configurer.setInitialSize(new Point(bounds.width, bounds.height));
- }
-
-}
+++ /dev/null
-package org.argeo.security.ui.rcp;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchAdvisor;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/** Generic secure application for RAP. */
-public class SecureRap extends AbstractSecureApplication {
-
- @Override
- protected WorkbenchAdvisor createWorkbenchAdvisor() {
- return new SecureWorkbenchAdvisor() {
- public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
- IWorkbenchWindowConfigurer configurer) {
- return new RapSecureWorkbenchWindowAdvisor(configurer);
- }
-
- };
- }
-
- public void stop() {
- final IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench == null)
- return;
- final Display display = workbench.getDisplay();
- display.syncExec(new Runnable() {
-
- public void run() {
- if (!display.isDisposed())
- workbench.close();
- }
- });
- }
-
-}