X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.e4.rap%2Fsrc%2Forg%2Fargeo%2Fcms%2Fe4%2Frap%2FCmsLoginLifecycle.java;h=3ee8df1ef76c27a9b44a672c16354d4b3fe0cf8a;hb=b7683883512d924a039a43c2e1102290aa49f64d;hp=047fb371e46e1efa464e9b53e8c88f9a5c90f03b;hpb=b73edb765859b2193c67380c33fbc6c694468fe4;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 047fb371e..3ee8df1ef 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; @@ -8,15 +9,16 @@ 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.api.NodeConstants; +import org.argeo.api.cms.CmsImageManager; +import org.argeo.api.cms.CmsView; +import org.argeo.api.cms.UxContext; import org.argeo.cms.auth.CurrentUser; -import org.argeo.cms.ui.CmsImageManager; -import org.argeo.cms.ui.CmsView; -import org.argeo.cms.ui.UxContext; -import org.argeo.cms.ui.dialogs.CmsFeedback; -import org.argeo.cms.util.SimpleUxContext; -import org.argeo.cms.widgets.auth.CmsLoginShell; -import org.argeo.node.NodeConstants; +import org.argeo.cms.swt.CmsSwtUtils; +import org.argeo.cms.swt.SimpleSwtUxContext; +import org.argeo.cms.swt.auth.CmsLoginShell; +import org.argeo.cms.swt.dialogs.CmsFeedback; +import org.argeo.cms.ui.util.SimpleImageManager; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate; @@ -34,14 +36,17 @@ public class CmsLoginLifecycle implements CmsView { private final static Log log = LogFactory.getLog(CmsLoginLifecycle.class); private UxContext uxContext; + private CmsImageManager imageManager; private LoginContext loginContext; 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() { @@ -57,7 +62,9 @@ public class CmsLoginLifecycle implements CmsView { Subject subject = Subject.getSubject(AccessController.getContext()); Display display = Display.getCurrent(); +// UiContext.setData(CmsView.KEY, this); CmsLoginShell loginShell = new CmsLoginShell(this); + CmsSwtUtils.registerCmsView(loginShell.getShell(), this); loginShell.setSubject(subject); try { // try pre-auth @@ -74,7 +81,8 @@ public class CmsLoginLifecycle implements CmsView { } if (CurrentUser.getUsername(getSubject()) == null) return false; - uxContext = new SimpleUxContext(); + uxContext = new SimpleSwtUxContext(); + imageManager = new SimpleImageManager(); eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() { @Override @@ -106,7 +114,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 { @@ -120,12 +128,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); } } @@ -138,7 +146,7 @@ public class CmsLoginLifecycle implements CmsView { @Override public CmsImageManager getImageManager() { - throw new UnsupportedOperationException(); + return imageManager; } protected Subject getSubject() { @@ -150,6 +158,11 @@ public class CmsLoginLifecycle implements CmsView { return CurrentUser.isAnonymous(getSubject()); } + @Override + public String getUid() { + return uid; + } + // CALLBACKS protected void startupComplete() { }