Hi,
I am working on an intranet search engine using
java URL and Authenticator class. This is a secured web-site using SSL in http server. I am not able to access the password protected pages. Following is the code:
URL url = new URL("https://*************");
URLConnection connection = url.openConnection();
PasswordAuthentication pa = Authenticator.requestPasswordAuthentication( InetAddress.getByName(connection.getURL().getHost()),
connection.getURL().getPort(), connection.getURL().getProtocol(), null, "Basic");
StringBuffer buf = new StringBuffer("*****************");
buf.append(":");
buf.append("************");
String encoded = new sun.misc.BASE64Encoder().encode(buf.toString().getBytes());
connection.setRequestProperty ("Authorization", "Basic" + encoded);
InputStream content = (InputStream)connection.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
Let me know if there is any other alternative
tnx,
Biswajit Biswal