X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FLoginEntryPoint.java;h=6b26b37288a1ff02124ac910b0e42bc75882ba18;hb=02b1daffc1b416fc784231719e459d2b8495cf70;hp=424b8b23c68c7686837348bfe79de5fde716d5e6;hpb=c5fa035468228d1f87ab5431a3fad17403eee1c3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui/src/org/argeo/cms/util/LoginEntryPoint.java b/org.argeo.cms.ui/src/org/argeo/cms/util/LoginEntryPoint.java index 424b8b23c..6b26b3728 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/util/LoginEntryPoint.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/util/LoginEntryPoint.java @@ -2,23 +2,20 @@ package org.argeo.cms.util; import java.util.Locale; -import javax.security.auth.Subject; -import javax.security.auth.login.CredentialNotFoundException; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import javax.servlet.http.HttpServletRequest; import org.argeo.cms.CmsException; -import org.argeo.cms.auth.AuthConstants; import org.argeo.cms.auth.CurrentUser; -import org.argeo.cms.auth.HttpRequestCallbackHandler; import org.argeo.cms.ui.CmsImageManager; import org.argeo.cms.ui.CmsView; import org.argeo.cms.ui.UxContext; import org.argeo.cms.widgets.auth.CmsLogin; import org.argeo.cms.widgets.auth.CmsLoginShell; import org.argeo.eclipse.ui.specific.UiContext; -import org.argeo.node.NodeAuthenticated; +import org.argeo.node.NodeConstants; +import org.argeo.node.security.NodeAuthenticated; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.application.EntryPoint; import org.eclipse.swt.events.SelectionListener; @@ -27,7 +24,7 @@ import org.eclipse.swt.widgets.Display; public class LoginEntryPoint implements EntryPoint, CmsView { // private final static Log log = LogFactory.getLog(WorkbenchLogin.class); - private final Subject subject = new Subject(); + // private final Subject subject = new Subject(); private LoginContext loginContext; private UxContext uxContext = null; @@ -35,30 +32,18 @@ public class LoginEntryPoint implements EntryPoint, CmsView { public int createUI() { final Display display = createDisplay(); UiContext.setData(NodeAuthenticated.KEY, this); + CmsLoginShell loginShell = createCmsLoginShell(); try { // try pre-auth - loginContext = new LoginContext(AuthConstants.LOGIN_CONTEXT_USER, - subject, new HttpRequestCallbackHandler(getRequest())); + loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, loginShell); loginContext.login(); - } catch (CredentialNotFoundException e) { - CmsLoginShell loginShell = createCmsLoginShell(); + } catch (LoginException e) { + loginShell.createUi(); loginShell.open(); while (!loginShell.getShell().isDisposed()) { - // try { if (!display.readAndDispatch()) display.sleep(); - // } catch (Exception e1) { - // try { - // Thread.sleep(3000); - // } catch (InterruptedException e2) { - // // silent - // } - // ErrorFeedback.show("Login failed", e1); - // return -1; - // } } - } catch (LoginException e) { - throw new CmsException("Cannot log in", e); } if (CurrentUser.getUsername() == null) @@ -88,11 +73,9 @@ public class LoginEntryPoint implements EntryPoint, CmsView { } @Override - protected void extendsCredentialsBlock(Composite credentialsBlock, - Locale selectedLocale, + protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale, SelectionListener loginSelectionListener) { - LoginEntryPoint.this.extendsCredentialsBlock(credentialsBlock, - selectedLocale, loginSelectionListener); + LoginEntryPoint.this.extendsCredentialsBlock(credentialsBlock, selectedLocale, loginSelectionListener); } }; @@ -108,8 +91,8 @@ public class LoginEntryPoint implements EntryPoint, CmsView { login.defaultCreateContents(parent); } - protected void extendsCredentialsBlock(Composite credentialsBlock, - Locale selectedLocale, SelectionListener loginSelectionListener) { + protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale, + SelectionListener loginSelectionListener) { } @@ -135,17 +118,17 @@ public class LoginEntryPoint implements EntryPoint, CmsView { } } - @Override - public final Subject getSubject() { - return subject; - } - @Override public void exception(Throwable e) { // TODO Auto-generated method stub } + @Override + public LoginContext getLoginContext() { + return loginContext; + } + @Override public CmsImageManager getImageManager() { // TODO Auto-generated method stub @@ -156,5 +139,4 @@ public class LoginEntryPoint implements EntryPoint, CmsView { public UxContext getUxContext() { return uxContext; } - -} +} \ No newline at end of file