mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-19 13:48:58 +00:00
Require ID command
This commit is contained in:
parent
b281117afc
commit
f75c38edc3
1 changed files with 15 additions and 9 deletions
|
@ -305,10 +305,10 @@ public class EmailService implements AutoCloseable {
|
||||||
|
|
||||||
if (auth == AUTH_TYPE_OAUTH) {
|
if (auth == AUTH_TYPE_OAUTH) {
|
||||||
AuthState authState = OAuthRefresh(context, provider, password);
|
AuthState authState = OAuthRefresh(context, provider, password);
|
||||||
connect(host, port, user, authState.getAccessToken(), factory);
|
connect(host, port, auth, user, authState.getAccessToken(), factory);
|
||||||
return authState.jsonSerializeString();
|
return authState.jsonSerializeString();
|
||||||
} else {
|
} else {
|
||||||
connect(host, port, user, password, factory);
|
connect(host, port, auth, user, password, factory);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (AuthenticationFailedException ex) {
|
} catch (AuthenticationFailedException ex) {
|
||||||
|
@ -326,7 +326,7 @@ public class EmailService implements AutoCloseable {
|
||||||
if (token == null)
|
if (token == null)
|
||||||
throw new AuthenticatorException("No token on refresh for " + user);
|
throw new AuthenticatorException("No token on refresh for " + user);
|
||||||
|
|
||||||
connect(host, port, user, token, factory);
|
connect(host, port, auth, user, token, factory);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ public class EmailService implements AutoCloseable {
|
||||||
}
|
}
|
||||||
else if (auth == AUTH_TYPE_OAUTH) {
|
else if (auth == AUTH_TYPE_OAUTH) {
|
||||||
AuthState authState = OAuthRefresh(context, provider, password);
|
AuthState authState = OAuthRefresh(context, provider, password);
|
||||||
connect(host, port, user, authState.getAccessToken(), factory);
|
connect(host, port, auth, user, authState.getAccessToken(), factory);
|
||||||
return authState.jsonSerializeString();
|
return authState.jsonSerializeString();
|
||||||
} else
|
} else
|
||||||
throw ex;
|
throw ex;
|
||||||
|
@ -374,9 +374,14 @@ public class EmailService implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect(
|
private void connect(
|
||||||
String host, int port, String user, String password,
|
String host, int port, int auth,
|
||||||
|
String user, String password,
|
||||||
SSLSocketFactoryService factory) throws MessagingException {
|
SSLSocketFactoryService factory) throws MessagingException {
|
||||||
InetAddress main = null;
|
InetAddress main = null;
|
||||||
|
boolean require_id = (purpose == PURPOSE_CHECK &&
|
||||||
|
auth == AUTH_TYPE_OAUTH &&
|
||||||
|
"outlook.office365.com".equals(host));
|
||||||
|
Log.i("Require ID=" + require_id);
|
||||||
try {
|
try {
|
||||||
//if (BuildConfig.DEBUG)
|
//if (BuildConfig.DEBUG)
|
||||||
// throw new MailConnectException(
|
// throw new MailConnectException(
|
||||||
|
@ -384,7 +389,7 @@ public class EmailService implements AutoCloseable {
|
||||||
|
|
||||||
main = InetAddress.getByName(host);
|
main = InetAddress.getByName(host);
|
||||||
EntityLog.log(context, "Connecting to " + main);
|
EntityLog.log(context, "Connecting to " + main);
|
||||||
_connect(main, port, user, password, factory);
|
_connect(main, port, require_id, user, password, factory);
|
||||||
} catch (UnknownHostException ex) {
|
} catch (UnknownHostException ex) {
|
||||||
throw new MessagingException(ex.getMessage(), ex);
|
throw new MessagingException(ex.getMessage(), ex);
|
||||||
} catch (MessagingException ex) {
|
} catch (MessagingException ex) {
|
||||||
|
@ -449,7 +454,7 @@ public class EmailService implements AutoCloseable {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EntityLog.log(context, "Falling back to " + iaddr);
|
EntityLog.log(context, "Falling back to " + iaddr);
|
||||||
_connect(iaddr, port, user, password, factory);
|
_connect(iaddr, port, require_id, user, password, factory);
|
||||||
return;
|
return;
|
||||||
} catch (MessagingException ex1) {
|
} catch (MessagingException ex1) {
|
||||||
ex = ex1;
|
ex = ex1;
|
||||||
|
@ -467,7 +472,8 @@ public class EmailService implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _connect(
|
private void _connect(
|
||||||
InetAddress address, int port, String user, String password,
|
InetAddress address, int port, boolean require_id,
|
||||||
|
String user, String password,
|
||||||
SSLSocketFactoryService factory) throws MessagingException {
|
SSLSocketFactoryService factory) throws MessagingException {
|
||||||
isession = Session.getInstance(properties, null);
|
isession = Session.getInstance(properties, null);
|
||||||
isession.setDebug(debug);
|
isession.setDebug(debug);
|
||||||
|
@ -502,7 +508,7 @@ public class EmailService implements AutoCloseable {
|
||||||
}
|
}
|
||||||
} catch (MessagingException ex) {
|
} catch (MessagingException ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
if (purpose == PURPOSE_CHECK)
|
if (require_id)
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue