+
+ /** returns the local name of the current connected user */
+ public final static String getUsername(UserAdmin userAdmin) {
+ LdapName dn = getLdapName();
+ return getUsername(getUser(userAdmin, dn));
+ }
+
+ /** Returns true if the current user is in the specified role */
+ public static boolean isUserInRole(String role) {
+ Set<String> roles = CurrentUser.roles();
+ return roles.contains(role);
+ }
+
+ public final static boolean isCurrentUser(User user) {
+ String userName = getProperty(user, LdifName.dn.name());
+ try {
+ LdapName selfUserName = UiAdminUtils.getLdapName();
+ LdapName userLdapName = new LdapName(userName);
+ if (userLdapName.equals(selfUserName))
+ return true;
+ else
+ return false;
+ } catch (InvalidNameException e) {
+ throw new ArgeoException("User " + user + " has an unvalid dn: "
+ + userName, e);
+ }
+ }
+
+ public final static LdapName getLdapName() {