protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, ParseException, ClassNotFoundException, SQLException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        authenticator = new Authenticator(request);
        globalResponse = response;
        try {
            if(request.getParameter("src")!=null && request.getParameter("src").equals("login")) {
                boolean flag;
                flag = authenticator.Login();
                if(flag) {
                    //redirect to home page/index.jsp
                    response.sendRedirect("index.jsp");
                } else {
                    //redirect to login.jsp with error
                    response.sendRedirect("login.jsp?error=error");
                }
            } else if(request.getParameter("src")!=null && request.getParameter("src").equals("logout")) {
                authenticator.Logout();
                response.sendRedirect("login.jsp");
            } else if(request.getParameter("signed_request") != null) {
                String signedRequest = request.getParameter("signed_request");
                ParseAndRegister(signedRequest, out);
            } else {
                response.sendRedirect("login.jsp");
            }
        } finally {
            out.close();
        }
    }