org.musicontroller.security
Class User

java.lang.Object
  extended by org.musicontroller.security.User
All Implemented Interfaces:
java.io.Serializable, org.acegisecurity.userdetails.UserDetails, IUser

public class User
extends java.lang.Object
implements IUser

Implements a User

Version:
$Id: User.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
Author:
Arjan Verstoep
See Also:
Serialized Form

Constructor Summary
User()
          Creates a new non-expired, non-locked, non-disabled User-object with an empty loginname and an empty username.
 
Method Summary
 void addRole(Role role)
          Adds a Role to the set of Roles of this User.
 boolean equals(java.lang.Object o)
           
 org.acegisecurity.GrantedAuthority[] getAuthorities()
           
 java.util.Date getExpiryDate()
           
 long getId()
          The unique identifier that can be used to distinguish different Users from eachother.
 java.lang.String getLoginname()
           
 java.lang.String getName()
           
 java.lang.String getPassword()
          Gets the encrypted version of this Users password.
 java.util.Set<Role> getRoles()
           
 java.util.List<Role> getRolesList()
          Convenience method to get the roles in List form.
 java.lang.String getUsername()
           
 int hashCode()
           
 boolean hasRole(java.lang.String roledescription)
          Returns whether or not this User has a certain role.
 boolean isAccountNonExpired()
           
 boolean isAccountNonLocked()
           
 boolean isAdmin()
           
 boolean isCredentialsNonExpired()
           
 boolean isEnabled()
           
 void setAccountNonLocked(boolean nonLocked)
           
 void setCredentialsNonExired(boolean nonExpired)
           
 void setDisabledMessage(java.lang.String message)
          When the disabledmessage is set, the User is automatically disabled, and cannot logon.
 void setExpiryDate(java.util.Date expiryDate)
          Sets the expirydate of this User.
 void setId(long id)
          Sets the identifier of the User.
 void setLoginname(java.lang.String loginname)
          Sets the loginname for this User.
 void setName(java.lang.String name)
          Set the real name of this User.
 void setPassword(java.lang.String encryptedPassword)
          Sets the encrypted version of this Users password.
 void setRoles(java.util.Set<Role> roles)
          Set the Roles which this User is assigned to.
 void setRolesList(java.util.List<Role> roles)
          Convenience method to set the roles in List form.
 void setUnencryptedPassword(java.lang.String unencryptedpass)
          Sets the password for a User.
 java.lang.String toString()
          A short description of the user, fit for human consumption.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

User

public User()
Creates a new non-expired, non-locked, non-disabled User-object with an empty loginname and an empty username. This new object cannot be used to login before the password is set using the setUnencryptedPassword-method, and being persisted using the UserDao.

See Also:
UserDao, IUser, Encrypter, Role, Authority
Method Detail

setId

public void setId(long id)
Description copied from interface: IUser
Sets the identifier of the User.

Specified by:
setId in interface IUser
Parameters:
id - an integer.

getId

public long getId()
Description copied from interface: IUser
The unique identifier that can be used to distinguish different Users from eachother.

Specified by:
getId in interface IUser
Returns:
The unique Id that is connected with this User, or -1 if the User has not been persisted yet.

isAccountNonExpired

public boolean isAccountNonExpired()
Specified by:
isAccountNonExpired in interface org.acegisecurity.userdetails.UserDetails

setExpiryDate

public void setExpiryDate(java.util.Date expiryDate)
Description copied from interface: IUser
Sets the expirydate of this User. After this date, the User will no longer be able to logon.

Specified by:
setExpiryDate in interface IUser

getExpiryDate

public java.util.Date getExpiryDate()
Specified by:
getExpiryDate in interface IUser
Returns:
The Date after which this User is no longer permitted to logon.

isAccountNonLocked

public boolean isAccountNonLocked()
Specified by:
isAccountNonLocked in interface org.acegisecurity.userdetails.UserDetails

setAccountNonLocked

