Improve SSH layer
[lgpl/argeo-commons.git] / rcp / org.argeo.cms.e4.rcp / src / org / argeo / cms / e4 / rcp / CmsE4Application.java
index 9cf4c8c6be1ecdb1a868f4c2f5a6856c260f6310..b37a76587c1a82f0e5292ec6e650b0c33b5fd432 100644 (file)
@@ -7,12 +7,12 @@ import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
-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.CmsException;
+import org.argeo.api.cms.CmsAuth;
+import org.argeo.api.cms.ux.CmsImageManager;
+import org.argeo.api.cms.ux.CmsView;
+import org.argeo.api.cms.ux.UxContext;
 import org.argeo.cms.auth.CurrentUser;
+import org.argeo.cms.swt.CmsException;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.swt.SimpleSwtUxContext;
 import org.argeo.cms.swt.auth.CmsLoginShell;
@@ -31,15 +31,18 @@ public class CmsE4Application implements IApplication, CmsView {
 
        @Override
        public Object start(IApplicationContext context) throws Exception {
+               // TODO wait for CMS to be ready
+               Thread.sleep(5000);
+
                uid = UUID.randomUUID().toString();
                Subject subject = new Subject();
                Display display = createDisplay();
-               CmsLoginShell loginShell = new CmsLoginShell(this);
+               CmsLoginShell loginShell = new CmsLoginShell(this, null);
                // TODO customize CmsLoginShell to be smaller and centered
                loginShell.setSubject(subject);
                try {
                        // try pre-auth
-                       loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, subject, loginShell);
+                       loginContext = new LoginContext(CmsAuth.LOGIN_CONTEXT_SINGLE_USER, subject, loginShell);
                        loginContext.login();
                } catch (LoginException e) {
                        e.printStackTrace();
@@ -52,7 +55,7 @@ public class CmsE4Application implements IApplication, CmsView {
                        }
                }
                if (CurrentUser.getUsername(getSubject()) == null)
-                       throw new CmsException("Cannot log in");
+                       throw new IllegalStateException("Cannot log in");
 
                // try {
                // CallbackHandler callbackHandler = new DefaultLoginDialog(
@@ -80,7 +83,7 @@ public class CmsE4Application implements IApplication, CmsView {
                // }
 
                uxContext = new SimpleSwtUxContext();
-               //UiContext.setData(CmsView.KEY, this);
+               // UiContext.setData(CmsView.KEY, this);
                CmsSwtUtils.registerCmsView(loginShell.getShell(), this);
                e4Application = getApplication(null);
                Object res = Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
@@ -201,5 +204,4 @@ public class CmsE4Application implements IApplication, CmsView {
                return uid;
        }
 
-       
 }