简体   繁体   English

基于Java Web的防火墙身份验证

[英]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 每天,我都必须经过一个基于Web的身份验证系统(防火墙),该系统的工作原理如下:连接到网络并输入任何网址(例如www.google.com ,系统会显示基于Web的登录表单(键入任何地址都会显示相同的表格),提交后,我会从路由器获得一个经过身份验证的响应页面,地址为: 192.168.2.254:1000/keepalive?somejibberjabbernumberwhichchangeseverytime : 192.168.2.254:1000/keepalive?somejibberjabbernumberwhichchangeseverytime

The page must be refreshed after 200 seconds or else you are logged out. 该页面必须在200秒后刷新,否则您将注销。 This is done automatically but sometimes it fails. 这是自动完成的,但有时会失败。

After that, Internet is enabled and one can browse. 之后,启用Internet,并且可以浏览。 I want to make a simple application (java) which does this boring task for me. 我想做一个简单的应用程序(java),它为我完成了这项无聊的任务。 It will send in my credentials to the server. 它将把我的凭据发送到服务器。 Log me in. Send refresh command after say 30 seconds automatically. 登录。30秒后自动发送刷新命令。

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. httpunit这样的Web测试库非常适合此类任务。 Basically, that's what you would do: 基本上,这就是您要做的:

  • Query some page (GetMethodWebRequest), expect to be redirected 查询某些页面(GetMethodWebRequest),期望被重定向
  • Check you're being redirected 检查您是否被重定向
  • Extract the form (response.getFormWithID), fill in your credentials, submit it 提取表单(response.getFormWithID),填写您的凭据,然后提交
  • Most likely the tricky part: Get the popup window URL. 最棘手的部分可能是:获取弹出窗口的URL。
  • Periodically poll the extracted URL 定期轮询提取的URL

Have a look at httpunit's cookbook and tutorial, my guess would be that you find all information required for your problem there. 看一下httpunit的食谱和教程,我想您会在那里找到问题所需的所有信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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