How to disable certain parts of the application in jsf?

I have a JSF application in which I have different servlets and chips. The server is located on a real IP address. Now I want one servlet to be accessible from anywhere on the network, should the rest of the application be accessible only through localhost? What is the easiest way to do this?

+3
source share
1 answer

Use Filterthat maps to url-pattern, which covers the resources you would like to hide, and does basically the following in a method doFilter():

if (request.getRemoteAddr().equals(request.getLocalAddr())) {
    chain.doFilter(request, response);
} else {
    ((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN);
}

It will display an HTTP 403FORBIDDEN error for requests not created by the same client as the server.

+5
source

Source: https://habr.com/ru/post/1789989/


All Articles