public static function authenticate($username, $password)
 {
     $db = Application::getDbAdapter();
     $config = Application::getConfig();
     $table = $config[self::SETUP_KEY]['table_name'];
     $username_col = $config[self::SETUP_KEY][self::IDENTITY_FIELD_KEY];
     $password_col = $config[self::SETUP_KEY][self::PASSWORD_FIELD_KEY];
     $query = "\n            SELECT {$config[self::SETUP_KEY][self::IDENTITY_ID_FIELD_KEY]} FROM {$table}\n            WHERE {$username_col} = ? AND {$password_col} = MD5(?);";
     $rowset = $db->prepareExecuteAndFetch($query, array($username, $password));
     if (count($rowset) == 1) {
         self::setAuthenticated(true, $rowset[0][$config[self::SETUP_KEY]['identity_id_field']]);
     }
 }
 public function __construct()
 {
     $this->dbAdapter = Application::getDbAdapter();
 }