Package oshi.util

Class UserGroupInfo

java.lang.Object
oshi.util.UserGroupInfo

@ThreadSafe public final class UserGroupInfo extends Object
Utility class to temporarily cache the userID and group maps in *nix, for parsing process ownership. Cache expires after one minute.
  • Field Details

  • Constructor Details

    • UserGroupInfo

      private UserGroupInfo()
  • Method Details

    • isElevated

      public static boolean isElevated()
      Determine whether the current process has elevated permissions such as sudo / Administrator
      Returns:
      True if this process has elevated permissions
    • getUser

      public static String getUser(String userId)
      Gets a user from their ID
      Parameters:
      userId - a user ID
      Returns:
      a pair containing that user id as the first element and the user name as the second
    • getGroupName

      public static String getGroupName(String groupId)
      Gets the group name for a given ID
      Parameters:
      groupId - a String object.
      Returns:
      a String object.
    • getUserMap

      private static Map<String,String> getUserMap()
    • getentPasswd

      private static String getentPasswd(String userId)
    • parsePasswd

      private static Map<String,String> parsePasswd(List<String> passwd)
    • getGroupMap

      private static Map<String,String> getGroupMap()
    • getentGroup

      private static String getentGroup(String groupId)
    • parseGroup

      private static Map<String,String> parseGroup(List<String> group)