- 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?
views:
40answers:
2
A:
Warlax
2010-03-02 20:30:00
A:
When running in the browser base64authorization
not null, correct?
I'm not really sure what getBase64authorization
is supposed to return, but I'm fairly certain when you call huc.setRequestProperty("Authorization", **autorization value**)
it's looking for a HTTP Basic authentication value. Meaning **authorization value**
needs to be in the format Basic **base 64 encoding of username:password**
as described here.
Maybe you just need to add the Basic
(note the trailing space) string to your property.
Vinnie
2010-03-02 20:30:26
Apparently not. I see you fixed it!
Vinnie
2010-03-02 20:32:32
Thank you Vinnie - but I was already doing that (I know you could not have known w/o my code).My solution posted above worked!
Warlax
2010-03-03 00:31:28