1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* Created on 20 juil. 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package UtilScanner;
/**
* exécution du scan par la structure Struts suivant les champs du formulaire validé
*/
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.DynaActionForm;
import Scanner.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.ServletException;
public class FormulaireAction extends Action {
/**
* exécute le scan en fonction des champs saisis dans le formulaire
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException,ServletException {
//on a un formulaire valide, sinon on ne serait pas arrivé là
DynaActionForm formulaire=(DynaActionForm)form;
Options options=new Options(new Integer((String)formulaire.get("maxThread")).intValue(),new Integer((String)formulaire.get("timeout")).intValue(),new Integer((String)formulaire.get("countPing")).intValue());
boolean hostname,userName,groupName,computerName,macAddress,ttl,httpDetect,ftpDetect;
if(((String)formulaire.get("hostname")).equals("true"))
hostname=true;
else
hostname=false;
if(((String)formulaire.get("ttl")).equals("true"))
ttl=true;
else
ttl=false;
if(((String)formulaire.get("userName")).equals("true"))
userName=true;
else
userName=false;
if(((String)formulaire.get("computerName")).equals("true"))
computerName=true;
else
computerName=false;
if(((String)formulaire.get("groupName")).equals("true"))
groupName=true;
else
groupName=false;
if(((String)formulaire.get("macAddress")).equals("true"))
macAddress=true;
else
macAddress=false;
if(((String)formulaire.get("httpDetect")).equals("true"))
httpDetect=true;
else
httpDetect=false;
if(((String)formulaire.get("ftpDetect")).equals("true"))
ftpDetect=true;
else
ftpDetect=false;
ScannerOptions scannerOptions=new ScannerOptions( ttl,
hostname,
userName,
groupName,
computerName,
macAddress,
httpDetect,
ftpDetect);
//request.setAttribute("scannerOptions",scannerOptions);
Scanner scanner=new Scanner((String)formulaire.get("ip1"), (String)formulaire.get("ip2"),scannerOptions,options);
scanner.run();
request.setAttribute("scanner",scanner);
return mapping.findForward("reponse");
}
} |