-
Bug
-
Resolution: Fixed
-
P4
-
9
-
b23
-
x86
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8063755 | 8u45 | Weijun Wang | P4 | Resolved | Fixed | b01 |
JDK-8049690 | 8u40 | Weijun Wang | P4 | Resolved | Fixed | b01 |
JDK-8070207 | emb-8u47 | Weijun Wang | P4 | Resolved | Fixed | team |
JDK-8079687 | 7u91 | Sean Coffey | P4 | Resolved | Fixed | b01 |
JDK-8180994 | openjdk7u | Weijun Wang | P4 | Resolved | Fixed | master |
JDK-8079688 | 6u105 | Sean Coffey | P4 | Resolved | Fixed | b01 |
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux cde 2.6.18-238.19.1.el5.centos.plus #1 SMP Mon Jul 18 10:05:09 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I can't authenticate with NTLM server. Same code does work in java 1.6, but isn't running in java 1.7.
When I try "conn.getInputStream()" i receive this error:
java.net.ProtocolException: Server redirected too many times (20)
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try running provided simple code against the NTML server.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
You shold receive the requested url.
ACTUAL -
There were no result, only ProtocolException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1622)
at ntlm.Main.getAuthenticatedResponse(Main.java:55)
at ntlm.Main.main(Main.java:30)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package ntlm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception
{
String urlStr = "http://put_here_ntlm_server_address";
String domain = "SIMPLE_DOMAIN";
String userName = "SIMPLE_USERNAME";
String password = "SIMPLE_PASSWORD";
String responseText = getAuthenticatedResponse(urlStr, domain, userName, password);
System.out.println("response: " + responseText);
}
private static String getAuthenticatedResponse(final String urlStr, final String domain, final String userName, final String password) throws IOException
{
StringBuilder response = new StringBuilder();
Authenticator.setDefault(new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(domain + "\\" + userName, password.toCharArray());
}
});
URL urlRequest = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) urlRequest.openConnection();
conn.setInstanceFollowRedirects(true);
conn.setAllowUserInteraction(true);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("GET");
InputStream stream = conn.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(stream));
String str = "";
while ((str = in.readLine()) != null) {
response.append(str);
}
in.close();
return response.toString();
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8049690 NTLM authentication fail if user specified a different realm
- Resolved
-
JDK-8063755 NTLM authentication fail if user specified a different realm
- Resolved
-
JDK-8070207 NTLM authentication fail if user specified a different realm
- Resolved
-
JDK-8079687 NTLM authentication fail if user specified a different realm
- Resolved
-
JDK-8079688 NTLM authentication fail if user specified a different realm
- Resolved
-
JDK-8180994 NTLM authentication fail if user specified a different realm
- Resolved
- duplicates
-
JDK-8151122 ntlm authentication fails when authenticating against server in alternate domain
- Closed