de.kosi.model
Class UserImpl

java.lang.Object
  |
  +--de.kosi.model.UserImpl
All Implemented Interfaces:
java.rmi.Remote, java.io.Serializable, User
Direct Known Subclasses:
ComputerPlayerUserImpl, GuestUserImpl

public class UserImpl
extends java.lang.Object
implements User, java.io.Serializable

The UserImpl class represents a User of the syste. It contains all neccessairy information about the user.

Version:
1.18 (2001/04/09 15:36:19) Log-Einträge : UserImpl.java,v Revision 1.18 2001/04/09 15:36:19 wombat Improved UserImpl, removed bugs Revision 1.17 2001/04/09 13:03:10 wombat Removed timeout from threadpool (did not work) Revision 1.16 2001/04/08 17:07:12 wombat Account Erstellung eingebaut Revision 1.15 2001/03/20 18:17:31 wombat Added logging support Revision 1.14 2001/03/19 21:50:49 wombat - Worked on admin client. - improved shutdown sequence - removed bugs in login/logout sequence Revision 1.13 2001/03/18 17:32:03 wombat Changed database concept Revision 1.12 2001/03/15 22:41:28 wombat - Worked on server admin client mockup - fixed smaller bugs - removed User.getPassword() method (use checkPassword instead) Revision 1.11 2001/03/14 13:46:34 wombat Worked on Admin Tool. Removed deadlock while killing session Revision 1.10 2001/03/09 11:15:03 wombat Updated documentation. Revision 1.9 2001/03/08 17:12:27 wombat Implemented User database Revision 1.8 2001/03/07 14:57:51 wombat worked on database Revision 1.7 2001/03/07 14:15:06 wombat started database implementation Revision 1.6 2001/02/25 23:16:05 wombat - deadlock vermeidung umgestellt. - ListenerList erstellt Revision 1.5 2001/02/11 17:11:29 login documented class UserImpl Revision 1.4 2001/02/09 21:50:01 login updated docs Revision 1.3 2001/02/04 17:12:59 wombat - updated Documentation - continued implementation of UserManger Revision 1.2 2001/01/30 16:32:26 wombat started implementation of UserManager, FoyerListener, UserListener Revision 1.1 2001/01/19 17:50:52 wombat Anfang Umsetzung Entwurf Revision 1.3 2000/12/21 13:05:51 wombat - dokumentiert - fehler in xmi/kosi.argo
Author:
Timo, Niklas, Ole
See Also:
Serialized Form

Fields inherited from interface de.kosi.model.User
STRENGTH_ADVANCED, STRENGTH_BEGINNER, STRENGTH_PROFESSIONAL
 
Constructor Summary
UserImpl(java.lang.String loginname, java.lang.String eMail, java.util.Locale locale, int strength, java.util.TimeZone timeZone, java.lang.String biddingSystem)
          Creates a new User and sends him his password with an e-mail.
UserImpl(java.lang.String loginname, java.lang.String password, java.lang.String eMail, boolean admin)
          Creates a new User.
 
Method Summary
 void addUserListener(UserListener listener)
          Adds a user listener to this User instance.
 boolean checkPassword(java.lang.String password)
          Checks the password.
protected static java.lang.String createRandomPassword()
          Create a random password.
 void destroy()
          Destroy this user instance.
 boolean equals(java.lang.Object obj)
          Two User objects are equal, if the loginnames are equal.
 Conventions getConventions()
          Returns the Conventions of the user.
 java.lang.String getEMail()
          Returns the e-mail address.
 java.util.Locale getLocale()
          Returns the locale.
 java.lang.String getLoginName()
          Returns the login name of the user.
protected  java.lang.String getPassword()
           
 Session getSession()
          Returns the session that is currently assigned to this user.
 int getStrength()
          Returns the strength of the user.
 java.util.TimeZone getTimeZone()
          Returns the time zone.
 boolean isAdmin()
          Reutrns if this user is an admin.
 boolean isOnline()
          Checks whether this user is currently online or not.
 void removeUserListener(UserListener listener)
          Removes a user listener from the list of user listeners.
 void sendMail(java.lang.String text, java.lang.Object[] params)
          Send an email to this user.
 void setEMail(java.lang.String email)
          Sets the e-mail address.
 void setLocale(java.util.Locale locale)
          Sets the locale of the user.
 void setOnline(boolean online)
          Sets whether this user is currently online or offline.
 void setPassword(java.lang.String password, java.lang.String oldPassword)
          Sets the password.
 void setSession(Session session)
          Sets the session of this user.
 void setStrength(int strength)
          Set the strength of the user.
 void setTimeZone(java.util.TimeZone timeZone)
          Sets the time zone of the user.
 java.lang.String toString()
          Returns a String representation of the user.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserImpl

public UserImpl(java.lang.String loginname,
                java.lang.String password,
                java.lang.String eMail,
                boolean admin)
         throws java.lang.IllegalArgumentException
Creates a new User.
Parameters:
loginname - The loginname of the user.
password - The password of the user.
eMail - The e-mail address of the user.
admin - Wether this user is an administrator.
Throws:
java.lang.IllegalArgumentException - If an parameter does not contain a valid value.

UserImpl

public UserImpl(java.lang.String loginname,
                java.lang.String eMail,
                java.util.Locale locale,
                int strength,
                java.util.TimeZone timeZone,
                java.lang.String biddingSystem)
         throws javax.mail.MessagingException
