I tried the following way to do the basic http authentication but it did not worked for me.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.http.phishy-userpass-length", 255);
driver = new FirefoxDriver(profile);
After this I passed the user name and password with the below approach.
driver.get("https://username:password@<<URL>>");
If there is any special character in the password how to pass it in the URL.
Is there any generic solution which will solve this problem on all the browsers.