From 37d2ce9041a34de28168bdeb8fcfcee9f4933e73 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Tue, 25 Oct 2016 15:31:18 +0000 Subject: [PATCH] git-svn-id: https://svn.argeo.org/commons/trunk@9283 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../cms/util/useradmin/UserAdminUtils.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/org.argeo.cms.ui/src/org/argeo/cms/util/useradmin/UserAdminUtils.java b/org.argeo.cms.ui/src/org/argeo/cms/util/useradmin/UserAdminUtils.java index 1c7ba0a6a..e157861f5 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/util/useradmin/UserAdminUtils.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/util/useradmin/UserAdminUtils.java @@ -19,13 +19,19 @@ import org.osgi.service.useradmin.UserAdmin; /** Centralise common patterns to manage users with a {@link UserAdmin} */ public class UserAdminUtils { - // SELF HELPERS - /** Simply checks if current user is registered */ + /** Checks if current user is registered */ public static boolean isRegistered() { return !CurrentUser.isAnonymous(); } - /** Simply checks if current user is the same as the passed one */ + /** Returns true if the current user is in the specified role */ + public static boolean isUserInRole(String role) { + Set roles = CurrentUser.roles(); + return roles.contains(role); + } + + // CURRENTUSER HELPERS + /** Checks if current user is the same as the passed one */ public static boolean isCurrentUser(User user) { String userUsername = getProperty(user, LdapAttrs.DN); LdapName userLdapName = getLdapName(userUsername); @@ -33,33 +39,27 @@ public class UserAdminUtils { return userLdapName.equals(selfUserName); } - /** Simply retrieves the current logged-in {@link User} */ + /** Retrieves the current logged-in {@link User} */ public static User getCurrentUser(UserAdmin userAdmin) { return (User) userAdmin.getRole(CurrentUser.getUsername()); } - /** Simply retrieves the current logged-in user {@link LdapName} */ + /** Retrieves the current logged-in user {@link LdapName} */ public final static LdapName getCurrentUserLdapName() { String name = CurrentUser.getUsername(); return getLdapName(name); } - /** Simply retrieves the current logged-in user display name. */ + /** Retrieves the current logged-in user display name. */ public static String getCurrentUserMail(UserAdmin userAdmin) { String username = CurrentUser.getUsername(); return getUserMail(userAdmin, username); } - /** Returns true if the current user is in the specified role */ - public static boolean isUserInRole(String role) { - Set roles = CurrentUser.roles(); - return roles.contains(role); - } - // OTHER USERS HELPERS /** - * Simply retrieves the local id of a user or group, that is respectively - * the uid or cn of the passed dn with no {@link UserAdmin} + * Retrieves the local id of a user or group, that is respectively the uid + * or cn of the passed dn with no {@link UserAdmin} */ public static String getUserLocalId(String dn) { LdapName ldapName = getLdapName(dn); @@ -119,7 +119,7 @@ public class UserAdminUtils { * Simply retrieves a LDAP name from a {@link LdapAttrs.DN} with no * exception */ - public static LdapName getLdapName(String dn) { + private static LdapName getLdapName(String dn) { try { return new LdapName(dn); } catch (InvalidNameException e) { -- 2.30.2