8006568: HTTP protocol handler NLTM Authentication should use Base64 API
Reviewed-by: chegar, alanb
This commit is contained in:
parent
69b0c6aad4
commit
4e11f499f4
@ -33,6 +33,7 @@ import java.net.PasswordAuthentication;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.URL;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Base64;
|
||||
|
||||
import sun.net.www.HeaderParser;
|
||||
import sun.net.www.protocol.http.AuthenticationInfo;
|
||||
@ -230,7 +231,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
|
||||
|
||||
private String buildType1Msg () {
|
||||
byte[] msg = client.type1();
|
||||
String result = "NTLM " + (new B64Encoder()).encode (msg);
|
||||
String result = "NTLM " + Base64.getEncoder().encodeToString(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -239,18 +240,12 @@ public class NTLMAuthentication extends AuthenticationInfo {
|
||||
/* First decode the type2 message to get the server nonce */
|
||||
/* nonce is located at type2[24] for 8 bytes */
|
||||
|
||||
byte[] type2 = (new sun.misc.BASE64Decoder()).decodeBuffer (challenge);
|
||||
byte[] type2 = Base64.getDecoder().decode(challenge);
|
||||
byte[] nonce = new byte[8];
|
||||
new java.util.Random().nextBytes(nonce);
|
||||
byte[] msg = client.type3(type2, nonce);
|
||||
String result = "NTLM " + (new B64Encoder()).encode (msg);
|
||||
String result = "NTLM " + Base64.getEncoder().encodeToString(msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class B64Encoder extends sun.misc.BASE64Encoder {
|
||||
/* to force it to to the entire encoding in one line */
|
||||
protected int bytesPerLine () {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,7 @@
|
||||
package sun.net.www.protocol.http.ntlm;
|
||||
|
||||
import java.io.IOException;
|
||||
import sun.misc.BASE64Encoder;
|
||||
import sun.misc.BASE64Decoder;
|
||||
import java.util.Base64;
|
||||
|
||||
/*
|
||||
* Hooks into Windows implementation of NTLM.
|
||||
@ -77,11 +76,11 @@ public class NTLMAuthSequence {
|
||||
assert !status.sequenceComplete;
|
||||
|
||||
if (token != null)
|
||||
input = (new BASE64Decoder()).decodeBuffer(token);
|
||||
input = Base64.getDecoder().decode(token);
|
||||
byte[] b = getNextToken (crdHandle, input, status);
|
||||
if (b == null)
|
||||
throw new IOException ("Internal authentication error");
|
||||
return (new B64Encoder()).encode (b);
|
||||
return Base64.getEncoder().encodeToString(b);
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
@ -95,8 +94,3 @@ public class NTLMAuthSequence {
|
||||
private native byte[] getNextToken (long crdHandle, byte[] lastToken, Status returned);
|
||||
}
|
||||
|
||||
class B64Encoder extends BASE64Encoder {
|
||||
protected int bytesPerLine () {
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.Base64;
|
||||
import javax.net.ssl.*;
|
||||
import javax.net.ServerSocketFactory;
|
||||
import sun.net.www.*;
|
||||
@ -295,10 +296,8 @@ public class ProxyTunnelServer extends Thread {
|
||||
String recvdUserPlusPass = authInfo.substring(ind + 1).trim();
|
||||
// extract encoded (username:passwd
|
||||
if (userPlusPass.equals(
|
||||
new String(
|
||||
(new sun.misc.BASE64Decoder()).
|
||||
decodeBuffer(recvdUserPlusPass)
|
||||
))) {
|
||||
new String(Base64.getDecoder().decode(recvdUserPlusPass))
|
||||
)) {
|
||||
matched = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user