X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FLoginEntryPoint.java;h=1f24da2f4327d3d9d27c550cd73aa059fafd390f;hb=9653b07ad7c6a73be1b1c1d8ce079e319727362d;hp=1f46f100e0c98cbce2a5e45496c7017b10eba5f0;hpb=7e333073d07b780efe681306a1842a750cbea83c;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 1f46f100e..1f24da2f4 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,10 +2,10 @@ package org.argeo.cms.util; import java.util.Locale; -import javax.security.auth.login.CredentialNotFoundException; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.argeo.cms.CmsException; import org.argeo.cms.auth.CurrentUser; @@ -24,6 +24,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; public class LoginEntryPoint implements EntryPoint, CmsView { + protected final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate"; + protected final static String HEADER_AUTHORIZATION = "Authorization"; // private final static Log log = LogFactory.getLog(WorkbenchLogin.class); // private final Subject subject = new Subject(); private LoginContext loginContext; @@ -38,25 +40,28 @@ public class LoginEntryPoint implements EntryPoint, CmsView { // try pre-auth loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, loginShell); loginContext.login(); - } catch (CredentialNotFoundException e) { + } catch (LoginException e) { loginShell.createUi(); loginShell.open(); + +// HttpServletRequest request = RWT.getRequest(); +// String authorization = request.getHeader(HEADER_AUTHORIZATION); +// if (authorization == null || !authorization.startsWith("Negotiate")) { +// HttpServletResponse response = RWT.getResponse(); +// response.setStatus(401); +// response.setHeader(HEADER_WWW_AUTHENTICATE, "Negotiate"); +// response.setDateHeader("Date", System.currentTimeMillis()); +// response.setDateHeader("Expires", System.currentTimeMillis() + (24 * 60 * 60 * 1000)); +// response.setHeader("Accept-Ranges", "bytes"); +// response.setHeader("Connection", "Keep-Alive"); +// response.setHeader("Keep-Alive", "timeout=5, max=97"); +// // response.setContentType("text/html; charset=UTF-8"); +// } + 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) @@ -76,8 +81,6 @@ public class LoginEntryPoint implements EntryPoint, CmsView { protected HttpServletRequest getRequest() { return RWT.getRequest(); } - - protected CmsLoginShell createCmsLoginShell() { return new CmsLoginShell(this) { @@ -132,19 +135,6 @@ public class LoginEntryPoint implements EntryPoint, CmsView { throw new CmsException("Cannot log out", e); } } - - - - // @Override - // public final Subject getSubject() { - // return subject; - // } - -// @Override -// public void registerCallbackHandler(CallbackHandler callbackHandler) { -// throw new UnsupportedOperationException(); -// -// } @Override public void exception(Throwable e) { @@ -167,5 +157,4 @@ public class LoginEntryPoint implements EntryPoint, CmsView { public UxContext getUxContext() { return uxContext; } - -} +} \ No newline at end of file