public void setAccountNonLocked(boolean nonLocked)

getAuthorities

public org.acegisecurity.GrantedAuthority[] getAuthorities()
Specified by:
getAuthorities in interface org.acegisecurity.userdetails.UserDetails

isAdmin

public boolean isAdmin()
Returns:
True if this User is an Admin.

hasRole

public boolean hasRole(java.lang.String roledescription)
Returns whether or not this User has a certain role.

Parameters:
roledescription - The description of the role, such as ROLE_USER
Returns:
True, if this User has the specified role.

setRoles

public void setRoles(java.util.Set<Role> roles)
Description copied from interface: IUser
Set the Roles which this User is assigned to.

Specified by:
setRoles in interface IUser
Parameters:
roles - The Roles.

getRoles

public java.util.Set<Role> getRoles()
Specified by:
getRoles in interface IUser
Returns:
All Role-objects assigned to this User.

addRole

public void addRole(Role role)
Description copied from interface: IUser
Adds a Role to the set of Roles of this User.

Specified by:
addRole in interface IUser
Parameters:
role - The Role to add

isCredentialsNonExpired

public boolean isCredentialsNonExpired()
Specified by:
isCredentialsNonExpired in interface org.acegisecurity.userdetails.UserDetails

setCredentialsNonExired

public void setCredentialsNonExired(boolean nonExpired)

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface org.acegisecurity.userdetails.UserDetails

getPassword

public java.lang.String getPassword()
Description copied from interface: IUser
Gets the encrypted version of this Users password.

Specified by:
getPassword in interface org.acegisecurity.userdetails.UserDetails
Specified by:
getPassword in interface IUser

setPassword

public void setPassword(java.lang.String encryptedPassword)
Description copied from interface: IUser
Sets the encrypted version of this Users password.

Specified by:
setPassword in interface IUser
Parameters:
encryptedPassword - The encrypted password.

getUsername

public java.lang.String getUsername()
Specified by:
getUsername in interface org.acegisecurity.userdetails.UserDetails

getLoginname

public java.lang.String getLoginname()
Specified by:
getLoginname in interface IUser
Returns:
The loginname of this User.

setLoginname

public void setLoginname(java.lang.String loginname)
Description copied from interface: IUser
Sets the loginname for this User.

Specified by:
setLoginname in interface IUser
Parameters:
loginname - The loginname. It is advisable to use only lowercase letters in the loginname.

getName

public java.lang.String getName()
Specified by:
getName in interface IUser
Returns:
The real name of this User.

setName

public void setName(java.lang.String name)
Description copied from interface: IUser
Set the real name of this User.

Specified by:
setName in interface IUser
Parameters:
name - The name.

setDisabledMessage

public void setDisabledMessage(java.lang.String message)
When the disabledmessage is set, the User is automatically disabled, and cannot logon.

Parameters:
message - A message specifying why the user is disabled.

setUnencryptedPassword

public void setUnencryptedPassword(java.lang.String unencryptedpass)
Description copied from interface: IUser
Sets the password for a User. This will encrypt the given password and fill the encrypted password with the encrypted version of the supplied password.

Specified by:
setUnencryptedPassword in interface IUser
Parameters:
unencryptedpass - The unencryted password.

toString

public java.lang.String toString()
A short description of the user, fit for human consumption. Note: This name need not be unique.

Overrides:
toString in class java.lang.Object
Returns:
The users' name.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getRolesList

public java.util.List<Role> getRolesList()
Description copied from interface: IUser
Convenience method to get the roles in List form.

Specified by:
getRolesList in interface IUser
Returns:
All Role-objects assigned to this User.

setRolesList

public void setRolesList(java.util.List<Role> roles)
Description copied from interface: IUser
Convenience method to set the roles in List form.

Specified by:
setRolesList in interface IUser
Parameters:
roles - The Roles.


Copyright © 2010 A.J.V.. All Rights Reserved.