在从嵌入式Applet进行HTTP调用时绕过内置浏览器身份验证 [英] Bypassing built-in browser authentication when making HTTP calls from embedded Applet

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

问题描述


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

  • 小程序
    向所有共享相同
    身份验证(例如用户名,
    密码)的不同Axis
    摄像机发出HTTP调用。 / li>
  • 我在启动小程序时将用户名和密码传递给Java代码 - 没有问题。

  • 当我从NetBeans

  • 当我在网络浏览器(Firefox)中打开HTML页面时,问题就开始了。
  • >
  • 即使我的代码处理认证:

      URL u = new URL(useMJPGStream? mjpgURL:jpgURL); 
    huc =(HttpURLConnection)u.openConnection();


    String base64authorization =
    securityMan.getAlias(this.securityAlias).getBase64authorization();
    //如果需要授权设置与编码的连接
    //授权信息
    if(base64authorization!= null)
    {
    huc.setDoInput真正);
    huc.setRequestProperty(Authorization,base64authorization);
    huc.connect();
    }

    InputStream is = huc.getInputStream();
    connected = true;
    BufferedInputStream bis = new BufferedInputStream(is);
    dis = new DataInputStream(bis);


  • 浏览器仍会显示身份验证弹出窗口,并分别请求每个摄像机的用户名和密码!

  • 更糟糕的是,从相机显示的图片会冻结和过去(从昨晚起)。

  • 如何绕过浏览器的身份验证 / p>

    我添加了以下行:

      huc.setDoOuput ; 
    huc.setUseCaches(false);

     

    之后的



    huc.setDoInput(true);

    行。


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

    • The browser still brings up an authentication pop-up and requests the username and password for each camera separately!
    • To make things worse, the images displayed from the camera are frozen and old (from last night).
    • How can I bypass the browser's authentication?

    解决方案

    Fixed

    I added the following lines:

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

    after the

    huc.setDoInput(true);
    

    line.

    这篇关于在从嵌入式Applet进行HTTP调用时绕过内置浏览器身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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