
com.github.eljah.AdminService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xssverifier Show documentation
Show all versions of xssverifier Show documentation
XSS Verifier is a library for verifying that the web application is XSS-free with Selenium
The newest version!
package com.github.eljah;
import fi.iki.elonen.NanoHTTPD;
import fi.iki.elonen.ServerRunner;
import org.apache.log4j.Logger;
import java.util.Map;
/**
* Created by Ilya Evlampiev on 08.06.15.
*/
public class AdminService extends NanoHTTPD {
private static final Logger log = Logger.getLogger(AdminService.class);
private static Admin admin= new Admin();
public AdminService() {
super(8085);
}
public AdminService(int port) {
super(port);
}
@Override public Response serve(IHTTPSession session) {
Method method = session.getMethod();
String uri = session.getUri();
log.info("com.github.eljah.Admin received "+method + " '" + uri + "' ");
if (uri.equals("/start"))
{
Map parms = session.getParms();
try
{
admin.listenStart(Integer.parseInt(parms.get("port")));
}
catch (NullPointerException e)
{
log.error("Parameter port was not passed to the admin service");
}
catch (NumberFormatException e)
{
log.error("Parameter port has wrong non-integer format");
}
}
if (uri.equals("/stop"))
{
Map parms = session.getParms();
try
{
admin.listenStop(Integer.parseInt(parms.get("port")));
}
catch (NullPointerException e)
{
log.error("Parameter port was not passed to the admin service; if the only Sniffer service is running it will be stopped");
admin.listenStop();
}
catch (NumberFormatException e)
{
log.error("Parameter port has wrong non-integer format");
}
}
String msg =
"\n";
return new NanoHTTPD.Response(msg);
}
public static void main(String[] args) {
ServerRunner.run(AdminService.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy