Merge security.ui bundle in the cms.ui.workbench bundle
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / util / UserMenuLink.java
index f4c5f006305deeaff642958046c615239a169cdf..1b7ca03f44f2fcc937498a208d6274840a9947b5 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];
@@ -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);
                                        }
                                }
                        }