Forum Stats

  • 3,838,514 Users
  • 2,262,378 Discussions
  • 7,900,678 Comments

Discussions

block websites

863824
863824 Member Posts: 2
edited May 23, 2011 9:16PM in Java Desktop Applications
Hi there,
does anyone know how to make an application block specific websites without editing the "hosts" file while the app is running?
Which APIs should I eventually use? I've never done anything like that.
Would be very grateful, if someone helps me.
thanks
Tagged:

Answers

  • 796440
    796440 Member Posts: 19,179 Gold Trophy
    This is not something you can do in pure Java.

    And note that "block specific websites" is a very vague requirement, open to many varying interpretations.
    796440
  • handat
    handat Member Posts: 4,688 Gold Crown
    Normally, you would use a firewall application to do this and I strongly suggest you do that. However, you could enable the security manager for your java application and make sure you remove java.security.AllPermission from the security policy and only add java.net.SocketPermission for the hosts you want to allow connection to. This would only be practical if you only had a few specific hosts you want the application to be able to connect to and deny connections for any other hosts.
This discussion has been closed.