We have a need to authenticate a user in a servlet using NTLM security then forward the user on to the secure site running on IIS to bypassing the IIS log in. Using the java.net.Authenticator class, I can get the below to load the requested page, but since no authentication data is stored to the session, any subsequent requests to the site will require you to log in again. I'm guessing I need to set the authentication header in the response but not sure how to do that.
Authenticator.setDefault(new MyAuthenticator());
URL url = new URL(" InputStream ins = url.openConnection().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
String str;
PrintWriter out = response.getWriter();
while((str = reader.readLine()) != null) {
out.println(str);
}
out.flush();
out.close();
Authenticator.setDefault(new MyAuthenticator());
URL url = new URL(" InputStream ins = url.openConnection().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
String str;
PrintWriter out = response.getWriter();
while((str = reader.readLine()) != null) {
out.println(str);
}
out.flush();
out.close();