简体   繁体   English

从JAVA应用程序启动经过身份验证的摘要网页

[英]Launch a Digest Authenticated webpage from a JAVA application

I am working on a JAVA Swing application, where I want to add a button, which when clicked should open the system's default web-browser with a webpage. 我正在开发一个JAVA Swing应用程序,我想在其中添加一个按钮,单击该按钮将打开带有网页的系统默认Web浏览器。 I was able to achieve this, however the web page that I am intended to open has a Digest Authentication(with nonce,realm and MD-5 sess), so when the page is opened it asks for username and password. 我能够做到这一点,但是我打算打开的网页具有摘要式身份验证(具有nonce,realm和MD-5 sess),因此当打开页面时,它会要求输入用户名和密码。 I want to do away with the login prompt every time I open the page from the JAVA application(username & password is known). 每次我从JAVA应用程序打开页面时,我都想取消登录提示(用户名和密码已知)。 I am wondering if its possible with the JAVA application to communicate to the webserver till the authentication and somehow transfer that HTTP session to a web browser. 我想知道是否有可能通过JAVA应用程序与Web服务器通信,直到进行身份验证,然后以某种方式将该HTTP会话传输到Web浏览器。

I have been trying out the HTTPclient from the apache commons , it works fine however I don't see how I can transfer the webpage to the web browser (No, I don't have access to the web server and I cannot change the authentication mechanism). 我一直在从apache commons中尝试HTTPclient ,它工作正常,但是我看不到如何将网页传输到Web浏览器(不,我无权访问Web服务器,并且无法更改身份验证机制)。

If we reduce your question, you're essentially asking, "can I subvert the authentication mechanism from outside the server". 如果我们减少您的问题,您实际上是在问:“我可以从服务器外部颠覆身份验证机制吗”。 The answer to this is, "thankfully no ." 这个问题的答案是,“值得庆幸的是没有 。” However, you can give the browser a helping hand by telling it what username and password to send. 但是,您可以通过告诉浏览器发送什么用户名和密码来为浏览器提供帮助。

If you're opening the following URL: 如果要打开以下URL:

http://localhost/index.html

Change your URL to: 将您的URL更改为:

http://username:password@localhost/index.html

Note that in some browsers, the password will be obscured, but you shouldn't rely on it. 请注意,在某些浏览器中,密码将被遮盖,但您不应依赖它。 So you're damned to giving away the password. 因此,您该舍弃密码了。

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

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