Ip address retriction


is there any way to get the user ip address? i need to restrict certain functionality only for users from certain ip address space. I couldnt find any suitable method from application class. Any ideas?

As an independent solution you may always write a simple servlet filter to reject all http requests from the untrusted networks and return an error code or redirect to some explanation “access forbidden” page.

P.S. Oops, just did not notice from the first sight - you want to restrict a part of an application, so it would be not trivial servlet filter

Check last line from here:

Try out something like:

WebBrowser b = (WebBrowser) getMainWindow().getTerminal().
String ip = b.getAddress();

It seems you may also register a TransactionListener with your application and get access to HttpServletRequest instance in the transaction start method. Then you may set some application variables according to IP address, which your application components can just consume.

thanks for fast reply, that works!

And now i know to check wiki in addition to forum and technical articles…