corelib.security
Class User

java.lang.Object
  extended by corelib.security.User
Direct Known Subclasses:
AuthentifiedUser

public class User
extends java.lang.Object

This class represents the concept of user for a considered computer system. A user has a number of attributes and a set of roles assigned to it.

Note: you cannot directly create a User. Instead of, use an UserManager instance.

Since:
0.3.6
Author:
Dominique Liard
See Also:
Role, RoleManager, SecurityManager, UserManager

Method Summary
 void addRole(Role role)
          Adds another role to this user.
 int getConnectionNumber()
          Returns the connection number of this user.
 int getConsecutiveError()
          Returns the consecutive error number
 int getIdentifier()
          Return the identifier of this user.
 java.util.Date getLastConnection()
          Returns the date and the time of the last connection for this user.
 java.lang.String getLogin()
          Returns the user login.
 java.util.Set<Role> getRoles()
          Returns a set of all roles associated to this user..
 boolean isDisabled()
          Returns if the user account is disabled.
 boolean isMemberOfRole(Role role)
          Checks is this user is associated to the specified role.
 boolean isSamePassword(java.lang.String password)
          Check if the encripted string (for the specified password) is the same that the encripted password store in the used security system (certainly a relational database).
 void removeRole(Role role)
          Removes a role to this user.
 void setConsecutiveError(int consecutiveError)
          Set the consecutive error number.
 void setDisabled(boolean isDisabled)
          Set the disabled state for this user.
 void setPassword(java.lang.String newPassword)
          Set the new password for this user.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getIdentifier

public int getIdentifier()
Return the identifier of this user. Normaly, this identified is used as the primary key in the security storage engine (certainly a relational database). It must be unique within the database. Therefore, you cannot change the user identifier's.

Returns:
The user identifier.

getLogin

public java.lang.String getLogin()
Returns the user login.

Returns:
The user login.

isSamePassword

public boolean isSamePassword(java.lang.String password)
                       throws SecurityManagerException
Check if the encripted string (for the specified password) is the same that the encripted password store in the used security system (certainly a relational database).

Parameters:
password - The clear password to compare
Returns:
true if encripted version of the password is the same that the user encripted password. false otherwise.
Throws:
SecurityManagerException - Thrown if passwords cannot be compared.
See Also:
setPassword(String)

setPassword

public void setPassword(java.lang.String newPassword)
                 throws SecurityManagerException
Set the new password for this user. Note that the password is stored in encripted format.

Parameters:
newPassword - The new password for this user.
Throws:
SecurityManagerException - Thrown if security system cannot change the password.
See Also:
isSamePassword(String)

getConnectionNumber

public int getConnectionNumber()
Returns the connection number of this user. The connection number is increased as each connection time.

Returns:
The actual connection number.
See Also:
setConnectionNumber( int ), UserManager.checkCredentials(String, String)

getLastConnection

public java.util.Date getLastConnection()
Returns the date and the time of the last connection for this user.

Returns:
The date of the last connection.
See Also:
setLastConnection( Date )

isDisabled

public boolean isDisabled()
Returns if the user account is disabled.

Returns:
true is the user account is disabled, false otherwise.
See Also:
setDisabled( boolean )

setDisabled

public void setDisabled(boolean isDisabled)
Set the disabled state for this user.

Parameters:
isDisabled - The disabled state.
See Also:
isDisabled()

getConsecutiveError

public int getConsecutiveError()
Returns the consecutive error number

Returns:
The consecutive error number.
See Also:
setConsecutiveError( int )

setConsecutiveError

public void setConsecutiveError(int consecutiveError)
Set the consecutive error number.

Parameters:
consecutiveError - The consecutive error value.
See Also:
getConsecutiveError()

isMemberOfRole

public boolean isMemberOfRole(Role role)
Checks is this user is associated to the specified role.

Parameters:
role - The expected role.
Returns:
true is this user has the specified role, false otherwize.

getRoles

public java.util.Set<Role> getRoles()
Returns a set of all roles associated to this user..

Returns:
The set of roles.

addRole

public void addRole(Role role)
Adds another role to this user.

Parameters:
role - The new role to affect for this user.

removeRole

public void removeRole(Role role)
Removes a role to this user.

Parameters:
role - The role to remove for this user.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


CAUTION: Ellipse is proposed to you in BETA version to allow evaluation of this framework. Infini Software is released from any responsibility for the use of Ellipse Framework.

Copyright 2012 Infini Software - All Rights Reserved.