X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=rap%2Forg.argeo.cms.ui.rap%2Fsrc%2Forg%2Fargeo%2Fcms%2Fweb%2FCmsWebEntryPoint.java;h=9e407366d2eaa6f7f98908246b56c28a865bc1a3;hb=df60fd8de17590b8f4ab32fd0278e57aaaedbfa2;hp=d7050e954d77784717e9393ed2d38ceb3f0cceec;hpb=f9efbe5228615951dd8482a4582aa24e00c10ce5;p=lgpl%2Fargeo-commons.git diff --git a/rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java b/rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java index d7050e954..9e407366d 100644 --- a/rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java +++ b/rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java @@ -12,19 +12,17 @@ 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.api.NodeConstants; import org.argeo.api.cms.CmsApp; -import org.argeo.api.cms.CmsImageManager; +import org.argeo.api.cms.CmsAuth; +import org.argeo.api.cms.CmsLog; import org.argeo.api.cms.CmsSession; -import org.argeo.api.cms.CmsUi; -import org.argeo.api.cms.CmsView; -import org.argeo.api.cms.UxContext; +import org.argeo.api.cms.ux.CmsImageManager; +import org.argeo.api.cms.ux.CmsUi; +import org.argeo.api.cms.ux.CmsView; +import org.argeo.api.cms.ux.UxContext; import org.argeo.cms.LocaleUtils; import org.argeo.cms.auth.CurrentUser; -import org.argeo.cms.auth.HttpRequestCallbackHandler; -import org.argeo.cms.osgi.CmsOsgiUtils; +import org.argeo.cms.auth.RemoteAuthCallbackHandler; import org.argeo.cms.servlet.ServletHttpRequest; import org.argeo.cms.servlet.ServletHttpResponse; import org.argeo.cms.swt.CmsSwtUtils; @@ -50,7 +48,7 @@ import org.osgi.service.event.EventAdmin; @SuppressWarnings("restriction") public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationListener { private static final long serialVersionUID = 7733510691684570402L; - private final static Log log = LogFactory.getLog(CmsWebEntryPoint.class); + private final static CmsLog log = CmsLog.getLog(CmsWebEntryPoint.class); private EventAdmin eventAdmin; @@ -85,13 +83,15 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL // Initial login LoginContext lc; try { - lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, - new HttpRequestCallbackHandler(new ServletHttpRequest(UiContext.getHttpRequest()), + lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER, + new RemoteAuthCallbackHandler(new ServletHttpRequest(UiContext.getHttpRequest()), new ServletHttpResponse(UiContext.getHttpResponse()))); lc.login(); } catch (LoginException e) { try { - lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_ANONYMOUS); + lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_ANONYMOUS, + new RemoteAuthCallbackHandler(new ServletHttpRequest(UiContext.getHttpRequest()), + new ServletHttpResponse(UiContext.getHttpResponse()))); lc.login(); } catch (LoginException e1) { throw new IllegalStateException("Cannot log in as anonymous", e1); @@ -156,7 +156,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL try { CurrentUser.logoutCmsSession(loginContext.getSubject()); loginContext.logout(); - LoginContext anonymousLc = new LoginContext(NodeConstants.LOGIN_CONTEXT_ANONYMOUS); + LoginContext anonymousLc = new LoginContext(CmsAuth.LOGIN_CONTEXT_ANONYMOUS, + new RemoteAuthCallbackHandler(new ServletHttpRequest(UiContext.getHttpRequest()), + new ServletHttpResponse(UiContext.getHttpResponse()))); anonymousLc.login(); authChange(anonymousLc); } catch (LoginException e) { @@ -189,7 +191,7 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL display.syncExec(() -> { // CmsFeedback.show("Unexpected exception in CMS", e); exception = e; -// log.error("Unexpected exception in CMS", e); + log.error("Unexpected exception in CMS", e); doRefresh(); }); } @@ -266,7 +268,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL @Override public CmsSession getCmsSession() { - CmsSession cmsSession = CmsOsgiUtils.getCmsSession(cmsWebApp.getBundleContext(), getSubject()); + CmsSession cmsSession = cmsWebApp.getCmsApp().getCmsContext().getCmsSession(getSubject()); + if (cmsSession == null) + throw new IllegalStateException("No CMS session available for " + getSubject()); return cmsSession; }