Rename RAP base package to be homogeneous
authorBruno Sinou <bsinou@argeo.org>
Wed, 30 Nov 2016 09:39:28 +0000 (09:39 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 30 Nov 2016 09:39:28 +0000 (09:39 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@9337 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

14 files changed:
org.argeo.cms.ui.workbench.rap/bnd.bnd
org.argeo.cms.ui.workbench.rap/plugin.xml
org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/AnonymousEntryPoint.java [new file with mode: 0644]
org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapActionBarAdvisor.java [new file with mode: 0644]
org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWindowAdvisor.java [new file with mode: 0644]
org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchAdvisor.java [new file with mode: 0644]
org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchLogin.java [new file with mode: 0644]
org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/SecureRapActivator.java [new file with mode: 0644]
org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/AnonymousEntryPoint.java [deleted file]
org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java [deleted file]
org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWindowAdvisor.java [deleted file]
org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWorkbenchAdvisor.java [deleted file]
org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWorkbenchLogin.java [deleted file]
org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/SecureRapActivator.java [deleted file]

index 96534754abf8b8f0484f2e6a997437c7187a87b9..f9e7f66df478fd140956ee6a6eba068ced1034bb 100644 (file)
@@ -1,5 +1,5 @@
 Bundle-SymbolicName: org.argeo.cms.ui.workbench.rap;singleton:=true
-Bundle-Activator: org.argeo.security.ui.rap.SecureRapActivator
+Bundle-Activator: org.argeo.cms.ui.workbench.rap.SecureRapActivator
 Bundle-ActivationPolicy: lazy
 
 Require-Bundle: org.eclipse.rap.ui,org.eclipse.core.runtime
index 4d81d83cfe7fca84d822e9842613876f13b0fbde..adb4a6ec5b9d67741562d246e488a8662e112ca4 100644 (file)
@@ -5,13 +5,13 @@
          point="org.eclipse.rap.ui.entrypoint">
       <entrypoint
             id="org.argeo.cms.ui.workbench.rap.secureEntryPoint"
-            class="org.argeo.security.ui.rap.RapWorkbenchLogin"
+            class="org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin"
             path="/node"
             brandingId="org.argeo.cms.ui.workbench.rap.defaultBranding">
       </entrypoint>
       <entrypoint
             id="org.argeo.cms.ui.workbench.rap.anonymousEntryPoint"
-            class="org.argeo.security.ui.rap.AnonymousEntryPoint"
+            class="org.argeo.cms.ui.workbench.rap.AnonymousEntryPoint"
             path="/public"
             brandingId="org.argeo.cms.ui.workbench.rap.defaultBranding">
       </entrypoint>
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/AnonymousEntryPoint.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/AnonymousEntryPoint.java
new file mode 100644 (file)
index 0000000..00399b9
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.cms.ui.workbench.rap;
+
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.CmsException;
+import org.argeo.node.NodeConstants;
+import org.eclipse.rap.rwt.RWT;
+import org.eclipse.rap.rwt.application.EntryPoint;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * RAP entry point which authenticates the subject as anonymous, for public
+ * unauthenticated access.
+ */
+public class AnonymousEntryPoint implements EntryPoint {
+       private final static Log log = LogFactory.getLog(AnonymousEntryPoint.class);
+
+       /**
+        * How many seconds to wait before invalidating the session if the user has
+        * not yet logged in.
+        */
+       private Integer sessionTimeout = 5 * 60;
+
+       @Override
+       public int createUI() {
+               RWT.getRequest().getSession().setMaxInactiveInterval(sessionTimeout);
+
+               // if (log.isDebugEnabled())
+               // log.debug("Anonymous THREAD=" + Thread.currentThread().getId()
+               // + ", sessionStore=" + RWT.getSessionStore().getId());
+
+               final Display display = PlatformUI.createDisplay();
+               Subject subject = new Subject();
+
+               final LoginContext loginContext;
+               try {
+                       loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER,
+                                       subject);
+                       loginContext.login();
+               } catch (LoginException e1) {
+                       throw new CmsException("Cannot initialize login context", e1);
+               }
+
+               // identify after successful login
+               if (log.isDebugEnabled())
+                       log.debug("Authenticated " + subject);
+               final String username = subject.getPrincipals().iterator().next()
+                               .getName();
+
+               // Logout callback when the display is disposed
+               display.disposeExec(new Runnable() {
+                       public void run() {
+                               log.debug("Display disposed");
+                               logout(loginContext, username);
+                       }
+               });
+
+               //
+               // RUN THE WORKBENCH
+               //
+               Integer returnCode = null;
+               try {
+                       returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
+                               public Integer run() {
+                                       RapWorkbenchAdvisor workbenchAdvisor = new RapWorkbenchAdvisor(
+                                                       null);
+                                       int result = PlatformUI.createAndRunWorkbench(display,
+                                                       workbenchAdvisor);
+                                       return new Integer(result);
+                               }
+                       });
+                       logout(loginContext, username);
+                       if (log.isTraceEnabled())
+                               log.trace("Return code " + returnCode);
+               } finally {
+                       display.dispose();
+               }
+               return 1;
+       }
+
+       private void logout(LoginContext loginContext, String username) {
+               try {
+                       loginContext.logout();
+                       log.info("Logged out " + (username != null ? username : "")
+                                       + " (THREAD=" + Thread.currentThread().getId() + ")");
+               } catch (LoginException e) {
+                       log.error("Erorr when logging out", e);
+               }
+       }
+}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapActionBarAdvisor.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapActionBarAdvisor.java
new file mode 100644 (file)
index 0000000..c18a9a7
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.cms.ui.workbench.rap;
+
+import org.argeo.cms.auth.CurrentUser;
+import org.argeo.cms.ui.workbench.commands.OpenHomePerspective;
+import org.eclipse.core.commands.Category;
+import org.eclipse.core.commands.Command;
+import org.eclipse.jface.action.ICoolBarManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+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;
+import org.eclipse.ui.commands.ICommandService;
+
+/** Eclipse rap specific action bar advisor */
+public class RapActionBarAdvisor extends ActionBarAdvisor {
+       private final static String ID_BASE = SecureRapActivator.ID;
+       // private final static Log log = LogFactory
+       // .getLog(SecureActionBarAdvisor.class);
+
+       /** Null means anonymous */
+       private String username = null;
+
+       // private IAction logoutAction;
+       // private IWorkbenchAction openPerspectiveDialogAction;
+       // private IWorkbenchAction showViewMenuAction;
+       // private IWorkbenchAction preferences;
+       private IWorkbenchAction saveAction;
+       private IWorkbenchAction saveAllAction;
+
+       // private IWorkbenchAction closeAllAction;
+
+       public RapActionBarAdvisor(IActionBarConfigurer configurer, String username) {
+               super(configurer);
+               this.username = username;
+       }
+
+       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);
+               //
+               // // logout
+               // logoutAction = ActionFactory.QUIT.create(window);
+               // // logoutAction = createLogoutAction();
+               // register(logoutAction);
+               //
+               // Save semantics
+               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(logoutAction);
+               //
+               // // Edit
+               // editMenu.add(preferences);
+               //
+               // // Window
+               // windowMenu.add(openPerspectiveDialogAction);
+               // windowMenu.add(showViewMenuAction);
+       }
+
+       @Override
+       protected void fillCoolBar(ICoolBarManager coolBar) {
+               // Add a command which label is the display name of the current
+               // logged-in user
+               if (username != null) {
+                       ICommandService cmdService = (ICommandService) getActionBarConfigurer()
+                                       .getWindowConfigurer().getWorkbenchConfigurer()
+                                       .getWorkbench().getService(ICommandService.class);
+                       Category userMenus = cmdService.getCategory(ID_BASE + ".userMenus");
+                       if (!userMenus.isDefined())
+                               userMenus.define("User Menus", "User related menus");
+                       Command userMenu = cmdService.getCommand(ID_BASE
+                                       + ".userMenuCommand");
+                       if (userMenu.isDefined())
+                               userMenu.undefine();
+                       userMenu.define(CurrentUser.getDisplayName(), "User menu actions",
+                                       userMenus);
+                       // userMenu.define(username, "User menu actions", userMenus);
+                       
+                       userMenu.setHandler(new OpenHomePerspective());
+
+                       // userToolbar.add(new UserMenuAction());
+                       // coolBar.add(userToolbar);
+               } else {// anonymous
+                       IToolBarManager userToolbar = new ToolBarManager(SWT.FLAT
+                                       | SWT.RIGHT);
+                       // userToolbar.add(logoutAction);
+                       coolBar.add(userToolbar);
+               }
+               // IToolBarManager saveToolbar = new ToolBarManager(SWT.FLAT |
+               // SWT.RIGHT);
+               // saveToolbar.add(saveAction);
+               // saveToolbar.add(saveAllAction);
+               // coolBar.add(saveToolbar);
+       }
+
+       // class UserMenuAction extends Action implements IWorkbenchAction {
+       //
+       // public UserMenuAction() {
+       // super(username, IAction.AS_DROP_DOWN_MENU);
+       // // setMenuCreator(new UserMenu());
+       // }
+       //
+       // @Override
+       // public String getId() {
+       // return "org.argeo.cms.ui.workbench.rap.userMenu";
+       // }
+       //
+       // @Override
+       // public void dispose() {
+       // }
+       //
+       // }
+
+       // class UserMenu implements IMenuCreator {
+       // private Menu menu;
+       //
+       // public Menu getMenu(Control parent) {
+       // Menu menu = new Menu(parent);
+       // addActionToMenu(menu, logoutAction);
+       // return menu;
+       // }
+       //
+       // private void addActionToMenu(Menu menu, IAction action) {
+       // ActionContributionItem item = new ActionContributionItem(action);
+       // item.fill(menu, -1);
+       // }
+       //
+       // public void dispose() {
+       // if (menu != null) {
+       // menu.dispose();
+       // }
+       // }
+       //
+       // public Menu getMenu(Menu parent) {
+       // // Not use
+       // return null;
+       // }
+       //
+       // }
+
+       // protected IAction createLogoutAction() {
+       // Subject subject = Subject.getSubject(AccessController.getContext());
+       // final String username = subject.getPrincipals().iterator().next()
+       // .getName();
+       //
+       // IAction logoutAction = new Action() {
+       // public String getId() {
+       // return SecureRapActivator.ID + ".logoutAction";
+       // }
+       //
+       // public String getText() {
+       // return "Logout " + username;
+       // }
+       //
+       // public void run() {
+       // // try {
+       // // Subject subject = SecureRapActivator.getLoginContext()
+       // // .getSubject();
+       // // String subjectStr = subject.toString();
+       // // subject.getPrincipals().clear();
+       // // SecureRapActivator.getLoginContext().logout();
+       // // log.info(subjectStr + " logged out");
+       // // } catch (LoginException e) {
+       // // log.error("Error when logging out", e);
+       // // }
+       // // SecureEntryPoint.logout(username);
+       // // PlatformUI.getWorkbench().close();
+       // // try {
+       // // RWT.getRequest().getSession().setMaxInactiveInterval(1);
+       // // } catch (Exception e) {
+       // // if (log.isTraceEnabled())
+       // // log.trace("Error when invalidating session", e);
+       // // }
+       // }
+       //
+       // };
+       // return logoutAction;
+       // }
+
+}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWindowAdvisor.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWindowAdvisor.java
new file mode 100644 (file)
index 0000000..60bad09
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.cms.ui.workbench.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.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+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;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+/** Eclipse RAP specific window advisor */
+public class RapWindowAdvisor extends WorkbenchWindowAdvisor {
+
+       private String username;
+
+       public RapWindowAdvisor(IWorkbenchWindowConfigurer configurer,
+                       String username) {
+               super(configurer);
+               this.username = username;
+       }
+
+       @Override
+       public ActionBarAdvisor createActionBarAdvisor(
+                       IActionBarConfigurer configurer) {
+               return new RapActionBarAdvisor(configurer, username);
+       }
+
+       public void preWindowOpen() {
+               IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+               configurer.setShowCoolBar(true);
+               configurer.setShowMenuBar(false);
+               configurer.setShowStatusLine(false);
+               configurer.setShowPerspectiveBar(true);
+               configurer.setTitle("Argeo Web UI"); //$NON-NLS-1$
+               // Full screen, see
+               // http://wiki.eclipse.org/RAP/FAQ#How_to_create_a_fullscreen_application
+               configurer.setShellStyle(SWT.NO_TRIM);
+               Rectangle bounds = Display.getCurrent().getBounds();
+               configurer.setInitialSize(new Point(bounds.width, bounds.height));
+
+               // Handle window resize in Rap 2.1+ see
+               // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417254
+               Display.getCurrent().addListener(SWT.Resize, new Listener() {
+                       private static final long serialVersionUID = 2970912561866704526L;
+
+                       @Override
+                       public void handleEvent(Event event) {
+                               Rectangle bounds = event.display.getBounds();
+                               IWorkbenchWindow iww = getWindowConfigurer().getWindow()
+                                               .getWorkbench().getActiveWorkbenchWindow();
+                               iww.getShell().setBounds(bounds);
+                       }
+               });
+       }
+
+       @Override
+       public void postWindowCreate() {
+               Shell shell = getWindowConfigurer().getWindow().getShell();
+               shell.setMaximized(true);
+       }
+
+       @Override
+       public void postWindowOpen() {
+               String defaultPerspective = getWindowConfigurer()
+                               .getWorkbenchConfigurer().getWorkbench()
+                               .getPerspectiveRegistry().getDefaultPerspective();
+               if (defaultPerspective == null) {
+                       IWorkbenchWindow window = getWindowConfigurer().getWindow();
+                       if (window == null)
+                               return;
+
+                       IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
+                                       .create(window);
+                       openPerspectiveDialogAction.run();
+               }
+       }
+
+}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchAdvisor.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchAdvisor.java
new file mode 100644 (file)
index 0000000..b650dbb
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.cms.ui.workbench.rap;
+
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.application.IWorkbenchConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+/** Eclipse RAP specific workbench advisor */
+public class RapWorkbenchAdvisor extends WorkbenchAdvisor {
+       public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
+       public final static String SAVE_AND_RESTORE_PROPERTY = "org.argeo.security.ui.saveAndRestore";
+
+       private String initialPerspective = System.getProperty(
+                       INITIAL_PERSPECTIVE_PROPERTY, null);
+
+       private String username;
+
+       public RapWorkbenchAdvisor(String username) {
+               this.username = username;
+       }
+
+       @Override
+       public void initialize(IWorkbenchConfigurer configurer) {
+               super.initialize(configurer);
+               Boolean saveAndRestore = Boolean.parseBoolean(System.getProperty(
+                               SAVE_AND_RESTORE_PROPERTY, "false"));
+               configurer.setSaveAndRestore(saveAndRestore);
+       }
+
+       public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+                       IWorkbenchWindowConfigurer configurer) {
+               return new RapWindowAdvisor(configurer, username);
+       }
+
+       public String getInitialWindowPerspectiveId() {
+               if (initialPerspective != null) {
+                       // check whether this user can see the declared perspective
+                       // (typically the perspective won't be listed if this user doesn't
+                       // have the right to see it)
+                       IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
+                                       .getPerspectiveRegistry()
+                                       .findPerspectiveWithId(initialPerspective);
+                       if (pd == null)
+                               return null;
+               }
+               return initialPerspective;
+       }
+}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchLogin.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchLogin.java
new file mode 100644 (file)
index 0000000..a023013
--- /dev/null
@@ -0,0 +1,90 @@
+package org.argeo.cms.ui.workbench.rap;
+
+import java.security.PrivilegedAction;
+import java.util.Locale;
+
+import javax.security.auth.Subject;
+import javax.security.auth.x500.X500Principal;
+
+import org.argeo.cms.CmsMsg;
+import org.argeo.cms.auth.CurrentUser;
+import org.argeo.cms.util.CmsUtils;
+import org.argeo.cms.util.LoginEntryPoint;
+import org.eclipse.rap.rwt.RWT;
+import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+public class RapWorkbenchLogin extends LoginEntryPoint {
+       // private final static Log log =
+       // LogFactory.getLog(RapWorkbenchLogin.class);
+
+       /** Override to provide an application specific workbench advisor */
+       protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(String username) {
+               return new RapWorkbenchAdvisor(username);
+       }
+
+       @Override
+       public int createUI() {
+               JavaScriptExecutor jsExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
+               int returnCode;
+               try {
+                       returnCode = super.createUI();
+               } finally {
+                       // always reload
+                       // TODO optimise?
+                       jsExecutor.execute("location.reload()");
+               }
+               return returnCode;
+       }
+
+       @Override
+       protected int postLogin() {
+               Subject subject = getLoginContext().getSubject();
+               final Display display = Display.getCurrent();
+               if (subject.getPrincipals(X500Principal.class).isEmpty()) {
+                       RWT.getClient().getService(JavaScriptExecutor.class).execute("location.reload()");
+               }
+               //
+               // RUN THE WORKBENCH
+               //
+               Integer returnCode = null;
+               try {
+                       returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
+                               public Integer run() {
+                                       int result = createAndRunWorkbench(display, CurrentUser.getUsername(subject));
+                                       return new Integer(result);
+                               }
+                       });
+                       // explicit workbench closing
+                       logout();
+               } finally {
+                       display.dispose();
+               }
+               return returnCode;
+       }
+
+       protected int createAndRunWorkbench(Display display, String username) {
+               RapWorkbenchAdvisor workbenchAdvisor = createRapWorkbenchAdvisor(username);
+               return PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
+       }
+
+       @Override
+       protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale,
+                       SelectionListener loginSelectionListener) {
+               Button loginButton = new Button(credentialsBlock, SWT.PUSH);
+               loginButton.setText(CmsMsg.login.lead(selectedLocale));
+               loginButton.setLayoutData(CmsUtils.fillWidth());
+               loginButton.addSelectionListener(loginSelectionListener);
+       }
+
+       @Override
+       protected Display createDisplay() {
+               return PlatformUI.createDisplay();
+       }
+
+}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/SecureRapActivator.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/SecureRapActivator.java
new file mode 100644 (file)
index 0000000..74068c2
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.cms.ui.workbench.rap;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/** Configure Equinox login context from the bundle context. */
+public class SecureRapActivator implements BundleActivator {
+       public final static String ID = "org.argeo.cms.ui.workbench.rap";
+
+       private static BundleContext bundleContext;
+
+       public void start(BundleContext bc) throws Exception {
+               bundleContext = bc;
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               bundleContext = null;
+       }
+
+       public static BundleContext getBundleContext() {
+               return bundleContext;
+       }
+}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/AnonymousEntryPoint.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/AnonymousEntryPoint.java
deleted file mode 100644 (file)
index 5ff9e40..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.rap;
-
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.CmsException;
-import org.argeo.node.NodeConstants;
-import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.application.EntryPoint;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * RAP entry point which authenticates the subject as anonymous, for public
- * unauthenticated access.
- */
-public class AnonymousEntryPoint implements EntryPoint {
-       private final static Log log = LogFactory.getLog(AnonymousEntryPoint.class);
-
-       /**
-        * How many seconds to wait before invalidating the session if the user has
-        * not yet logged in.
-        */
-       private Integer sessionTimeout = 5 * 60;
-
-       @Override
-       public int createUI() {
-               RWT.getRequest().getSession().setMaxInactiveInterval(sessionTimeout);
-
-               // if (log.isDebugEnabled())
-               // log.debug("Anonymous THREAD=" + Thread.currentThread().getId()
-               // + ", sessionStore=" + RWT.getSessionStore().getId());
-
-               final Display display = PlatformUI.createDisplay();
-               Subject subject = new Subject();
-
-               final LoginContext loginContext;
-               try {
-                       loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER,
-                                       subject);
-                       loginContext.login();
-               } catch (LoginException e1) {
-                       throw new CmsException("Cannot initialize login context", e1);
-               }
-
-               // identify after successful login
-               if (log.isDebugEnabled())
-                       log.debug("Authenticated " + subject);
-               final String username = subject.getPrincipals().iterator().next()
-                               .getName();
-
-               // Logout callback when the display is disposed
-               display.disposeExec(new Runnable() {
-                       public void run() {
-                               log.debug("Display disposed");
-                               logout(loginContext, username);
-                       }
-               });
-
-               //
-               // RUN THE WORKBENCH
-               //
-               Integer returnCode = null;
-               try {
-                       returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
-                               public Integer run() {
-                                       RapWorkbenchAdvisor workbenchAdvisor = new RapWorkbenchAdvisor(
-                                                       null);
-                                       int result = PlatformUI.createAndRunWorkbench(display,
-                                                       workbenchAdvisor);
-                                       return new Integer(result);
-                               }
-                       });
-                       logout(loginContext, username);
-                       if (log.isTraceEnabled())
-                               log.trace("Return code " + returnCode);
-               } finally {
-                       display.dispose();
-               }
-               return 1;
-       }
-
-       private void logout(LoginContext loginContext, String username) {
-               try {
-                       loginContext.logout();
-                       log.info("Logged out " + (username != null ? username : "")
-                                       + " (THREAD=" + Thread.currentThread().getId() + ")");
-               } catch (LoginException e) {
-                       log.error("Erorr when logging out", e);
-               }
-       }
-}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java
deleted file mode 100644 (file)
index 6e33cdd..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.rap;
-
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.commands.OpenHomePerspective;
-import org.eclipse.core.commands.Category;
-import org.eclipse.core.commands.Command;
-import org.eclipse.jface.action.ICoolBarManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.swt.SWT;
-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;
-import org.eclipse.ui.commands.ICommandService;
-
-/** Eclipse rap specific action bar advisor */
-public class RapActionBarAdvisor extends ActionBarAdvisor {
-       private final static String ID_BASE = SecureRapActivator.ID;
-       // private final static Log log = LogFactory
-       // .getLog(SecureActionBarAdvisor.class);
-
-       /** Null means anonymous */
-       private String username = null;
-
-       // private IAction logoutAction;
-       // private IWorkbenchAction openPerspectiveDialogAction;
-       // private IWorkbenchAction showViewMenuAction;
-       // private IWorkbenchAction preferences;
-       private IWorkbenchAction saveAction;
-       private IWorkbenchAction saveAllAction;
-
-       // private IWorkbenchAction closeAllAction;
-
-       public RapActionBarAdvisor(IActionBarConfigurer configurer, String username) {
-               super(configurer);
-               this.username = username;
-       }
-
-       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);
-               //
-               // // logout
-               // logoutAction = ActionFactory.QUIT.create(window);
-               // // logoutAction = createLogoutAction();
-               // register(logoutAction);
-               //
-               // Save semantics
-               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(logoutAction);
-               //
-               // // Edit
-               // editMenu.add(preferences);
-               //
-               // // Window
-               // windowMenu.add(openPerspectiveDialogAction);
-               // windowMenu.add(showViewMenuAction);
-       }
-
-       @Override
-       protected void fillCoolBar(ICoolBarManager coolBar) {
-               // Add a command which label is the display name of the current
-               // logged-in user
-               if (username != null) {
-                       ICommandService cmdService = (ICommandService) getActionBarConfigurer()
-                                       .getWindowConfigurer().getWorkbenchConfigurer()
-                                       .getWorkbench().getService(ICommandService.class);
-                       Category userMenus = cmdService.getCategory(ID_BASE + ".userMenus");
-                       if (!userMenus.isDefined())
-                               userMenus.define("User Menus", "User related menus");
-                       Command userMenu = cmdService.getCommand(ID_BASE
-                                       + ".userMenuCommand");
-                       if (userMenu.isDefined())
-                               userMenu.undefine();
-                       userMenu.define(CurrentUser.getDisplayName(), "User menu actions",
-                                       userMenus);
-                       // userMenu.define(username, "User menu actions", userMenus);
-                       
-                       userMenu.setHandler(new OpenHomePerspective());
-
-                       // userToolbar.add(new UserMenuAction());
-                       // coolBar.add(userToolbar);
-               } else {// anonymous
-                       IToolBarManager userToolbar = new ToolBarManager(SWT.FLAT
-                                       | SWT.RIGHT);
-                       // userToolbar.add(logoutAction);
-                       coolBar.add(userToolbar);
-               }
-               // IToolBarManager saveToolbar = new ToolBarManager(SWT.FLAT |
-               // SWT.RIGHT);
-               // saveToolbar.add(saveAction);
-               // saveToolbar.add(saveAllAction);
-               // coolBar.add(saveToolbar);
-       }
-
-       // class UserMenuAction extends Action implements IWorkbenchAction {
-       //
-       // public UserMenuAction() {
-       // super(username, IAction.AS_DROP_DOWN_MENU);
-       // // setMenuCreator(new UserMenu());
-       // }
-       //
-       // @Override
-       // public String getId() {
-       // return "org.argeo.cms.ui.workbench.rap.userMenu";
-       // }
-       //
-       // @Override
-       // public void dispose() {
-       // }
-       //
-       // }
-
-       // class UserMenu implements IMenuCreator {
-       // private Menu menu;
-       //
-       // public Menu getMenu(Control parent) {
-       // Menu menu = new Menu(parent);
-       // addActionToMenu(menu, logoutAction);
-       // return menu;
-       // }
-       //
-       // private void addActionToMenu(Menu menu, IAction action) {
-       // ActionContributionItem item = new ActionContributionItem(action);
-       // item.fill(menu, -1);
-       // }
-       //
-       // public void dispose() {
-       // if (menu != null) {
-       // menu.dispose();
-       // }
-       // }
-       //
-       // public Menu getMenu(Menu parent) {
-       // // Not use
-       // return null;
-       // }
-       //
-       // }
-
-       // protected IAction createLogoutAction() {
-       // Subject subject = Subject.getSubject(AccessController.getContext());
-       // final String username = subject.getPrincipals().iterator().next()
-       // .getName();
-       //
-       // IAction logoutAction = new Action() {
-       // public String getId() {
-       // return SecureRapActivator.ID + ".logoutAction";
-       // }
-       //
-       // public String getText() {
-       // return "Logout " + username;
-       // }
-       //
-       // public void run() {
-       // // try {
-       // // Subject subject = SecureRapActivator.getLoginContext()
-       // // .getSubject();
-       // // String subjectStr = subject.toString();
-       // // subject.getPrincipals().clear();
-       // // SecureRapActivator.getLoginContext().logout();
-       // // log.info(subjectStr + " logged out");
-       // // } catch (LoginException e) {
-       // // log.error("Error when logging out", e);
-       // // }
-       // // SecureEntryPoint.logout(username);
-       // // PlatformUI.getWorkbench().close();
-       // // try {
-       // // RWT.getRequest().getSession().setMaxInactiveInterval(1);
-       // // } catch (Exception e) {
-       // // if (log.isTraceEnabled())
-       // // log.trace("Error when invalidating session", e);
-       // // }
-       // }
-       //
-       // };
-       // return logoutAction;
-       // }
-
-}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWindowAdvisor.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWindowAdvisor.java
deleted file mode 100644 (file)
index 05f4787..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.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.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-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;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/** Eclipse RAP specific window advisor */
-public class RapWindowAdvisor extends WorkbenchWindowAdvisor {
-
-       private String username;
-
-       public RapWindowAdvisor(IWorkbenchWindowConfigurer configurer,
-                       String username) {
-               super(configurer);
-               this.username = username;
-       }
-
-       @Override
-       public ActionBarAdvisor createActionBarAdvisor(
-                       IActionBarConfigurer configurer) {
-               return new RapActionBarAdvisor(configurer, username);
-       }
-
-       public void preWindowOpen() {
-               IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
-               configurer.setShowCoolBar(true);
-               configurer.setShowMenuBar(false);
-               configurer.setShowStatusLine(false);
-               configurer.setShowPerspectiveBar(true);
-               configurer.setTitle("Argeo Web UI"); //$NON-NLS-1$
-               // Full screen, see
-               // http://wiki.eclipse.org/RAP/FAQ#How_to_create_a_fullscreen_application
-               configurer.setShellStyle(SWT.NO_TRIM);
-               Rectangle bounds = Display.getCurrent().getBounds();
-               configurer.setInitialSize(new Point(bounds.width, bounds.height));
-
-               // Handle window resize in Rap 2.1+ see
-               // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417254
-               Display.getCurrent().addListener(SWT.Resize, new Listener() {
-                       private static final long serialVersionUID = 2970912561866704526L;
-
-                       @Override
-                       public void handleEvent(Event event) {
-                               Rectangle bounds = event.display.getBounds();
-                               IWorkbenchWindow iww = getWindowConfigurer().getWindow()
-                                               .getWorkbench().getActiveWorkbenchWindow();
-                               iww.getShell().setBounds(bounds);
-                       }
-               });
-       }
-
-       @Override
-       public void postWindowCreate() {
-               Shell shell = getWindowConfigurer().getWindow().getShell();
-               shell.setMaximized(true);
-       }
-
-       @Override
-       public void postWindowOpen() {
-               String defaultPerspective = getWindowConfigurer()
-                               .getWorkbenchConfigurer().getWorkbench()
-                               .getPerspectiveRegistry().getDefaultPerspective();
-               if (defaultPerspective == null) {
-                       IWorkbenchWindow window = getWindowConfigurer().getWindow();
-                       if (window == null)
-                               return;
-
-                       IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
-                                       .create(window);
-                       openPerspectiveDialogAction.run();
-               }
-       }
-
-}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWorkbenchAdvisor.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWorkbenchAdvisor.java
deleted file mode 100644 (file)
index edde41f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.rap;
-
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.application.IWorkbenchConfigurer;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchAdvisor;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/** Eclipse RAP specific workbench advisor */
-public class RapWorkbenchAdvisor extends WorkbenchAdvisor {
-       public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
-       public final static String SAVE_AND_RESTORE_PROPERTY = "org.argeo.security.ui.saveAndRestore";
-
-       private String initialPerspective = System.getProperty(
-                       INITIAL_PERSPECTIVE_PROPERTY, null);
-
-       private String username;
-
-       public RapWorkbenchAdvisor(String username) {
-               this.username = username;
-       }
-
-       @Override
-       public void initialize(IWorkbenchConfigurer configurer) {
-               super.initialize(configurer);
-               Boolean saveAndRestore = Boolean.parseBoolean(System.getProperty(
-                               SAVE_AND_RESTORE_PROPERTY, "false"));
-               configurer.setSaveAndRestore(saveAndRestore);
-       }
-
-       public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
-                       IWorkbenchWindowConfigurer configurer) {
-               return new RapWindowAdvisor(configurer, username);
-       }
-
-       public String getInitialWindowPerspectiveId() {
-               if (initialPerspective != null) {
-                       // check whether this user can see the declared perspective
-                       // (typically the perspective won't be listed if this user doesn't
-                       // have the right to see it)
-                       IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
-                                       .getPerspectiveRegistry()
-                                       .findPerspectiveWithId(initialPerspective);
-                       if (pd == null)
-                               return null;
-               }
-               return initialPerspective;
-       }
-}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWorkbenchLogin.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/RapWorkbenchLogin.java
deleted file mode 100644 (file)
index 06fc62e..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.argeo.security.ui.rap;
-
-import java.security.PrivilegedAction;
-import java.util.Locale;
-
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
-
-import org.argeo.cms.CmsMsg;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.util.CmsUtils;
-import org.argeo.cms.util.LoginEntryPoint;
-import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-public class RapWorkbenchLogin extends LoginEntryPoint {
-       // private final static Log log =
-       // LogFactory.getLog(RapWorkbenchLogin.class);
-
-       /** Override to provide an application specific workbench advisor */
-       protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(String username) {
-               return new RapWorkbenchAdvisor(username);
-       }
-
-       @Override
-       public int createUI() {
-               JavaScriptExecutor jsExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
-               int returnCode;
-               try {
-                       returnCode = super.createUI();
-               } finally {
-                       // always reload
-                       // TODO optimise?
-                       jsExecutor.execute("location.reload()");
-               }
-               return returnCode;
-       }
-
-       @Override
-       protected int postLogin() {
-               Subject subject = getLoginContext().getSubject();
-               final Display display = Display.getCurrent();
-               if (subject.getPrincipals(X500Principal.class).isEmpty()) {
-                       RWT.getClient().getService(JavaScriptExecutor.class).execute("location.reload()");
-               }
-               //
-               // RUN THE WORKBENCH
-               //
-               Integer returnCode = null;
-               try {
-                       returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
-                               public Integer run() {
-                                       int result = createAndRunWorkbench(display, CurrentUser.getUsername(subject));
-                                       return new Integer(result);
-                               }
-                       });
-                       // explicit workbench closing
-                       logout();
-               } finally {
-                       display.dispose();
-               }
-               return returnCode;
-       }
-
-       protected int createAndRunWorkbench(Display display, String username) {
-               RapWorkbenchAdvisor workbenchAdvisor = createRapWorkbenchAdvisor(username);
-               return PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
-       }
-
-       @Override
-       protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale,
-                       SelectionListener loginSelectionListener) {
-               Button loginButton = new Button(credentialsBlock, SWT.PUSH);
-               loginButton.setText(CmsMsg.login.lead(selectedLocale));
-               loginButton.setLayoutData(CmsUtils.fillWidth());
-               loginButton.addSelectionListener(loginSelectionListener);
-       }
-
-       @Override
-       protected Display createDisplay() {
-               return PlatformUI.createDisplay();
-       }
-
-}
diff --git a/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/SecureRapActivator.java b/org.argeo.cms.ui.workbench.rap/src/org/argeo/security/ui/rap/SecureRapActivator.java
deleted file mode 100644 (file)
index 045f88a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.rap;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/** Configure Equinox login context from the bundle context. */
-public class SecureRapActivator implements BundleActivator {
-       public final static String ID = "org.argeo.cms.ui.workbench.rap";
-
-       private static BundleContext bundleContext;
-
-       public void start(BundleContext bc) throws Exception {
-               bundleContext = bc;
-       }
-
-       public void stop(BundleContext context) throws Exception {
-               bundleContext = null;
-       }
-
-       public static BundleContext getBundleContext() {
-               return bundleContext;
-       }
-}