Creates a new User and sends him his password with an e-mail.
Parameters:
loginname - Loginname of the user.
eMail - eMail address of the user.
locale - Locale of the user.
strength - Strength of the user (one of the User.STRENGHT_* constants).
timeZone - Time zone the user lives in.
biddingSystem - Bidding system. This is used to set up first conventions for the user.
Throws:
javax.mail.MessagingException - If the E-Mail could not be sent.
Method Detail

createRandomPassword

protected static java.lang.String createRandomPassword()
Create a random password.
Returns:
A random String.

getLoginName

public java.lang.String getLoginName()
Returns the login name of the user.
Specified by:
getLoginName in interface User
Returns:
The login name of the user.

checkPassword

public boolean checkPassword(java.lang.String password)
                      throws KosiAccessException
Checks the password.
Specified by:
checkPassword in interface User
Parameters:
password - The password.
Returns:
true if password is correct.
Throws:
KosiAccessException - if not called by the user himself or an admin.

getPassword

protected java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password,
                        java.lang.String oldPassword)
                 throws KosiAccessException,
                        InvalidSessionException,
                        PasswordException
Sets the password.
Specified by:
setPassword in interface User
Parameters:
password - The new password.
oldPassword - The old password used to verify, that the user knows the password.
Throws:
KosiAccessException - If not called by the user himself or an admin.
InvalidSessionException - If not called from a valid session context.

setEMail

public void setEMail(java.lang.String email)
              throws KosiAccessException,
                     InvalidSessionException
Sets the e-mail address.
Specified by:
setEMail in interface User
Parameters:
email - the new e-mail address.
Throws:
KosiAccessException - if not called by the user himself or an admin.
InvalidSessionException - If not called from a valid session context.

getEMail

public java.lang.String getEMail()
                          throws KosiAccessException,
                                 InvalidSessionException
Returns the e-mail address.
Specified by:
getEMail in interface User
Returns:
The e-mail address.
Throws:
KosiAccessException - If not called by the user himself or an admin.
InvalidSessionException - If not called from a valid session context.

setLocale

public void setLocale(java.util.Locale locale)
               throws KosiAccessException,
                      InvalidSessionException
Sets the locale of the user. The locale can be used to format dates etc.
Specified by:
setLocale in interface User
Parameters:
locale - The new Locale.
Throws:
KosiAccessException - if not called by the user himself or an admin.
InvalidSessionException - If not called from a valid session context.

getLocale

public java.util.Locale getLocale()
Returns the locale.
Specified by:
getLocale in interface User
Returns:
The locale.

setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
                 throws KosiAccessException,
                        InvalidSessionException
Sets the time zone of the user.
Specified by:
setTimeZone in interface User
Parameters:
timeZone - th.
Throws:
KosiAccessException - if not called by the user himself or an admin.
InvalidSessionException - If not called from a valid session context.

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone.
Specified by:
getTimeZone in interface User
Returns:
The time zone.

getStrength

public int getStrength()
Returns the strength of the user.
Specified by:
getStrength in interface User
Returns:
One of the STRENGTH_* constants.

setStrength

public void setStrength(int strength)
                 throws KosiAccessException,
                        InvalidSessionException
Set the strength of the user.
Specified by:
setStrength in interface User
Parameters:
strength - One of the STRENGTH_* constants.
Throws:
KosiAccessException - if not called by the user himself or an admin.
InvalidSessionException - If not called from a valid session context.

getConventions

public Conventions getConventions()
Returns the Conventions of the user.
Specified by:
getConventions in interface User
Returns:
Conventions of the user.

addUserListener

public void addUserListener(UserListener listener)
Adds a user listener to this User instance.
Parameters:
listener - The UserListener to add to the list of listeners.

removeUserListener

public void removeUserListener(UserListener listener)
Removes a user listener from the list of user listeners.
Parameters:
listener - The user listener that is to be removed.

setSession

public void setSession(Session session)
Sets the session of this user.
Parameters:
session - The session to assign to this user.

getSession

public Session getSession()
Returns the session that is currently assigned to this user.
Returns:
The session currently assigned to this user.

sendMail

public void sendMail(java.lang.String text,
                     java.lang.Object[] params)
              throws javax.mail.MessagingException
Send an email to this user.
Parameters:
text - Name of the Text for this mail (the actual text and subject are loaded from a ResourceBundle):
params - Parameters, that can be used in the mail (see java.text.MessageFormat for further information)
Throws:
javax.mail.MessagingException - If the email could not be sent.

setOnline

public void setOnline(boolean online)
Sets whether this user is currently online or offline.
Parameters:
online - true if the user is going online, otherwise false.

destroy

public void destroy()
Destroy this user instance. This method must explicitely be called to notify each listener that this user instance is not valid any more.

isOnline

public boolean isOnline()
Checks whether this user is currently online or not.
Returns:
true if the user is currently online, otherwise false.

isAdmin

public boolean isAdmin()
Reutrns if this user is an admin.
Returns:
true if admin.

toString

public java.lang.String toString()
Returns a String representation of the user.
Overrides:
toString in class java.lang.Object
Returns:
The user represented by his loginname.

equals

public boolean equals(java.lang.Object obj)
Two User objects are equal, if the loginnames are equal.
Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare.
Returns:
true if this object is equal to obj.