String type1Msg = null;
int flags = PropUtil.getIntProperty(props,
"mail." + name + ".auth.ntlm.flags", 0);
String domain = props.getProperty(
"mail." + name + ".auth.ntlm.domain", "");
Ntlm ntlm = new Ntlm(domain, getLocalHost(), u, p, debug ? out : null);
try {
tag = writeCommand("AUTHENTICATE NTLM", null);
} catch (Exception ex) {
// Convert this into a BYE response
r = Response.byeResponse(ex);
done = true;
}
OutputStream os = getOutputStream(); // stream to IMAP server
boolean first = true;
while (!done) { // loop till we are done
try {
r = readResponse();
if (r.isContinuation()) {
// Server challenge ..
String s;
if (first) {
s = ntlm.generateType1Msg(flags);
first = false;
} else {
s = ntlm.generateType3Msg(r.getRest());
}
os.write(ASCIIUtility.getBytes(s));
os.write(CRLF); // CRLF termination
os.flush(); // flush the stream