简体   繁体   中英

Java Web-Based Firewall Authenticate

Everyday, I have to go through a web based authentication system (firewall) which works likes this: Once I am connected to the network and I type in any web address say www.google.com , I am presented with a web based login form (typing any address brings up the same form) and after submit I get a Authenticated response page from the router with address: 192.168.2.254:1000/keepalive?somejibberjabbernumberwhichchangeseverytime

The page must be refreshed after 200 seconds or else you are logged out. This is done automatically but sometimes it fails.

After that, Internet is enabled and one can browse. I want to make a simple application (java) which does this boring task for me. It will send in my credentials to the server. Log me in. Send refresh command after say 30 seconds automatically.

Are there any suggestions as to how to do this? I need to create a standalone desktop application not a server-side app.

Thanks

So basically, you want to "play browser" with your application? Web testing libraries like httpunit are well suited for such tasks. Basically, that's what you would do:

  • Query some page (GetMethodWebRequest), expect to be redirected
  • Check you're being redirected
  • Extract the form (response.getFormWithID), fill in your credentials, submit it
  • Most likely the tricky part: Get the popup window URL.
  • Periodically poll the extracted URL

Have a look at httpunit's cookbook and tutorial, my guess would be that you find all information required for your problem there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM