X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2FAbstractCmsEntryPoint.java;h=a9ad03a12470055dfac85116237bf5f825235dcc;hb=0b3ea4f2c08f00100e962272bf21f4f32346fd61;hp=6e30d8e31d7b16b3b9cf4938faf954e0721839b5;hpb=ff718212e89b0ea05087aabe147859efedf186f9;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java b/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java index 6e30d8e31..a9ad03a12 100644 --- a/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java +++ b/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java @@ -15,6 +15,7 @@ import javax.jcr.Session; import javax.jcr.nodetype.NodeType; import javax.security.auth.Subject; import javax.security.auth.login.LoginException; +import javax.security.auth.x500.X500Principal; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -38,7 +39,7 @@ import org.eclipse.swt.widgets.Shell; /** Manages history and navigation */ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint - implements CmsSession { + implements CmsView { private final Log log = LogFactory.getLog(AbstractCmsEntryPoint.class); private final Subject subject; @@ -71,24 +72,27 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint final HttpSession httpSession = httpRequest.getSession(); AccessControlContext acc = (AccessControlContext) httpSession .getAttribute(KernelHeader.ACCESS_CONTROL_CONTEXT); - if (acc != null) + if (acc != null + && Subject.getSubject(acc).getPrincipals(X500Principal.class) + .size() == 1) { subject = Subject.getSubject(acc); - else + } else { subject = new Subject(); - // Initial login - try { - new ArgeoLoginContext(KernelHeader.LOGIN_CONTEXT_USER, subject) - .login(); - } catch (LoginException e) { - // if (log.isTraceEnabled()) - // log.trace("Cannot authenticate user", e); + // Initial login try { - new ArgeoLoginContext(KernelHeader.LOGIN_CONTEXT_ANONYMOUS, - subject).login(); - } catch (LoginException eAnonymous) { - throw new ArgeoException("Cannot initialize subject", - eAnonymous); + new ArgeoLoginContext(KernelHeader.LOGIN_CONTEXT_USER, subject) + .login(); + } catch (LoginException e) { + // if (log.isTraceEnabled()) + // log.trace("Cannot authenticate user", e); + try { + new ArgeoLoginContext(KernelHeader.LOGIN_CONTEXT_ANONYMOUS, + subject).login(); + } catch (LoginException eAnonymous) { + throw new ArgeoException("Cannot initialize subject", + eAnonymous); + } } } authChange(); @@ -118,7 +122,7 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint @Override protected final void createContents(final Composite parent) { - getShell().getDisplay().setData(CmsSession.KEY, this); + getShell().getDisplay().setData(CmsView.KEY, this); Subject.doAs(subject, new PrivilegedAction() { @Override public Void run() { @@ -234,17 +238,17 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint }); } - @Override - public Object local(Msg msg) { - String key = msg.getId(); - int lastDot = key.lastIndexOf('.'); - String className = key.substring(0, lastDot); - String fieldName = key.substring(lastDot + 1); - Locale locale = RWT.getLocale(); - ResourceBundle rb = ResourceBundle.getBundle(className, locale, - msg.getClassLoader()); - return rb.getString(fieldName); - } + // @Override + // public Object local(Msg msg) { + // String key = msg.getId(); + // int lastDot = key.lastIndexOf('.'); + // String className = key.substring(0, lastDot); + // String fieldName = key.substring(lastDot + 1); + // Locale locale = RWT.getLocale(); + // ResourceBundle rb = ResourceBundle.getBundle(className, locale, + // msg.getClassLoader()); + // return rb.getString(fieldName); + // } /** Sets the state of the entry point and retrieve the related JCR node. */ protected synchronized String setState(String newState) {