org.alicebot.server.core.responder
Class HTMLResponder

java.lang.Object
  extended by org.alicebot.server.core.responder.AbstractMarkupResponder
      extended by org.alicebot.server.core.responder.HTMLResponder
All Implemented Interfaces:
Responder

public class HTMLResponder
extends AbstractMarkupResponder

Responsible for handling requests that come via HTTP, and delivering the response via dynamically-generated HTML based on user-designed templates.

Author:
Kim Sullivan, Sergey Zenyuk, Noel Bush, X-31

Field Summary
static java.lang.String PASSWORD_COOKIE_NAME
          The password cookie name.
static java.lang.String USER_COOKIE_NAME
          The user id cookie name.
 
Fields inherited from class org.alicebot.server.core.responder.AbstractMarkupResponder
ALICE_IN, ALICE_OUT, ATOMIC_MARKER_END, bot, BOT_, BOT_NAME_EQUALS, botid, EMPTY_STRING, footer, header, HNAME, hostName, HOSTNAME, MARKER_END, MARKER_START, QUOTE_MARK, REPLY_END, REPLY_START, replyPart, response, RESPONSE, SPACE, tags, UNDERSCORE, USERINPUT
 
Constructor Summary
HTMLResponder(java.lang.String botid, java.lang.String templateName)
           
 
Method Summary
 java.lang.String authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String userid)
           Tries to authenticate a user.
static java.lang.String changePasswordRequest()
          Processes a change password request.
static java.lang.String loginRequest()
          loginRequest with no parameters means unknown username, password
static java.lang.String loginRequest(java.lang.String user, java.lang.String password)
          Processes a login request
static java.lang.String registerRequest()
          Processes a registration request
 
Methods inherited from class org.alicebot.server.core.responder.AbstractMarkupResponder
append, loadTemplate, log, parse, parseTemplate, postprocess, preprocess, registerTemplates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_COOKIE_NAME

public static final java.lang.String USER_COOKIE_NAME
The user id cookie name.

See Also:
Constant Field Values

PASSWORD_COOKIE_NAME

public static final java.lang.String PASSWORD_COOKIE_NAME
The password cookie name.

See Also:
Constant Field Values
Constructor Detail

HTMLResponder

public HTMLResponder(java.lang.String botid,
                     java.lang.String templateName)
              throws java.io.IOException
Throws:
java.io.IOException
Method Detail

loginRequest

public static java.lang.String loginRequest()
loginRequest with no parameters means unknown username, password


loginRequest

public static java.lang.String loginRequest(java.lang.String user,
                                            java.lang.String password)
Processes a login request

Parameters:
user - the username
password - the password

registerRequest

public static java.lang.String registerRequest()
Processes a registration request


changePasswordRequest

public static java.lang.String changePasswordRequest()
Processes a change password request.


authenticate

public java.lang.String authenticate(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.String userid)

Tries to authenticate a user. Different things can happen, depending on parameters in the request. Here are the meanings of the parameter values:

Most important goal is to get out of here as quickly as possible. This relies on the DBMultiplexor having a quick method to check a user -- ideally not going to the database each time. Also relies on creating as few objects as possible, even avoiding Strings if possible, but never checking the same parameter more than once. Of course, the order is the most important thing. We have to first see if there are any of the relevant parameters supplied, then check a couple of server properties, to know what we have to do. It's okay if the registration and login steps are a little slower, but not okay if each reply is slowed down in a conversation. That's what we tried hard to avoid here.

Parameters:
request - the HttpServletRequest
response - the HttpServletResponse
userid - the userid given with the request (will not be the same as final userid)