从嵌入的小程序发出HTTP调用时绕过内置的浏览器认证 [英] Bypassing built-in browser authentication when making HTTP calls from embedded Applet

查看:536
本文介绍了从嵌入的小程序发出HTTP调用时绕过内置的浏览器认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我有带一个简单的网页
    嵌入式Java小程序。

  • 小程序
    使得HTTP调用不同的轴
    相机谁都有同样的
    验证(如用户名,
    密码)。

  • 我在推出的小程序传递用户名和密码到Java code - 没问题

  • 当我与小程序查看器的NetBeans中运行,我可以完全访问摄像机,看流媒体视频 - 正是因为标榜

  • 当我在Web浏览器(Firefox)中打开HTML页的问题开始。

  • 尽管我的code处理身份验证:

  • 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);


  • 浏览器还带来了一个认证弹出并分别要求每个摄像机的用户名和密码!

  • 要更糟糕的是,从相机中显示的图像冻结,旧的(昨晚)。

  • 如何绕过浏览器的认证?

  • 推荐答案

    固定

    Fixed

    我添加了以下行:

    huc.setDoOuput(true);
    huc.setUseCaches(false);
    

    huc.setDoInput(true);
    

    行。

    这篇关于从嵌入的小程序发出HTTP调用时绕过内置的浏览器认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