git-svn-id: https://svn.argeo.org/commons/trunk@9283 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc
authorBruno Sinou <bsinou@argeo.org>
Tue, 25 Oct 2016 15:31:18 +0000 (15:31 +0000)
committerBruno Sinou <bsinou@argeo.org>
Tue, 25 Oct 2016 15:31:18 +0000 (15:31 +0000)
org.argeo.cms.ui/src/org/argeo/cms/util/useradmin/UserAdminUtils.java

index 1c7ba0a6aab339db83f009ff2a47a02335a65eec..e157861f55ad4397429689b9147ea0afc4a881d1 100644 (file)
@@ -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<String> 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<String> 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) {