X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.e4.rap%2Fsrc%2Forg%2Fargeo%2Fcms%2Fe4%2Frap%2FCmsLoginLifecycle.java;h=12ee3c55e9150fe17ea22a87bd85eb13e3dd9156;hb=03f646fd0d7e7ce393694c836c779bc67a4eef55;hp=f7a1ed667c8aee878928f453d6ffe5da4fd84024;hpb=5b3108fe285bca50565b58b63fa4feddc96c0765;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/CmsLoginLifecycle.java b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/CmsLoginLifecycle.java index f7a1ed667..12ee3c55e 100644 --- a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/CmsLoginLifecycle.java +++ b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/CmsLoginLifecycle.java @@ -1,6 +1,7 @@ package org.argeo.cms.e4.rap; import java.security.AccessController; +import java.util.UUID; import javax.security.auth.Subject; import javax.security.auth.login.LoginContext; @@ -9,7 +10,6 @@ import javax.security.auth.login.LoginException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.api.NodeConstants; -import org.argeo.cms.CmsException; import org.argeo.cms.auth.CurrentUser; import org.argeo.cms.ui.CmsImageManager; import org.argeo.cms.ui.CmsView; @@ -18,7 +18,6 @@ import org.argeo.cms.ui.dialogs.CmsFeedback; import org.argeo.cms.ui.util.SimpleImageManager; import org.argeo.cms.ui.util.SimpleUxContext; import org.argeo.cms.ui.widgets.auth.CmsLoginShell; -import org.argeo.eclipse.ui.specific.UiContext; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate; @@ -42,9 +41,11 @@ public class CmsLoginLifecycle implements CmsView { private BrowserNavigation browserNavigation; private String state = null; + private String uid; @PostContextCreate boolean login(final IEventBroker eventBroker) { + uid = UUID.randomUUID().toString(); browserNavigation = RWT.getClient().getService(BrowserNavigation.class); if (browserNavigation != null) browserNavigation.addBrowserNavigationListener(new BrowserNavigationListener() { @@ -60,8 +61,9 @@ public class CmsLoginLifecycle implements CmsView { Subject subject = Subject.getSubject(AccessController.getContext()); Display display = Display.getCurrent(); - UiContext.setData(CmsView.KEY, this); +// UiContext.setData(CmsView.KEY, this); CmsLoginShell loginShell = new CmsLoginShell(this); + CmsView.registerCmsView(loginShell.getShell(), this); loginShell.setSubject(subject); try { // try pre-auth @@ -111,7 +113,7 @@ public class CmsLoginLifecycle implements CmsView { @Override public void authChange(LoginContext loginContext) { if (loginContext == null) - throw new CmsException("Login context cannot be null"); + throw new IllegalArgumentException("Login context cannot be null"); // logout previous login context // if (this.loginContext != null) // try { @@ -125,12 +127,12 @@ public class CmsLoginLifecycle implements CmsView { @Override public void logout() { if (loginContext == null) - throw new CmsException("Login context should not be null"); + throw new IllegalStateException("Login context should not be null"); try { CurrentUser.logoutCmsSession(loginContext.getSubject()); loginContext.logout(); } catch (LoginException e) { - throw new CmsException("Cannot log out", e); + throw new IllegalStateException("Cannot log out", e); } } @@ -155,6 +157,11 @@ public class CmsLoginLifecycle implements CmsView { return CurrentUser.isAnonymous(getSubject()); } + @Override + public String getUid() { + return uid; + } + // CALLBACKS protected void startupComplete() { }