Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass basic authentication without prompting login box from browser in JSP frames

I have created frame in JSP which takes some site in source which has basic authentication implemented

<frameset frameborder="0" border="0" framespacing="0">
<frame name="content" src="http://abc/" marginheight="0" 
       marginwidth="0" scrolling="auto" noresize>

but when this frame loads it prompts login box of browser.

What code should be used so that if I provide hardcoded user name and password, each time when I run site within the frame it loads site directly?

like image 805
Saghir A. Khatri Avatar asked Nov 23 '11 04:11

Saghir A. Khatri


1 Answers

You can make an AJAX request with the Authorization header having the authentication details, such that further requests join the session and does not need authentication.

Here it is to add the Authorization header:

byte[] authBytes = Encoding.UTF8.GetBytes("user:password".ToCharArray());
String authHeaderValue = "Basic " + Convert.ToBase64String(authBytes);
//Add Authorization:authHeaderValue to the request 
like image 100
Ramesh PVK Avatar answered Sep 28 '22 14:09

Ramesh PVK