]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/util/UserMenuLink.java
Authentication working for workbench, web and data.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / util / UserMenuLink.java
index f4c5f006305deeaff642958046c615239a169cdf..e8fd556bfe7f71302f16e40c20f7fe4751c239ff 100644 (file)
@@ -1,11 +1,12 @@
 package org.argeo.cms.util;
 
 import javax.jcr.Node;
+import javax.security.auth.Subject;
 
 import org.argeo.cms.CmsMsg;
 import org.argeo.cms.CmsStyles;
 import org.argeo.cms.auth.AuthConstants;
-import org.argeo.security.SecurityUtils;
+import org.argeo.cms.auth.CurrentUser;
 import org.eclipse.swt.events.DisposeEvent;
 import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.events.MouseEvent;
@@ -23,13 +24,12 @@ public class UserMenuLink extends MenuLink {
 
        @Override
        public Control createUi(Composite parent, Node context) {
-               String username = SecurityUtils.getUsername(CmsUtils.getCmsView()
-                               .getSubject());
+               Subject subject = CmsUtils.getCmsView().getSubject();
+               String username = CurrentUser.getUsername(subject);
                if (username.equalsIgnoreCase(AuthConstants.ROLE_ANONYMOUS))
                        setLabel(CmsMsg.login.lead());
                else {
-                       setLabel(SecurityUtils.getDisplayName(CmsUtils.getCmsView()
-                                       .getSubject()));
+                       setLabel(CurrentUser.getDisplayName(subject));
                }
                Label link = (Label) ((Composite) super.createUi(parent, context))
                                .getChildren()[0];
@@ -38,7 +38,7 @@ public class UserMenuLink extends MenuLink {
        }
 
        protected UserMenu createUserMenu(Control source) {
-               return new UserMenu(source.getParent());
+               return new UserMenu(source.getParent(), true);
        }
 
        private class UserMenuLinkController implements MouseListener,
@@ -61,7 +61,7 @@ public class UserMenuLink extends MenuLink {
                                        // avoid to reopen the menu, if one has clicked gain
                                        if (durationSinceLastDispose > 200) {
                                                userMenu = createUserMenu(source);
-                                               userMenu.addDisposeListener(this);
+                                               userMenu.getShell().addDisposeListener(this);
                                        }
                                }
                        }