Package com.command

Source Code of com.command.LoginCommand

package com.command;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import modele.ActionStatus;
import modele.UserSession;
import dao.Dao;

/**
* Servlet implementation class FrontController point d'entrer de toute les
* requete
*/

public class LoginCommand extends FrontCommand {

  @Override
  public void processRequest(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {

    /*
     * get user login and password values
     */
    String curUserName = request.getParameter("login");
    String curpassword = request.getParameter("password");
    String resultPage = null;
    UserSession session = UserSession.getInstance();
   
    ActionStatus a = Dao.validLogin(curUserName, curpassword);
    if (a.isStatusValue()) {
      Dao.setCurrentUser(curUserName);
      request.setAttribute("ressources", Dao.getUser(curUserName)
          .getRessources());
      session.authentifiedUser = Dao.getUser(curUserName);
      session.sessionID = request.getSession().getId();
    } else {
      request.setAttribute("Message", a.getStatusDescription());
      resultPage = "/jsp/DisplayMessage.jsp";
      forward(resultPage, request, response);
      return;
    }
    response.setContentType("text/html");
    resultPage = "/jsp/menu.jsp";
    forward(resultPage, request, response);
   
  }
}
TOP

Related Classes of com.command.LoginCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.