package misclases;

import org.apache.struts2.interceptor.*;
import org.apache.struts2.util.*;
import javax.servlet.http.*;
import javax.servlet.*;

public class Validar implements ServletRequestAware, ServletContextAware{
    String pwd;
    String user;
    ServletContext context;
    public String execute() throws Exception {
      String driver=context.getInitParameter("driver");
      String cadenaCon=context.getInitParameter("cadenaCon");
      GestionClientes gc=new GestionClientes(driver,cadenaCon);
      if(gc.validar(user,pwd))
	  return "ok";
      else
	  return "error";
    }

    public String getUser(){
	return user;
    }
    public String getPwd(){
	return pwd;
    }
    public void setServletRequest(HttpServletRequest request){
       
	pwd=request.getParameter("password");
	user=request.getParameter("username");
    }
    public void setServletContext(ServletContext context){
      this.context=context;
	
    }

    
} 
