mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Eliminate searching for '3' in exception message
This was dead code. The exception message will always start with either "SMTP response is 0 length" from checkLine() or else "Negative SMTP reply" from NegativeSmtpReplyException(). The problem originated from way back before 4.904.
This commit is contained in:
parent
21237c3720
commit
c8f6c4d625
@ -666,6 +666,12 @@ public class SmtpTransport extends Transport {
|
||||
* Read lines as long as the length is 4 or larger, e.g. "220-banner text here".
|
||||
* Shorter lines are either errors of contain only a reply code. Those cases will
|
||||
* be handled by checkLine() below.
|
||||
*
|
||||
* TODO: All responses should be checked to confirm that they start with a valid
|
||||
* reply code, and that the reply code is appropriate for the command being executed.
|
||||
* That means it should either be a 2xx code (generally) or a 3xx code in special cases
|
||||
* (e.g., DATA & AUTH LOGIN commands). Reply codes should be made available as part of
|
||||
* the returned object.
|
||||
*/
|
||||
String line = readLine();
|
||||
while (line.length() >= 4) {
|
||||
@ -711,12 +717,14 @@ public class SmtpTransport extends Transport {
|
||||
executeSimpleCommand("AUTH LOGIN");
|
||||
executeSimpleCommand(Utility.base64Encode(username), true);
|
||||
executeSimpleCommand(Utility.base64Encode(password), true);
|
||||
} catch (MessagingException me) {
|
||||
if (me.getMessage().length() > 1 && me.getMessage().charAt(1) == '3') {
|
||||
throw new AuthenticationFailedException("AUTH LOGIN failed (" + me.getMessage()
|
||||
+ ")");
|
||||
} catch (NegativeSmtpReplyException exception) {
|
||||
if (exception.getReplyCode() == 535) {
|
||||
// Authentication credentials invalid
|
||||
throw new AuthenticationFailedException("AUTH LOGIN failed ("
|
||||
+ exception.getMessage() + ")");
|
||||
} else {
|
||||
throw exception;
|
||||
}
|
||||
throw me;
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,12 +733,14 @@ public class SmtpTransport extends Transport {
|
||||
String data = Utility.base64Encode("\000" + username + "\000" + password);
|
||||
try {
|
||||
executeSimpleCommand("AUTH PLAIN " + data, true);
|
||||
} catch (MessagingException me) {
|
||||
if (me.getMessage().length() > 1 && me.getMessage().charAt(1) == '3') {
|
||||
throw new AuthenticationFailedException("AUTH PLAIN failed (" + me.getMessage()
|
||||
+ ")");
|
||||
} catch (NegativeSmtpReplyException exception) {
|
||||
if (exception.getReplyCode() == 535) {
|
||||
// Authentication credentials invalid
|
||||
throw new AuthenticationFailedException("AUTH PLAIN failed ("
|
||||
+ exception.getMessage() + ")");
|
||||
} else {
|
||||
throw exception;
|
||||
}
|
||||
throw me;
|
||||
}
|
||||
}
|
||||
|
||||
@ -748,7 +758,12 @@ public class SmtpTransport extends Transport {
|
||||
try {
|
||||
executeSimpleCommand(b64CRAMString, true);
|
||||
} catch (NegativeSmtpReplyException exception) {
|
||||
throw new AuthenticationFailedException(exception.getMessage(), exception);
|
||||
if (exception.getReplyCode() == 535) {
|
||||
// Authentication credentials invalid
|
||||
throw new AuthenticationFailedException(exception.getMessage(), exception);
|
||||
} else {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user