net.sf.opensmus
Class MUSDBConnection

java.lang.Object
  extended by net.sf.opensmus.MUSDBConnection
All Implemented Interfaces:
ServerUserDatabase

public class MUSDBConnection
extends java.lang.Object
implements ServerUserDatabase


Field Summary
 boolean m_enabled
           
 
Fields inherited from interface net.sf.opensmus.ServerUserDatabase
AUTHENTICATION_NONE, AUTHENTICATION_OPTIONAL, AUTHENTICATION_REQUIRED
 
Constructor Summary
MUSDBConnection(MUSServer srv, boolean enableFlag)
           
 
Method Summary
 void addBannedEntry(java.lang.String inentry, int secsToBan)
           
 boolean canGetAttribute(java.lang.String attname, ServerUser user)
           
 boolean canSetAttribute(java.lang.String attname, ServerUser user)
           
 int checkLogin(MUSUser oneUser, java.lang.String username, java.lang.String password)
          Checks if a user/pass combination is valid and sets the userlevel
 void checkPoint()
           
 boolean createApplication(java.lang.String applicationnamein, java.lang.String description)
           
 int createApplicationData(int applicationid)
           
 boolean createDBPlayer(int userid, int appid)
           
 void createDefaultDB()
           
 boolean createUser(java.lang.String usernamein, java.lang.String password, java.lang.String userlevel)
          Creates a user record in the user database
 boolean declareAttribute(java.lang.String attributenamein)
           
 boolean deleteAttribute(int attid)
           
 boolean deleteDBApplication(int appid)
           
 boolean deleteDBApplicationData(int appdataid)
           
 boolean deleteDBPlayer(int playerid)
           
 boolean deleteDBUser(int userid)
          Deletes the user with the specified user id from the database.
 void deliver(ServerUser user, MUSMovie mov, java.lang.String[] args, MUSMessage msg, MUSMessage reply)
           
 void ensureDBPresence()
           
 LPropList getApplicationDataAsL(int appid)
           
 LList getApplicationDataListFromApplicationID(int appid)
           
 MUSAttribute getAttribute(int ownerid, java.lang.String attributenamein)
           
 int getAttribute(java.lang.String attributenamein)
           
 boolean getAttributeExists(int ownerid, int attrid)
           
 LValue getAttributeNames(int ownerid)
           
 int getDBApplication(java.lang.String appnamein)
           
 int getDBPlayer(int userid, int appid)
           
 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
 LList getMatchedApplicationDataList(LPropList plist)
           
 LValue handleAttributeMessage(int ownerid, MUSMessage reply, java.lang.String attrcommand, LPropList msgattributes, ServerUser user)
           
 boolean isBanned(java.lang.String inentry)
           
 boolean isEnabled()
          Checks if the user database is enabled.
 void killDBConnection()
           
 void processDBConfigCommands()
           
 void purgeBannedTable()
           
 boolean removeAttribute(int ownerid, MUSAttribute attin)
           
 void removeBannedEntry(java.lang.String inentry)
           
 LList searchApplicationDataForNumber(int appid, int attrid, LList appdataidlist, LValue argsearch1)
           
 LList searchApplicationDataForRange(int appid, int attrid, LList appdataidlist, LValue argsearch1, LValue argsearch2)
           
 LList searchApplicationDataForText(int appid, int attrid, LList appdataidlist, LValue argsearch1)
           
 void setAttribute(int ownerid, MUSAttribute attin)
           
 void setDBObjectAttributes(int objectid, LList attrlist, LList vallist)
           
 LValue srvcmd_getApplicationCount()
           
 LValue srvcmd_getApplicationNames()
           
 LValue srvcmd_getAttributeCount()
           
 LValue srvcmd_getAttributeNames()
           
 LValue srvcmd_getBanned()
           
 LValue srvcmd_getUserCount()
           
 LValue srvcmd_getUserNames()
           
 void updateUserLastLoginTime(int userid)
          Updates the last login time for this user in the database to the current time.
 void validateAttributesList(LValue attributes, LList intattrlist, ServerUser user, int accessmode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_enabled

public boolean m_enabled
Constructor Detail

MUSDBConnection

public MUSDBConnection(MUSServer srv,
                       boolean enableFlag)
Method Detail

isEnabled

public boolean isEnabled()
Description copied from interface: ServerUserDatabase
Checks if the user database is enabled.
Databases are enabled by default, but can be disabled by using the OpenSMUS.cfg file.

Specified by:
isEnabled in interface ServerUserDatabase

killDBConnection

public void killDBConnection()

processDBConfigCommands

public void processDBConfigCommands()

createUser

public boolean createUser(java.lang.String usernamein,
                          java.lang.String password,
                          java.lang.String userlevel)
Description copied from interface: ServerUserDatabase
Creates a user record in the user database

Specified by:
createUser in interface ServerUserDatabase
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

createApplication

public boolean createApplication(java.lang.String applicationnamein,
                                 java.lang.String description)

createDBPlayer

public boolean createDBPlayer(int userid,
                              int appid)

checkPoint

public void checkPoint()

isBanned

public boolean isBanned(java.lang.String inentry)

purgeBannedTable

public void purgeBannedTable()

addBannedEntry

public void addBannedEntry(java.lang.String inentry,
                           int secsToBan)

removeBannedEntry

public void removeBannedEntry(java.lang.String inentry)

createApplicationData

public int createApplicationData(int applicationid)

declareAttribute

public boolean declareAttribute(java.lang.String attributenamein)

ensureDBPresence

public void ensureDBPresence()
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

createDefaultDB

public void createDefaultDB()
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

srvcmd_getUserCount

public LValue srvcmd_getUserCount()

srvcmd_getUserNames

public LValue srvcmd_getUserNames()

srvcmd_getApplicationCount

public LValue srvcmd_getApplicationCount()

srvcmd_getApplicationNames

public LValue srvcmd_getApplicationNames()

srvcmd_getAttributeCount

public LValue srvcmd_getAttributeCount()

srvcmd_getAttributeNames

public LValue srvcmd_getAttributeNames()

srvcmd_getBanned

public LValue srvcmd_getBanned()

updateUserLastLoginTime

public void updateUserLastLoginTime(int userid)
Description copied from interface: ServerUserDatabase
Updates the last login time for this user in the database to the current time.

Specified by:
updateUserLastLoginTime in interface ServerUserDatabase
Parameters:
userid - User id integer retrieved by the getDBUser method.

getDBUser

public int getDBUser(java.lang.String usernamein)
              throws DBException,
                     UserNotFoundException
Description copied from interface: ServerUserDatabase
Returns the integer id for the user in the database.
Other methods use the user id for speed.

Specified by:
getDBUser in interface ServerUserDatabase
Parameters:
usernamein - Username string
Throws:
DBException
UserNotFoundException

deleteDBUser

public boolean deleteDBUser(int userid)
Description copied from interface: ServerUserDatabase
Deletes the user with the specified user id from the database.

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

getAttribute

public int getAttribute(java.lang.String attributenamein)
                 throws DBException
Throws:
DBException

deleteAttribute

public boolean deleteAttribute(int attid)

removeAttribute

public boolean removeAttribute(int ownerid,
                               MUSAttribute attin)
                        throws AttributeNotFoundException
Throws:
AttributeNotFoundException

getAttributeNames

public LValue getAttributeNames(int ownerid)

getAttribute

public MUSAttribute getAttribute(int ownerid,
                                 java.lang.String attributenamein)
                          throws DBException,
                                 AttributeNotFoundException
Throws:
DBException
AttributeNotFoundException

getAttributeExists

public boolean getAttributeExists(int ownerid,
                                  int attrid)
                           throws DBException
Throws:
DBException

setAttribute

public void setAttribute(int ownerid,
                         MUSAttribute attin)
                  throws DBException
Throws:
DBException

setDBObjectAttributes

public void setDBObjectAttributes(int objectid,
                                  LList attrlist,
                                  LList vallist)

getDBUserLevel

public int getDBUserLevel(int userid)
                   throws DBException
Description copied from interface: ServerUserDatabase
Retrieves the user access level

Specified by:
getDBUserLevel in interface ServerUserDatabase
Parameters:
userid - User id integer retrieved by the getDBUser method.
Throws:
DBException

getDBUserPassword

public java.lang.String getDBUserPassword(int userid)
                                   throws DBException
Description copied from interface: ServerUserDatabase
Retrieves the user password

Specified by:
getDBUserPassword in interface ServerUserDatabase
Parameters:
userid - User id integer retrieved by the getDBUser method.
Throws:
DBException

checkLogin

public int checkLogin(MUSUser oneUser,
                      java.lang.String username,
                      java.lang.String password)
Description copied from interface: ServerUserDatabase
Checks if a user/pass combination is valid and sets the userlevel

Specified by:
checkLogin in interface ServerUserDatabase
Parameters:
oneUser - The user object that will have the userlevel set
Returns:
0 if allowed to login, MUS errorcode if not.

getDBApplication

public int getDBApplication(java.lang.String appnamein)
                     throws DBException
Throws:
DBException

deleteDBApplication

public boolean deleteDBApplication(int appid)

deleteDBApplicationData

public boolean deleteDBApplicationData(int appdataid)

deleteDBPlayer

public boolean deleteDBPlayer(int playerid)

getDBPlayer

public int getDBPlayer(int userid,
                       int appid)
                throws DBException,
                       PlayerNotFoundException
Throws:
DBException
PlayerNotFoundException

getApplicationDataListFromApplicationID

public LList getApplicationDataListFromApplicationID(int appid)

getApplicationDataAsL

public LPropList getApplicationDataAsL(int appid)

searchApplicationDataForText

public LList searchApplicationDataForText(int appid,
                                          int attrid,
                                          LList appdataidlist,
                                          LValue argsearch1)

searchApplicationDataForNumber

public LList searchApplicationDataForNumber(int appid,
                                            int attrid,
                                            LList appdataidlist,
                                            LValue argsearch1)

searchApplicationDataForRange

public LList searchApplicationDataForRange(int appid,
                                           int attrid,
                                           LList appdataidlist,
                                           LValue argsearch1,
                                           LValue argsearch2)

deliver

public void deliver(ServerUser user,
                    MUSMovie mov,
                    java.lang.String[] args,
                    MUSMessage msg,
                    MUSMessage reply)

handleAttributeMessage

public LValue handleAttributeMessage(int ownerid,
                                     MUSMessage reply,
                                     java.lang.String attrcommand,
                                     LPropList msgattributes,
                                     ServerUser user)
                              throws DBException,
                                     MUSErrorCode
Throws:
DBException
MUSErrorCode

getMatchedApplicationDataList

public LList getMatchedApplicationDataList(LPropList plist)
                                    throws MUSErrorCode
Throws:
MUSErrorCode

validateAttributesList

public void validateAttributesList(LValue attributes,
                                   LList intattrlist,
                                   ServerUser user,
                                   int accessmode)
                            throws MUSErrorCode
Throws:
MUSErrorCode

canSetAttribute

public boolean canSetAttribute(java.lang.String attname,
                               ServerUser user)

canGetAttribute

public boolean canGetAttribute(java.lang.String attname,
                               ServerUser user)