Try classic login as last resort

This commit is contained in:
M66B 2021-01-14 12:50:36 +01:00
parent 3e9d4ac554
commit ab8cb73739
2 changed files with 15 additions and 69 deletions

View File

@ -910,27 +910,27 @@ public class IMAPStore extends Store
continue;
}
} catch (ProtocolException ex) {
eu.faircode.email.Log.w(ex);
if (pex == null)
pex = ex;
if (m.equals("PLAIN") || m.equals("LOGIN")) {
eu.faircode.email.Log.w("Falling back to classic LOGIN");
try {
p.authclassic(user, password);
return;
} catch (ProtocolException exex) {
eu.faircode.email.Log.w(exex);
}
}
}
}
if (pex != null)
throw pex;
if (!p.hasCapability("LOGINDISABLED"))
try {
eu.faircode.email.Log.i("Trying LOGIN");
p.login(user, password);
return;
} catch (ProtocolException ex) {
if (pex == null)
pex = ex;
}
if (!p.hasCapability("LOGINDISABLED")) {
p.login(user, password);
return;
if (pex != null) {
if (eu.faircode.email.BuildConfig.PLAY_STORE_RELEASE)
eu.faircode.email.Log.i(pex);
else
eu.faircode.email.Log.w(pex);
throw pex;
}
throw new ProtocolException("No login methods supported!");

View File

@ -630,60 +630,6 @@ public class IMAPProtocol extends Protocol {
authenticated = true;
}
public synchronized void authclassic(String u, String p)
throws ProtocolException {
List<Response> v = new ArrayList<>();
String tag = null;
Response r = null;
boolean done = false;
try {
if (noauthdebug && isTracing()) {
logger.fine("LOGIN command trace suppressed");
suspendTracing();
}
try {
Argument arg = new Argument();
arg.writeNString(u);
arg.writeNString(p);
tag = writeCommand("LOGIN", arg);
} catch (Exception ex) {
r = Response.byeResponse(ex);
done = true;
}
while (!done) {
try {
r = readResponse();
if (r.isTagged() && r.getTag().equals(tag))
done = true;
else if (r.isBYE()) // outta here
done = true;
} catch (Exception ioex) {
r = Response.byeResponse(ioex);
done = true;
}
v.add(r);
}
} finally {
resumeTracing();
}
Response[] responses = v.toArray(new Response[v.size()]);
handleCapabilityResponse(responses);
notifyResponseHandlers(responses);
if (noauthdebug && isTracing())
logger.fine("LOGIN command result: " + r);
handleLoginResult(r);
setCapabilities(r);
authenticated = true;
}
/**
* The AUTHENTICATE command with AUTH=PLAIN authentication scheme.
* This is based heavly on the {@link #authlogin} method.