Package org.mycore.user2
Class MCRUser
java.lang.Object
org.mycore.user2.MCRUser
- All Implemented Interfaces:
Serializable
,Cloneable
,MCRUserInformation
- Direct Known Subclasses:
MCRTransientUser
Represents a login user. Each user has a unique numerical ID.
Each user belongs to a realm. The user name must be unique within a realm.
Any changes made to an instance of this class does not persist automatically.
Use
MCRUserManager.updateUser(MCRUser)
to achieve this.- Author:
- Frank Lützenkirchen, Thomas Scheffler (yagee), René Adler (eagle)
- See Also:
-
Field Summary
Fields inherited from interface org.mycore.common.MCRUserInformation
ATT_EMAIL, ATT_PRIMARY_GROUP, ATT_REAL_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
assignRole
(String roleName) Adds this user to the given role.clone()
void
Disable login for this user.void
Enable login for this user.boolean
Returns this MCRUser with basic information.Returns the E-Mail address of the person this login user represents.Returns a collection any external role ID this user is member of.getHint()
Returns a hint the user has stored in case of forgotten hash.Returns the last time the user has logged in.getOwner()
Returns the user that owns this user, or null if the user is independent and has no owner.getRealm()
Returns the realm the user belongs to.Returns the ID of the realm the user belongs to.Returns the name of the person this login user represents.Returns this MCRUser with safe information.getSalt()
Returns a collection any system role ID this user is member of.getUserAttribute
(String attribute) Returns additional user attributes.Returns the login user name.Returns aDate
when this user can not login anymore.int
hashCode()
boolean
Returns true if this user has no owner and therefore is independent.boolean
boolean
isLocked()
boolean
isUserInRole
(String role) boolean
Returns true if logins are allowed for this user.void
setAttributes
(SortedSet<MCRUserAttribute> attributes) void
setDisabled
(Boolean disabled) void
Sets the E-Mail address of the person this user represents.void
setHashType
(MCRPasswordHashType hashType) void
Sets a hint to store in case of hash loss.void
Sets the time of last login to now.void
setLastLogin
(Date lastLogin) Sets the time of last login.void
void
Sets the user that owns this user.void
setPassword
(String password) void
setRealName
(String realName) Sets the name of the person this login user represents.void
void
setUserAttribute
(String name, String value) void
setValidUntil
(Date validUntil) Sets aDate
when this user can not login anymore.void
unassignRole
(String roleName) Removes this user from the given role.
-
Constructor Details
-
MCRUser
protected MCRUser() -
MCRUser
Creates a new user.- Parameters:
userName
- the login user namemcrRealm
- the realm this user belongs to
-
MCRUser
Creates a new user.- Parameters:
userName
- the login user namerealmID
- the ID of the realm this user belongs to
-
MCRUser
Creates a new user in the default realm.- Parameters:
userName
- the login user name
-
-
Method Details
-
isLocked
public boolean isLocked() -
setLocked
-
isDisabled
public boolean isDisabled()- Returns:
- the disabled
-
setDisabled
- Parameters:
disabled
- the disabled to set
-
getUserName
Returns the login user name. The user name is unique within its realm.- Returns:
- the login user name.
-
getRealm
Returns the realm the user belongs to.- Returns:
- the realm the user belongs to.
-
getRealmID
Returns the ID of the realm the user belongs to.- Returns:
- the ID of the realm the user belongs to.
-
getPassword
- Returns:
- the hash
-
setPassword
- Parameters:
password
- the hash value to set
-
getSalt
- Returns:
- the salt
-
setSalt
- Parameters:
salt
- the salt to set
-
getHashType
- Returns:
- the hashType
-
setHashType
- Parameters:
hashType
- the hashType to set
-
getOwner
Returns the user that owns this user, or null if the user is independent and has no owner.- Returns:
- the user that owns this user.
-
setOwner
Sets the user that owns this user. Setting this to null makes the user independent.- Parameters:
owner
- the owner of the user.
-
hasNoOwner
public boolean hasNoOwner()Returns true if this user has no owner and therefore is independent. Independent users may change their passwords etc., owned users may not, they are created to limit read access in general.- Returns:
- true if this user has no owner
-
getRealName
Returns the name of the person this login user represents.- Returns:
- the name of the person this login user represents.
-
setRealName
Sets the name of the person this login user represents.- Parameters:
realName
- the name of the person this login user represents.
-
getEMailAddress
Returns the E-Mail address of the person this login user represents.- Returns:
- the E-Mail address of the person this login user represents.
-
setEMail
Sets the E-Mail address of the person this user represents.- Parameters:
eMail
- the E-Mail address
-
getHint
Returns a hint the user has stored in case of forgotten hash.- Returns:
- a hint the user has stored in case of forgotten hash.
-
setHint
Sets a hint to store in case of hash loss.- Parameters:
hint
- a hint for the user in case hash is forgotten.
-
getLastLogin
Returns the last time the user has logged in.- Returns:
- the last time the user has logged in.
-
setLastLogin
Sets the time of last login.- Parameters:
lastLogin
- the last time the user logged in.
-
setLastLogin
public void setLastLogin()Sets the time of last login to now. -
equals
-
hashCode
public int hashCode() -
getUserID
- Specified by:
getUserID
in interfaceMCRUserInformation
-
getUserAttribute
Returns additional user attributes. This methods handlesMCRUserInformation.ATT_REAL_NAME
and all attributes defined ingetAttributes()
.- Specified by:
getUserAttribute
in interfaceMCRUserInformation
-
isUserInRole
- Specified by:
isUserInRole
in interfaceMCRUserInformation
-
setAttributes
- Parameters:
attributes
- the attributes to set
-
getAttributes
-
getSystemRoleIDs
Returns a collection any system role ID this user is member of.- See Also:
-
getExternalRoleIDs
Returns a collection any external role ID this user is member of.- See Also:
-
assignRole
Adds this user to the given role.- Parameters:
roleName
- the role the user should be added to (must already exist)
-
unassignRole
Removes this user from the given role.- Parameters:
roleName
- the role the user should be removed from (must already exist)
-
enableLogin
public void enableLogin()Enable login for this user. -
disableLogin
public void disableLogin()Disable login for this user. -
loginAllowed
public boolean loginAllowed()Returns true if logins are allowed for this user. -
getValidUntil
Returns aDate
when this user can not login anymore. -
setValidUntil
Sets aDate
when this user can not login anymore.- Parameters:
validUntil
- the validUntil to set
-
setUserAttribute
-
clone
-
getBasicCopy
Returns this MCRUser with basic information. Same asgetSafeCopy()
but without these informations:- real name
- attributes
- role information
- last login
- valid until
- password hint
- Returns:
- a clone copy of this instance
-
getSafeCopy
Returns this MCRUser with safe information. Same asclone()
but without these informations:- password hash type
- password hash value
- password salt
- Returns:
- a clone copy of this instance
-