net.sf.opensmus
Interface ServerUserDatabase

All Known Implementing Classes:
MUSDBConnection, MUSSQLConnection

public interface ServerUserDatabase

Interface used by OpenSMUS for user authentication, using the internal database system or an SQL source.
The database backend used for user authentication is configured in the OpenSMUS.cfg file. Use the getServerUserDatabase() method of the ServerObject interface to acquire this object.


Field Summary
static int AUTHENTICATION_NONE
           
static int AUTHENTICATION_OPTIONAL
           
static int AUTHENTICATION_REQUIRED
           
 
Method Summary
 int checkLogin(MUSUser oneUser, java.lang.String username, java.lang.String password)
          Checks if a user/pass combination is valid and sets the userlevel
 boolean createUser(java.lang.String usernamein, java.lang.String password, java.lang.String userlevel)
          Creates a user record in the user database
 boolean deleteDBUser(int userid)
          Deletes the user with the specified user id from the database.
 int getDBUser(java.lang.String usernamein)
          Returns the integer id for the user in the database.
 int getDBUserLevel(int userid)
          Retrieves the user access level
 java.lang.String getDBUserPassword(int userid)
          Retrieves the user password
 boolean isEnabled()
          Checks if the user database is enabled.
 void updateUserLastLoginTime(int userid)
          Updates the last login time for this user in the database to the current time.
 

Field Detail

AUTHENTICATION_NONE

static final int AUTHENTICATION_NONE
See Also:
Constant Field Values

AUTHENTICATION_OPTIONAL

static final int AUTHENTICATION_OPTIONAL
See Also:
Constant Field Values

AUTHENTICATION_REQUIRED

static final int AUTHENTICATION_REQUIRED
See Also:
Constant Field Values
Method Detail

createUser

boolean createUser(java.lang.String usernamein,
                   java.lang.String password,
                   java.lang.String userlevel)
Creates a user record in the user database

Parameters:
usernamein - Username string, will be converted to uppercase for storage
password - Password string
userlevel - User access level as a string. Usual values are between 20 and 100.
If the string specified can not be converted the default user level will be set.
Returns:
true if the user account is created successfully, false if an error occurs

updateUserLastLoginTime

void updateUserLastLoginTime(int userid)
Updates the last login time for this user in the database to the current time.

Parameters:
userid - User id integer retrieved by the getDBUser method.

getDBUser

int getDBUser(java.lang.String usernamein)
              throws DBException,
                     UserNotFoundException
Returns the integer id for the user in the database.
Other methods use the user id for speed.

Parameters:
usernamein - Username string
Throws:
DBException
UserNotFoundException

deleteDBUser

boolean deleteDBUser(int userid)
Deletes the user with the specified user id from the database.

Parameters:
userid - User id integer retrieved by the getDBUser method.
Returns:
true if the user account is deleted successfully, false if an error occurs

getDBUserLevel

int getDBUserLevel(int userid)
                   throws DBException
Retrieves the user access level

Parameters:
userid - User id integer retrieved by the getDBUser method.
Throws:
DBException

getDBUserPassword

java.lang.String getDBUserPassword(int userid)
                                   throws DBException
Retrieves the user password

Parameters:
userid - User id integer retrieved by the getDBUser method.
Throws:
DBException

checkLogin

int checkLogin(MUSUser oneUser,
               java.lang.String username,
               java.lang.String password)
Checks if a user/pass combination is valid and sets the userlevel

Parameters:
oneUser - The user object that will have the userlevel set
username -
password -
Returns:
0 if allowed to login, MUS errorcode if not.

isEnabled

boolean isEnabled()
Checks if the user database is enabled.
Databases are enabled by default, but can be disabled by using the OpenSMUS.cfg file.