X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=security%2Fplugins%2Forg.argeo.security.ui.rap%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fui%2Frap%2FSecureEntryPoint.java;h=f30f0059bd825516bdc77cff250d9bb6d5ed14f1;hb=fb4f7c451ea7d9025f7cf7fe032020f229df794a;hp=d7dc18ca9c5dacdde74b134c465482763fd776b7;hpb=ba1f9e3787c089254d03ac067b2d363a809b2274;p=lgpl%2Fargeo-commons.git diff --git a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java index d7dc18ca9..f30f0059b 100644 --- a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java +++ b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java @@ -5,21 +5,27 @@ import java.security.PrivilegedAction; import javax.security.auth.Subject; import javax.security.auth.login.LoginException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; 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.rwt.service.SessionStoreEvent; +import org.eclipse.rwt.service.SessionStoreListener; 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 { +public class SecureEntryPoint implements IEntryPoint, SessionStoreListener { + private Log log = LogFactory.getLog(SecureEntryPoint.class); @Override public int createUI() { + // log.debug("THREAD=" + Thread.currentThread().getId() + // + ", RWT.getSessionStore().getId()=" + // + RWT.getSessionStore().getId()); + Integer returnCode = null; Display display = PlatformUI.createDisplay(); try { @@ -27,9 +33,10 @@ public class SecureEntryPoint implements IEntryPoint { Boolean retry = true; while (retry) { try { + // force login in order to give Spring Security a chance to + // load SecureRapActivator.getLoginContext().login(); - subject = SecureRapActivator.getLoginContext() - .getSubject(); + subject = SecureRapActivator.getLoginContext().getSubject(); retry = false; } catch (LoginException e) { Error.show("Cannot login", e); @@ -40,16 +47,6 @@ public class SecureEntryPoint implements IEntryPoint { } } - 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)); @@ -59,20 +56,17 @@ public class SecureEntryPoint implements IEntryPoint { 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(); - } + log.error("Unexpected error",e); + return -1; + } +// 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); @@ -99,4 +93,13 @@ public class SecureEntryPoint implements IEntryPoint { }; } + @Override + public void beforeDestroy(SessionStoreEvent event) { + if (log.isDebugEnabled()) + log.debug("RWT session " + event.getSessionStore().getId() + + " about to be destroyed. THREAD=" + + Thread.currentThread().getId()); + + } + }