org.moremotion.security
Class User

java.lang.Object
  extended by org.moremotion.security.User
All Implemented Interfaces:
java.lang.Comparable

public class User
extends java.lang.Object
implements java.lang.Comparable

Represent a user. A User has a user name, a password, a full name, an email, an account enabled/disabled flag, attributes and roles.

Version:
$Id: User.java 51 2008-03-10 11:46:54Z erkan $

Constructor Summary
User()
          Creates a new user.
User(java.lang.String name, java.lang.String password, java.lang.String email, java.lang.String fullname, boolean accDsbld)
          Creates a new user.
 
Method Summary
 void addRole(Role role)
          Adds a new role to this user.
 boolean authenticate(java.lang.String password)
          Authenticates the specified password agains the password of this user and returns true if they match.
 int compareTo(java.lang.Object obj)
          Compares this user to other.
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the specified user attribute.
 java.util.Properties getAttributes()
          Returns the attribute of this user.
 java.lang.String[] getCheckPointNames()
          Returns the names of the checkpoints that this user has.
 java.lang.String getEmail()
          Returns the email address of this user.
 java.lang.String getFullname()
          Returns the full name of this user.
 java.lang.String getId()
          Returns the database record identity of this user.
 long getLastReferredTime()
          Returns the last referred time.
 long getLModified()
          Returns the last modification time.
 java.lang.String getName()
          Returns the name of this user.
 java.lang.String getPassword()
          Returns the encrypted password of this user.
 Role[] getRoles()
          Returns roles of this user.
 long getSignInTime()
          Returns the sign in time.
 boolean hasCheckPoint(java.lang.String checkPoint)
          Checks the authority of user against a check point.
 boolean isAccountDisabled()
          Returns true if this user is disabled.
 void removeAttribute(java.lang.String name)
          Removes the specified attribute from this user.
 void removeRole(Role role)
          Removes a role from this user.
 void setAccountDisabled(boolean value)
          Sets the user account as enabled or disabled.
 void setAttribute(java.lang.String name, java.lang.String value)
          Sets a user attribute to this user.
 void setBroker(SecurityBroker broker)
          Sets the security broker to this object .
 void setEmail(java.lang.String email)
          Sets the email address of this user.
 void setFullname(java.lang.String fullname)
          Sets the full name of this user.
 void setId(java.lang.String value)
          Sets the database record identity of this user.
 void setLastReferredTime(long value)
          Sets the last referred time.
 void setLModified(long value)
          Sets the modification time.
 void setName(java.lang.String username)
          Sets the user name of this user.
 void setPassword(java.lang.String password)
          Encrypts the specified password and stores in this user.
 void setSignInTime(long value)
          Sets the sign in time.
 java.lang.String toString()
          Returns string representation of this user.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

User

public User()
Creates a new user.


User

public User(java.lang.String name,
            java.lang.String password,
            java.lang.String email,
            java.lang.String fullname,
            boolean accDsbld)
Creates a new user.

Parameters:
name - User name.
password - Encrypted Password.
email - Email.
fullname - Full name.
accDsbld - Account enabled/disabled flag. True for enabled, false for disabled.
Method Detail

setBroker

public void setBroker(SecurityBroker broker)
Sets the security broker to this object .


getLModified

public long getLModified()
Returns the last modification time.


setLModified

public void setLModified(long value)
Sets the modification time.


getSignInTime

public long getSignInTime()
Returns the sign in time.


setSignInTime

public void setSignInTime(long value)
Sets the sign in time.


getLastReferredTime

public long getLastReferredTime()
Returns the last referred time.


setLastReferredTime

public void setLastReferredTime(long value)
Sets the last referred time.


getAttributes

public java.util.Properties getAttributes()
Returns the attribute of this user.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Sets a user attribute to this user.


getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns the value of the specified user attribute.


removeAttribute

public void removeAttribute(java.lang.String name)
Removes the specified attribute from this user.


authenticate

public boolean authenticate(java.lang.String password)
Authenticates the specified password agains the password of this user and returns true if they match.


getRoles

public Role[] getRoles()
Returns roles of this user.


isAccountDisabled

public boolean isAccountDisabled()
Returns true if this user is disabled.


setAccountDisabled

public void setAccountDisabled(boolean value)
Sets the user account as enabled or disabled.


addRole

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


removeRole

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


getName

public java.lang.String getName()
Returns the name of this user.


getEmail

public java.lang.String getEmail()
Returns the email address of this user.


setName

public void setName(java.lang.String username)
Sets the user name of this user.


setEmail

public void setEmail(java.lang.String email)
Sets the email address of this user.


getPassword

public java.lang.String getPassword()
Returns the encrypted password of this user.


setPassword

public void setPassword(java.lang.String password)
Encrypts the specified password and stores in this user.


getFullname

public java.lang.String getFullname()
Returns the full name of this user.


setFullname

public void setFullname(java.lang.String fullname)
Sets the full name of this user.


getId

public java.lang.String getId()
Returns the database record identity of this user. Generally table row id.


setId

public void setId(java.lang.String value)
Sets the database record identity of this user. Generally table row id.

Note that: This method is used only by Security Brokers after retrieving the user info from database.


hasCheckPoint

public boolean hasCheckPoint(java.lang.String checkPoint)
Checks the authority of user against a check point.

Parameters:
checkPoint - CheckPoint.
Returns:
true if user has authority, false if not.

getCheckPointNames

public java.lang.String[] getCheckPointNames()
Returns the names of the checkpoints that this user has.


toString

public java.lang.String toString()
Returns string representation of this user.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares this user to other.

Specified by:
compareTo in interface java.lang.Comparable


Copyright © 2002-2008 MOR YAZILIM. All Rights Reserved.