Package com.xpn.xwiki.api
Class User
- java.lang.Object
-
- com.xpn.xwiki.api.Api
-
- com.xpn.xwiki.api.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: c81b109e4c94fbd16b9c63f6afd3bde6e4b768d2 $
-
-
Constructor Summary
Constructors Constructor Description User(XWikiUser user, XWikiContext context)
Constructs a wrapper for the given protected XWikiUser object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkPassword(String password)
Check if the password passed as argument is the user password.String
getEmail()
API to retrieve the e-mail address of this user.XWikiUser
getUser()
Expose the wrapped XWikiUser object.boolean
isDisabled()
protected boolean
isMain()
See if the user is global (i.e.boolean
isUserInGroup(String groupName)
Check if the user belongs to a group or not.void
setDisabledStatus(boolean disabledStatus)
Set the disabled status of a user.-
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
-
-
-
-
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 currentcontext
.
-
-
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.
-
-