import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class GetKey extends GenericServlet {
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
String key = getInitParameter("key");
String host = req.getServerName();
int port = req.getServerPort();
if (!keyFitsServer(key, host, port)) {
out.println("Pirated!");
} else {
out.println("Valid");
}
}
private boolean keyFitsServer(String key, String host, int port) {
return true;
}
}
|