]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java
Introduce hierarchies in user management
[lgpl/argeo-commons.git] / rap / org.argeo.cms.ui.rap / src / org / argeo / cms / web / CmsWebEntryPoint.java
index afc07c5b0681dfa61cfd057ed3ead7ad1ffcc25e..2236870f6e74ab2144fdd9ccf3b827a8b222a923 100644 (file)
@@ -15,15 +15,14 @@ import javax.security.auth.login.LoginException;
 import org.argeo.api.cms.CmsApp;
 import org.argeo.api.cms.CmsAuth;
 import org.argeo.api.cms.CmsImageManager;
+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.CmsLog;
 import org.argeo.api.cms.UxContext;
 import org.argeo.cms.LocaleUtils;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.auth.RemoteAuthCallbackHandler;
-import org.argeo.cms.osgi.CmsOsgiUtils;
 import org.argeo.cms.servlet.ServletHttpRequest;
 import org.argeo.cms.servlet.ServletHttpResponse;
 import org.argeo.cms.swt.CmsSwtUtils;
@@ -90,7 +89,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                        lc.login();
                } catch (LoginException e) {
                        try {
-                               lc = new LoginContext(CmsAuth.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);
@@ -155,7 +156,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                try {
                        CurrentUser.logoutCmsSession(loginContext.getSubject());
                        loginContext.logout();
-                       LoginContext anonymousLc = new LoginContext(CmsAuth.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) {
@@ -188,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();
                });
        }
@@ -265,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;
        }