import org.argeo.cms.auth.AuthConstants;
import org.argeo.cms.auth.CurrentUser;
import org.argeo.cms.auth.HttpRequestCallbackHandler;
-import org.argeo.cms.util.UserMenu;
+import org.argeo.cms.widgets.auth.CmsLoginShell;
import org.argeo.eclipse.ui.specific.UiContext;
import org.eclipse.rap.rwt.application.EntryPoint;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
public abstract class WorkbenchLogin implements EntryPoint, CmsView {
final Display display = PlatformUI.createDisplay();
UiContext.setData(CmsView.KEY, this);
try {
+ // try pre-auth
loginContext = new LoginContext(AuthConstants.LOGIN_CONTEXT_USER,
subject, new HttpRequestCallbackHandler(getRequest()));
loginContext.login();
} catch (CredentialNotFoundException e) {
- Shell shell = new Shell(display, SWT.NO_TRIM);
- shell.setMaximized(true);
- //shell.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
- UserMenu userMenu = new UserMenu(shell, false);
- shell.open();
- while (!userMenu.getShell().isDisposed()) {
+ CmsLoginShell loginShell = createCmsLoginShell();
+ loginShell.open();
+ while (!loginShell.getShell().isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
return new Integer(result);
}
});
+ // explicit workbench closing
+ logout();
} finally {
display.dispose();
}
- // explicit workbench closing
- logout();
return returnCode;
}
protected abstract int createAndRunWorkbench(Display display,
String username);
- // private void fullLogout() {
- // String username = CurrentUser.getUsername(subject);
- // try {
- // LoginContext loginContext = new LoginContext(
- // AuthConstants.LOGIN_CONTEXT_USER, subject);
- // loginContext.logout();
- // HttpServletRequest httpRequest = getRequest();
- // httpRequest.setAttribute(HttpContext.AUTHORIZATION, null);
- // HttpSession httpSession = httpRequest.getSession();
- // httpSession.setAttribute(HttpContext.AUTHORIZATION, null);
- // httpSession.setMaxInactiveInterval(1);
- // log.info("Logged out " + (username != null ? username : "")
- // + " (THREAD=" + Thread.currentThread().getId() + ")");
- // } catch (LoginException e) {
- // log.error("Error when logging out", e);
- // }
- // }
-
protected HttpServletRequest getRequest() {
return UiContext.getHttpRequest();
}
+ protected CmsLoginShell createCmsLoginShell() {
+ return new CmsLoginShell(this);
+ }
+
@Override
public void navigateTo(String state) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
return null;
}
-
}