1 package org
.argeo
.security
.ui
.rcp
;
3 import java
.security
.PrivilegedAction
;
5 import javax
.security
.auth
.Subject
;
7 import org
.argeo
.security
.equinox
.CurrentUser
;
8 import org
.eclipse
.equinox
.app
.IApplication
;
9 import org
.eclipse
.equinox
.app
.IApplicationContext
;
10 import org
.eclipse
.swt
.widgets
.Display
;
11 import org
.eclipse
.ui
.IWorkbench
;
12 import org
.eclipse
.ui
.PlatformUI
;
13 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
14 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
16 public class SecureRap
implements IApplication
{
17 public Object
start(IApplicationContext context
) throws Exception
{
18 String username
= CurrentUser
.getUsername();
19 Integer result
= null;
20 Display display
= PlatformUI
.createDisplay();
22 result
= (Integer
) Subject
.doAs(CurrentUser
.getSubject(),
23 getRunAction(display
));
24 } catch (Exception e
) {
32 @SuppressWarnings("rawtypes")
33 private PrivilegedAction
getRunAction(final Display display
) {
34 return new PrivilegedAction() {
37 int result
= PlatformUI
.createAndRunWorkbench(display
,
38 new ApplicationWorkbenchAdvisor());
39 return new Integer(result
);
45 final IWorkbench workbench
;
47 workbench
= PlatformUI
.getWorkbench();
48 } catch (Exception e
) {
51 if (workbench
== null)
53 final Display display
= workbench
.getDisplay();
54 display
.syncExec(new Runnable() {
57 if (!display
.isDisposed())
63 class ApplicationWorkbenchAdvisor
extends SecureWorkbenchAdvisor
{
64 public WorkbenchWindowAdvisor
createWorkbenchWindowAdvisor(
65 IWorkbenchWindowConfigurer configurer
) {
66 return new RapSecureWorkbenchWindowAdvisor(configurer
);