Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Jetty 8.1: how to protect specified URLs of a web app via IP filter (with jetty 6, HTAccessHandler seems could do this, but it's gone in jetty 8)
icon5.gif  Jetty 8.1: how to protect specified URLs of a web app via IP filter [message #893084] Mon, 02 July 2012 14:26 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 9
Registered: December 2010
Junior Member
hi there,


i use jetty 8 as the servlet container, assume i have a web app 'example.war', in which has 2 urls '/example/admin/' and '/example/billing' i want to allowing access from certain ip address, say 192.168.0.1, deny all request from other ip addresses.

what' should i do?

googled shows with jetty 6, a class HTAccessHandler seems has some functions to do this, but here's no such thing in jetty 8.

any idea?

thanks a lot!
Re: Jetty 8.1: how to protect specified URLs of a web app via IP filter [message #893089 is a reply to message #893084] Mon, 02 July 2012 14:55 Go to previous messageGo to next message
Eclipse UserFriend
The extension point 'org.eclipse.equinox.http.registry.filters' could help on that.
The filter would look like:
public class IpFilter implements Filter {

  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
  }

  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    final HttpServletResponse res = (HttpServletResponse) response;
    if (request.getRemoteAddr().equals("192.168.0.1")) {
      res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }
  }

  @Override
  public void destroy() {
  }

}


Unfortunately there is no property to define the order in case of having several filter classes.

-andreas
Re: Jetty 8.1: how to protect specified URLs of a web app via IP filter [message #893090 is a reply to message #893089] Mon, 02 July 2012 14:58 Go to previous messageGo to next message
Eclipse UserFriend
HttpServletResponse.SC_FORBIDDEN is probably the better answer;)

-andreas
Re: Jetty 8.1: how to protect specified URLs of a web app via IP filter [message #893095 is a reply to message #893090] Mon, 02 July 2012 15:21 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 9
Registered: December 2010
Junior Member
Andreas Hoegger wrote on Mon, 02 July 2012 10:58
HttpServletResponse.SC_FORBIDDEN is probably the better answer;)

-andreas


thanks a lot for the quick reply!

another questions is, is there any way to do ip filter via using config files, such as jetty.xml, jetty-*.xml or things like that?

thank you!
Re: Jetty 8.1: how to protect specified URLs of a web app via IP filter [message #893098 is a reply to message #893095] Mon, 02 July 2012 15:36 Go to previous messageGo to next message
Eclipse UserFriend
http://wiki.eclipse.org/Jetty/Reference/DoSFilter is an implementation of such a filter. Make sure the required jars are on the classpath. Alternatively you could also create your own filter in a separate jar using the configuration mechanism an put it on the classpath.

-andreas
Re: Jetty 8.1: how to protect specified URLs of a web app via IP filter [message #893102 is a reply to message #893098] Mon, 02 July 2012 16:00 Go to previous message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 9
Registered: December 2010
Junior Member
Andreas Hoegger wrote on Mon, 02 July 2012 11:36
DoSFilter is an implementation of such a filter. Make sure the required jars are on the classpath. Alternatively you could also create your own filter in a separate jar using the configuration mechanism an put it on the classpath.

-andreas



thanks a lot, that's what i'm looking for, will try.
Previous Topic:Formatting XML's in StyledText
Next Topic:BIRT SQL query data set
Goto Forum:
  


Current Time: Tue Apr 23 14:49:41 GMT 2024

Powered by FUDForum. Page generated in 0.08622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top