001 package org.esupportail.cas.server.handlers.database;
002
003 import org.dom4j.Element;
004
005 /**
006 * This class implements a search database handler class. It is used by
007 * GenericHandler.
008 *
009 * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
010 */
011 public final class SearchDatabaseHandler extends QueryDatabaseHandler {
012
013 /**
014 * Constructor.
015 *
016 * @param handlerElement the XML element that declares the handler
017 * in the configuration file
018 * @param configDebug debugging mode of the global configuration
019 * @throws Exception Exception
020 */
021 public SearchDatabaseHandler(
022 final Element handlerElement,
023 final Boolean configDebug) throws Exception {
024 super(handlerElement, configDebug);
025 traceBegin();
026 traceEnd();
027 }
028
029 /**
030 * Read the SQL query from the configuration (deduces it from other parameters).
031 * @return a String.
032 * @throws Exception Exception
033 */
034 protected String readSqlQueryFromConfig() throws Exception {
035 traceBegin();
036
037 String table = getConfigSubElementContent("table", true/*needed*/);
038 trace("table = " + table);
039
040 String loginColumn = getConfigSubElementContent("login_column", true/*needed*/);
041 trace("login_column = " + loginColumn);
042
043 String passwordColumn = getConfigSubElementContent("password_column", true/*needed*/);
044 trace("password_column = " + passwordColumn);
045
046 String query = "SELECT " + passwordColumn
047 + " FROM " + table
048 + " WHERE " + loginColumn
049 + " = '" + QueryDatabaseHandler.SQL_LOGIN_TOKEN + "'";
050
051 traceEnd(query);
052 return query;
053 }
054
055 }
056