001package jmri.web.servlet;
002
003import static jmri.web.servlet.ServletUtil.UTF8_TEXT_HTML;
004
005import java.io.IOException;
006import javax.servlet.ServletException;
007import javax.servlet.annotation.WebServlet;
008import javax.servlet.http.HttpServlet;
009import javax.servlet.http.HttpServletRequest;
010import javax.servlet.http.HttpServletResponse;
011import org.openide.util.lookup.ServiceProvider;
012
013/**
014 * Servlet that simply sends an HTTP 403 FORBIDDEN error.
015 *
016 * Passing requests for certain resources protects those resources from network
017 * access.
018 *
019 * @author Randall Wood
020 */
021@WebServlet(name = "DenialServlet",
022        urlPatterns = {"/prefs/networkServices", "/settings/preferences"})
023@ServiceProvider(service = HttpServlet.class)
024public class DenialServlet extends HttpServlet {
025
026    @Override
027    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
028        response.setContentType(UTF8_TEXT_HTML);
029        response.sendError(HttpServletResponse.SC_FORBIDDEN);
030    }
031
032    @Override
033    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
034        this.doGet(request, response);
035    }
036
037}