从嵌入式 Applet 进行 HTTP 调用时绕过内置浏览器身份验证 [英] Bypassing built-in browser authentication when making HTTP calls from embedded Applet
本文介绍了从嵌入式 Applet 进行 HTTP 调用时绕过内置浏览器身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 我有一个简单的网页嵌入式 Java 小程序.
- 小程序对不同的轴进行 HTTP 调用共享相同的相机身份验证(例如用户名、密码).
- 我在启动小程序时将用户名和密码传递给 Java 代码 - 没问题.
- 当我使用小程序查看器在 NetBeans 中运行时,我可以完全访问相机并观看流媒体视频 - 与宣传的完全一样.
- 当我在网络浏览器 (Firefox) 中打开 HTML 页面时,问题就开始了.
即使我的代码处理身份验证:
- I have a simple web page with an embedded Java applet.
- The applet makes HTTP calls to different Axis Cameras who all share the same authentication (e.g. username, password).
- I am passing the user name and password to the Java code upon launch of the applet - no problem.
- When I run from within NetBeans with the applet viewer, I get full access to the cameras and see streaming video - exactly as advertised.
- The problem begins when I open the HTML page in a web browser (Firefox).
Even though my code handles authentication:
URL u = new URL(useMJPGStream ? mjpgURL : jpgURL);
huc = (HttpURLConnection) u.openConnection();
String base64authorization =
securityMan.getAlias(this.securityAlias).getBase64authorization();
// if authorization is required set up the connection with the encoded
// authorization-information
if(base64authorization != null)
{
huc.setDoInput(true);
huc.setRequestProperty("Authorization",base64authorization);
huc.connect();
}
InputStream is = huc.getInputStream();
connected = true;
BufferedInputStream bis = new BufferedInputStream(is);
dis= new DataInputStream(bis);
推荐答案
已修复
我添加了以下几行:
huc.setDoOuput(true);
huc.setUseCaches(false);
在
huc.setDoInput(true);
线.
这篇关于从嵌入式 Applet 进行 HTTP 调用时绕过内置浏览器身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文