Class User


  • public class User
    extends Api
    Scriptable API for easy handling of users. For the moment this API is very limited, containing only one method. In the future it should be extended to provide useful methods for working with users.
    Since:
    1.0
    Version:
    $Id: c2f55f1b19af126e9dbe66473401a677061d6954 $
    • Field Detail

      • LOGGER

        protected static final org.slf4j.Logger LOGGER
        Logging helper object.
    • Constructor Detail

      • User

        public User​(XWikiUser user,
                    XWikiContext context)
        Constructs a wrapper for the given protected XWikiUser object.
        Parameters:
        user - The XWikiUser object that should be wrapper.
        context - The current context.
    • Method Detail

      • getUser

        @Programming
        public XWikiUser getUser()
        Expose the wrapped XWikiUser object. Requires programming rights.
        Returns:
        The wrapped XWikiUser object, or null if the user does not have programming rights.
      • setDisabledStatus

        public void setDisabledStatus​(boolean disabledStatus)
        Set the disabled status of a user.
        Parameters:
        disabledStatus - true to disable an user, false to enable it back.
        Since:
        11.7RC1
      • isDisabled

        public boolean isDisabled()
        Returns:
        true if the user is disabled, false if it is enabled.
        Since:
        11.8RC1
      • isUserInGroup

        public boolean isUserInGroup​(String groupName)
        Check if the user belongs to a group or not. This method only check direct membership (no recursive checking) in the current wiki.
        Parameters:
        groupName - The group to check.
        Returns:
        true if the user does belong to the specified group, false otherwise or if an exception occurs.
      • isMain

        protected boolean isMain()

        See if the user is global (i.e. registered in the main wiki) or local to a virtual wiki.

        This method is not public, as the underlying implementation is not fully functional

        Returns:
        true if the user is global, false otherwise or if an exception occurs.
      • getEmail

        public String getEmail()
        API to retrieve the e-mail address of this user. This e-mail address is taken from the user profile. If the user hasn't changed his profile, then this is the e-mail address he filled in the registration form.
        Returns:
        The e-mail address from the user profile, or null if there is an error retrieving the email.
        Since:
        1.1.3, 1.2.2, 1.3M2
      • checkPassword

        public boolean checkPassword​(String password)
                              throws XWikiException
        Check if the password passed as argument is the user password. This method is used when a user wants to change its password. To make sure that it wouldn't be used to perform brute force attacks, we ensure that this is only used to check the current user password on its profile page.
        Parameters:
        password - Password submitted.
        Returns:
        true if password is really the user password.
        Throws:
        XWikiException - error if authorization denied.