|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.locomotive.loco.User
The User object encapsulates information stored for a user in the Locomotive User Management system. It is passed to modules as a member of the the HandlerData Object. The user can be "anonymous", or can be a specific user whose content is persistantly stored in the User Database. Modules wishing to store additional module-specific data based on users should use the userid field as a key. If the current session is non-anonymous (aka "authenticated"), the User object will contain pre-loaded user specific data. Given that it will be loaded every hit, the User object only contains the most important data, for performance reasons.
Field Summary | |
static int |
ANONYMOUS_ID
|
static java.lang.String |
ANONYMOUS_NAME
|
static int |
LOCO_FLAGS_CAN_CHANGE_LOCO_VARS
|
static int |
LOCO_FLAGS_CAN_EDIT_USER_PREFS
|
static int |
LOCO_FLAGS_CAN_SHUT_DOWN_LOCO
|
static int |
LOCO_FLAGS_CAN_VIEW_SERVER_STATUS
|
static int |
LOCO_FLAGS_CAN_VIEW_USER_PREFS
|
static int |
LOCO_FLAGS_DEFAULT
|
static int |
MIN_ID
|
static int |
NULL_USERID
|
Constructor Summary | |
User()
create an anonymous User |
|
User(java.sql.Connection conn,
int uid)
loads persistant User data from the user database. |
|
User(java.sql.Connection conn,
int uid,
java.lang.String un,
java.lang.String pword,
int locoflg)
creates User and persistantly stores User's data. |
|
User(java.sql.Connection conn,
int uid,
java.lang.String un,
java.lang.String pword,
java.lang.String fn,
java.lang.String ln,
int flg,
int locoflg)
Deprecated. thanks to schema changes for the loco_user table. fn, ln, flg are all now ignored. |
|
User(java.sql.Connection conn,
java.lang.String un)
loads persistant User data from the user database. |
|
User(java.sql.Connection conn,
java.lang.String un,
boolean sensitiveToCase)
loads persistant User data from the user database. |
|
User(int uid,
java.lang.String un,
java.lang.String pword,
int locoflg)
used internally by loadUsers (Connection, int[]) to create the heap of individual User objects. |
Method Summary | |
boolean |
canChangeLocoVars()
|
boolean |
canEditUserPrefs()
|
boolean |
canShutDownLoco()
|
boolean |
canViewServerStatus()
|
boolean |
canViewUserPrefs()
|
boolean |
equals(java.lang.Object o)
overrides Object.equals for User specific checking |
static boolean |
exists(java.sql.Connection conn,
int id)
returns true if a user with this userid exists in the user database |
static boolean |
exists(java.sql.Connection conn,
java.lang.String un)
returns true if a user in the user database has the same name |
static boolean |
existsAnyCase(java.sql.Connection conn,
java.lang.String un)
returns true if a user in the user database has the same name, regardless of case. |
static java.lang.String |
generateNewPassword(int seedmodifier)
Generates a character sequence of length 8 suitable for a password (though probably not easy to remember) |
int |
getAnonymousUserid()
gets the userid of the Anonymous User |
java.lang.String |
getAnonymousUsername()
gets the username of the Anonymous User |
int |
getLocoFlags()
gets the value for this User's Loco-specific flags |
java.lang.String |
getPassword()
returns the value of the User's password Note that later this might be made package accessable only |
int |
getUserid()
gets the userid of this User |
java.lang.String |
getUsername()
gets username of this User |
static java.lang.String |
getUsername(java.sql.Connection conn,
int userid)
Given a userid, return the username |
static java.util.Vector |
getUsernames(java.sql.Connection conn,
java.util.Vector userids)
Given a vector of Integer-ized userids, look up each username for them. |
boolean |
hasPassword(java.lang.String pwtry)
tests to see if the stored password is equivalent to the input |
boolean |
hasPasswordAnyCase(java.lang.String pwtry)
tests to see if the stored password is equivalent to the input in any case (i.e. |
protected static void |
initialize()
initializes the config object. |
boolean |
isAnonymous()
checks whether this user is an anonymous user. |
static java.lang.String[] |
loadAllUserNames(java.sql.Connection conn)
Returns an array of all the user names in the database. |
static User[] |
loadUsers(java.sql.Connection conn,
int[] userids)
Searches the user database and returns a list of Users, based upon userid. |
void |
save(java.sql.Connection conn)
Updates the User data in the database if changes have been made, silently ignored on anonymous users |
void |
saveLoginTime(java.sql.Connection conn)
Updates the user.last_login field in the database. |
void |
setLocoFlags(int newlocoflags)
sets the loco_flags value for this User |
void |
setPassword(java.lang.String pw)
sets the password value for this User |
void |
setUsername(java.lang.String un)
sets the username value for this User Note: this may be made package friendly only in the future |
java.lang.String |
toString()
Returns the userid and username |
void |
valueBound(javax.servlet.http.HttpSessionBindingEvent hsbe)
If the name of the event is 'locomotive.user', this will go ahead and associate this user with this session in the database. |
void |
valueUnbound(javax.servlet.http.HttpSessionBindingEvent hsbe)
We don't really need to do anything here |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int LOCO_FLAGS_DEFAULT
public static final int LOCO_FLAGS_CAN_SHUT_DOWN_LOCO
public static final int LOCO_FLAGS_CAN_VIEW_SERVER_STATUS
public static final int LOCO_FLAGS_CAN_CHANGE_LOCO_VARS
public static final int LOCO_FLAGS_CAN_VIEW_USER_PREFS
public static final int LOCO_FLAGS_CAN_EDIT_USER_PREFS
public static final int NULL_USERID
public static final int ANONYMOUS_ID
public static final int MIN_ID
public static final java.lang.String ANONYMOUS_NAME
Constructor Detail |
public User()
public User(java.sql.Connection conn, int uid) throws LoadUserException, UserNotFoundException
conn
- a JDBC connection with access to the Loco user databaseuid
- the userid of the userpublic User(java.sql.Connection conn, java.lang.String un) throws LoadUserException, UserNotFoundException
conn
- a JDBC connection with access to the Loco user databaseun
- the username of the userpublic User(java.sql.Connection conn, java.lang.String un, boolean sensitiveToCase) throws LoadUserException, UserNotFoundException
conn
- a JDBC connection with access to the Loco user databaseun
- the username of the usersensitiveToCase
- whether or not to pay attention to casepublic User(java.sql.Connection conn, int uid, java.lang.String un, java.lang.String pword, java.lang.String fn, java.lang.String ln, int flg, int locoflg) throws LoadUserException
conn
- a JDBC connection with access to the Loco user databaseuid
- the userid, system will pick if <= 0un
- username of the new userpword
- password of the new userfn
- firstname of the new userln
- lastname of the new userflg
- flags of the new userlocoflg
- flags of the new user for Loco-specific functionspublic User(java.sql.Connection conn, int uid, java.lang.String un, java.lang.String pword, int locoflg) throws LoadUserException
conn
- a JDBC connection with access to the Loco user databaseuid
- the userid, system will pick if <= 0un
- username of the new userpword
- password of the new userlocoflg
- flags of the new user for Loco-specific functionspublic User(int uid, java.lang.String un, java.lang.String pword, int locoflg)
Method Detail |
protected static void initialize()
public int getUserid()
public int getAnonymousUserid()
public java.lang.String getUsername()
public java.lang.String getAnonymousUsername()
public java.lang.String getPassword()
public int getLocoFlags()
public void setLocoFlags(int newlocoflags)
newlocoflags
- the new value for loco_flagspublic void setUsername(java.lang.String un)
un
- the new username valuepublic void setPassword(java.lang.String pw)
pw
- the new value for the User's passwordpublic boolean hasPassword(java.lang.String pwtry)
pwtry
- the password to compare for a matchpublic boolean hasPasswordAnyCase(java.lang.String pwtry)
pwtry
- the password to compare for a matchpublic boolean isAnonymous()
public boolean canShutDownLoco()
public boolean canViewServerStatus()
public boolean canChangeLocoVars()
public boolean canViewUserPrefs()
public boolean canEditUserPrefs()
public java.lang.String toString()
public boolean equals(java.lang.Object o)
public void valueBound(javax.servlet.http.HttpSessionBindingEvent hsbe)
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent hsbe)
public static boolean exists(java.sql.Connection conn, int id) throws LoadUserException
conn
- a JDBC connection with access to the Loco user databaseid
- the userid of the user to look forpublic static boolean exists(java.sql.Connection conn, java.lang.String un) throws LoadUserException
conn
- a JDBC connection with access to the Loco user databaseun
- the username of the user to look forpublic static boolean existsAnyCase(java.sql.Connection conn, java.lang.String un) throws LoadUserException
conn
- a JDBC connection with access to the Loco user databaseun
- the username of the user to look forpublic void saveLoginTime(java.sql.Connection conn) throws LoadUserException
conn
- an active JDBC connectionpublic void save(java.sql.Connection conn) throws LoadUserException
conn
- an active JDBC connectionpublic static User[] loadUsers(java.sql.Connection conn, int[] userids) throws LoadUserException
conn
- a JDBC connectionuserids
- a list of userids to retrievepublic static java.lang.String[] loadAllUserNames(java.sql.Connection conn) throws LoadUserException
conn
- a JDBC connectionpublic static java.util.Vector getUsernames(java.sql.Connection conn, java.util.Vector userids) throws java.sql.SQLException
public static java.lang.String getUsername(java.sql.Connection conn, int userid) throws java.sql.SQLException
public static java.lang.String generateNewPassword(int seedmodifier)
seedmodifier
- seed used to assist random character generation
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |