X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.security.ui.rap%2Fsrc%2Forg%2Fargeo%2Fsecurity%2Fui%2Frap%2FSecureEntryPoint.java;h=7463f8b533ea362bbde433ea5a971931173e14ac;hb=afcca7fbd7257e8ce6f813d002b4eef82d63d8ee;hp=6a582f83f75e948dc60b8fb9680e3aa9b49033a4;hpb=9dba7b01008499bdaf15c754190906d3200713fe;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/SecureEntryPoint.java b/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/SecureEntryPoint.java index 6a582f83f..7463f8b53 100644 --- a/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/SecureEntryPoint.java +++ b/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/SecureEntryPoint.java @@ -15,14 +15,12 @@ */ package org.argeo.security.ui.rap; -import static org.argeo.cms.auth.AuthConstants.ACCESS_CONTROL_CONTEXT; - import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; import javax.security.auth.Subject; -import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.login.CredentialNotFoundException; import javax.security.auth.login.FailedLoginException; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; @@ -34,9 +32,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.ArgeoException; import org.argeo.cms.auth.AuthConstants; +import org.argeo.cms.auth.ThreadDeathLoginException; import org.argeo.cms.widgets.auth.DefaultLoginDialog; import org.argeo.eclipse.ui.dialogs.ErrorFeedback; -import org.argeo.util.LocaleUtils; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.application.EntryPoint; @@ -48,7 +46,9 @@ import org.eclipse.ui.PlatformUI; * authenticated, the workbench is run as a privileged action by the related * subject. */ +@Deprecated public class SecureEntryPoint implements EntryPoint { + final static String ACCESS_CONTROL_CONTEXT = "org.argeo.node.accessControlContext"; private final static Log log = LogFactory.getLog(SecureEntryPoint.class); /** @@ -77,7 +77,7 @@ public class SecureEntryPoint implements EntryPoint { HttpServletRequest httpRequest = RWT.getRequest(); final HttpSession httpSession = httpRequest.getSession(); AccessControlContext acc = (AccessControlContext) httpSession - .getAttribute(AuthConstants.ACCESS_CONTROL_CONTEXT); + .getAttribute(ACCESS_CONTROL_CONTEXT); final Subject subject; if (acc != null @@ -88,8 +88,9 @@ public class SecureEntryPoint implements EntryPoint { subject = new Subject(); final LoginContext loginContext; + DefaultLoginDialog callbackHandler; try { - CallbackHandler callbackHandler = new DefaultLoginDialog( + callbackHandler = new DefaultLoginDialog( display.getActiveShell()); loginContext = new LoginContext( AuthConstants.LOGIN_CONTEXT_USER, subject, @@ -105,9 +106,9 @@ public class SecureEntryPoint implements EntryPoint { throw new ArgeoException("Login succeeded but no auth");// fatal // add thread locale to RWT session - if (log.isTraceEnabled()) - log.trace("Locale " + LocaleUtils.threadLocale.get()); - RWT.setLocale(LocaleUtils.threadLocale.get()); + // if (log.isTraceEnabled()) + // log.trace("Locale " + LocaleUtils.threadLocale.get()); + // RWT.setLocale(LocaleUtils.threadLocale.get()); // once the user is logged in, longer session timeout RWT.getRequest().getSession() @@ -120,7 +121,13 @@ public class SecureEntryPoint implements EntryPoint { "Bad Credentials", e.getMessage()); // retry login continue tryLogin; + } catch (CredentialNotFoundException e) { + MessageDialog.openInformation(display.getActiveShell(), + "No Credentials", e.getMessage()); + // retry login + continue tryLogin; } catch (LoginException e) { + callbackHandler.getShell().dispose(); return processLoginDeath(display, e); } } @@ -168,7 +175,7 @@ public class SecureEntryPoint implements EntryPoint { return returnCode; } - private Integer processLoginDeath(Display display, LoginException e) { + private Integer processLoginDeath(Display display, Throwable e) { // check thread death ThreadDeath td = wasCausedByThreadDeath(e); if (td != null) { @@ -195,7 +202,8 @@ public class SecureEntryPoint implements EntryPoint { protected ThreadDeath wasCausedByThreadDeath(Throwable t) { if (t instanceof ThreadDeath) return (ThreadDeath) t; - + if (t instanceof ThreadDeathLoginException) + return ((ThreadDeathLoginException) t).getThreadDeath(); if (t.getCause() != null) return wasCausedByThreadDeath(t.getCause()); else