org.alicebot.server.core
Class DBMultiplexor

java.lang.Object
  extended by org.alicebot.server.core.Multiplexor
      extended by org.alicebot.server.core.DBMultiplexor

public class DBMultiplexor
extends Multiplexor

A database-oriented Multiplexor. Uses a database for storage and retrieval of predicates.

This is adapted from Classifier, to use a better database structure and to support user authentication.

Version:
4.1.3
Author:
Richard Wallace, Jon Baer, Thomas Ringate/Pedro Colla, Noel Bush

Field Summary
 
Fields inherited from class org.alicebot.server.core.Multiplexor
ASTERISK, avgResponseTime, EMPTY_STRING, HOST_NAME, INPUT, PREDICATE_EMPTY_DEFAULT, QUOTE_MARK, responseCount, SECRET_KEY, SHOW_CONSOLE, SHOW_MATCH_TRACE, SPACE, STAR, startTime, THAT, TOPIC, totalTime, USE_TARGETING, VALUE
 
Constructor Summary
DBMultiplexor()
           
 
Method Summary
 boolean changePassword(java.lang.String userid, java.lang.String password, java.lang.String secretKey, java.lang.String botid)
          Changes the password associated with a userid.
 boolean checkUser(java.lang.String userid, java.lang.String password, java.lang.String secretKey, java.lang.String botid)
          Checks whether a given userid and password combination is valid.
 boolean createUser(java.lang.String userid, java.lang.String password, java.lang.String secretKey, java.lang.String botid)
          Creates a userid with a given password.
 void initialize()
          Loads the database properties from the server configuration.
 java.lang.String loadPredicate(java.lang.String name, java.lang.String userid, java.lang.String botid)
          Loads the value of a predicate from a database.
 void savePredicate(java.lang.String name, java.lang.String value, java.lang.String userid, java.lang.String botid)
          Saves a predicate in a database.
 int useridCount(java.lang.String botid)
          Returns a count of known userids.
 
Methods inherited from class org.alicebot.server.core.Multiplexor
addPulse, averageResponseTime, getInternalResponse, getResponse, pulse, queriesPerHour
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBMultiplexor

public DBMultiplexor()
Method Detail

initialize

public void initialize()
Loads the database properties from the server configuration.

Overrides:
initialize in class Multiplexor

savePredicate

public void savePredicate(java.lang.String name,
                          java.lang.String value,
                          java.lang.String userid,
                          java.lang.String botid)
Saves a predicate in a database.

Specified by:
savePredicate in class Multiplexor
Parameters:
name - predicate name
value - predicate value
userid - user identifier

loadPredicate

public java.lang.String loadPredicate(java.lang.String name,
                                      java.lang.String userid,
                                      java.lang.String botid)
                               throws NoSuchPredicateException
Loads the value of a predicate from a database.

Specified by:
loadPredicate in class Multiplexor
Parameters:
name - predicate name
userid - user identifier
Returns:
the predicate value
Throws:
NoSuchPredicateException - if there is no predicate with this name

createUser

public boolean createUser(java.lang.String userid,
                          java.lang.String password,
                          java.lang.String secretKey,
                          java.lang.String botid)
Creates a userid with a given password. If the userid already exists, returns false.

Specified by:
createUser in class Multiplexor
Parameters:
userid - the userid to use
password - the password to assign
secretKey - the secret key that should authenticate this request
Returns:
whether the creation was successful
See Also:
Multiplexor#createUser}

checkUser

public boolean checkUser(java.lang.String userid,
                         java.lang.String password,
                         java.lang.String secretKey,
                         java.lang.String botid)
Description copied from class: Multiplexor
Checks whether a given userid and password combination is valid. Multiplexors for which this makes no sense should just return true.

Specified by:
checkUser in class Multiplexor
Parameters:
userid - the userid to check
password - the password to check
secretKey - the secret key that should authenticate this request
Returns:
whether the userid and password combination is valid

changePassword

public boolean changePassword(java.lang.String userid,
                              java.lang.String password,
                              java.lang.String secretKey,
                              java.lang.String botid)
Description copied from class: Multiplexor
Changes the password associated with a userid. Multiplexors for which this makes no sense should just return true.

Specified by:
changePassword in class Multiplexor
Parameters:
userid - the userid
password - the new password
secretKey - the secret key that should authenticate this request
Returns:
whether the change was successful

useridCount

public int useridCount(java.lang.String botid)
Description copied from class: Multiplexor
Returns a count of known userids. This may be defined differently for different multiplexors.

Specified by:
useridCount in class Multiplexor
Returns:
a count of known userids