8286526: Improve NTLM support

Reviewed-by: weijun, rhalade
This commit is contained in:
Hai-May Chao 2022-06-13 20:06:40 +00:00 committed by Henry Jen
parent c622d56a0d
commit 5a8e5ea3e2
5 changed files with 23 additions and 13 deletions

View file

@ -224,23 +224,27 @@ class NTLM {
System.arraycopy(data, 0, internal, offset, data.length);
}
void writeSecurityBuffer(int offset, byte[] data) {
void writeSecurityBuffer(int offset, byte[] data) throws NTLMException {
if (data == null) {
writeShort(offset+4, current);
writeInt(offset+4, current);
} else {
int len = data.length;
if (len > 65535) {
throw new NTLMException(NTLMException.INVALID_INPUT,
"Invalid data length " + len);
}
if (current + len > internal.length) {
internal = Arrays.copyOf(internal, current + len + 256);
}
writeShort(offset, len);
writeShort(offset+2, len);
writeShort(offset+4, current);
writeInt(offset+4, current);
System.arraycopy(data, 0, internal, current, len);
current += len;
}
}
void writeSecurityBuffer(int offset, String str, boolean unicode) {
void writeSecurityBuffer(int offset, String str, boolean unicode) throws NTLMException {
writeSecurityBuffer(offset, str == null ? null : str.getBytes(
unicode ? StandardCharsets.UTF_16LE
: StandardCharsets.ISO_8859_1));