code: public static UnixUserGroupInformation login() throws LoginException {
      try {
        String userName;
  
        // if an exception occurs, then uses the
        // default user
        try {
          userName =  getUnixUserName();
        } catch (Exception e) {
          userName = DEFAULT_USERNAME;
        }
  
        // check if this user already has a UGI object in the ugi map
        UnixUserGroupInformation ugi = user2UGIMap.get(userName);
        if (ugi != null) {
          return ugi;
        }
  
        /* get groups list from UNIX. 
         * It's assumed that the first group is the default group.
         */
        String[]  groupNames;
  
        // if an exception occurs, then uses the
        // default group
        try {
          groupNames = getUnixGroups();
        } catch (Exception e) {
          groupNames = new String[1];
          groupNames[0] = DEFAULT_GROUP;
        }
  
        // construct a Unix UGI
        ugi = new UnixUserGroupInformation(userName, groupNames);
        user2UGIMap.put(ugi.getUserName(), ugi);
        return ugi;
      } catch (Exception e) {
        throw new LoginException("Login failed: "+e.getMessage());
      }
    }
docs: Get current user's name and the names of all its groups from Unix.
  It's assumed that there is only one UGI per user. If this user already
  has a UGI in the ugi map, return the ugi in the map.
  Otherwise get the current user's information from Unix, store it
  in the map, and return it.
  
  If the current user's UNIX username or groups are configured in such a way
  to throw an Exception, for example if the user uses LDAP, then this method
  will use a the {@link #DEFAULT_USERNAME} and {@link #DEFAULT_GROUP}
  constants.