use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class ImapConnection method saslAuthExternal.
private void saslAuthExternal() throws IOException, MessagingException {
try {
String command = Commands.AUTHENTICATE_EXTERNAL + " " + Base64.encode(settings.getUsername());
extractCapabilities(executeSimpleCommand(command, false));
} catch (NegativeImapResponseException e) {
/*
* Provide notification to the user of a problem authenticating
* using client certificates. We don't use an
* AuthenticationFailedException because that would trigger a
* "Username or password incorrect" notification in
* AccountSetupCheckSettings.
*/
throw new CertificateValidationException(e.getMessage());
}
}
use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class ImapConnectionTest method open_withStartTlsButWithoutStartTlsCapability_shouldThrow.
@Test
public void open_withStartTlsButWithoutStartTlsCapability_shouldThrow() throws Exception {
settings.setConnectionSecurity(ConnectionSecurity.STARTTLS_REQUIRED);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
//FIXME: CertificateValidationException seems wrong
assertEquals("STARTTLS connection security not available", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class ImapConnectionTest method open_authExternalWithAuthenticationFailure_shouldThrow.
@Test
public void open_authExternalWithAuthenticationFailure_shouldThrow() throws Exception {
settings.setAuthType(AuthType.EXTERNAL);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=EXTERNAL");
server.expect("2 AUTHENTICATE EXTERNAL " + ByteString.encodeUtf8(USERNAME).base64());
server.output("2 NO Bad certificate");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
//FIXME: improve exception message
assertThat(e.getMessage(), containsString("Bad certificate"));
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class RealImapConnectionTest method open_authExternalWithoutAuthExternalCapability_shouldThrow.
@Test
public void open_authExternalWithoutAuthExternalCapability_shouldThrow() throws Exception {
settings.setAuthType(AuthType.EXTERNAL);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=PLAIN");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
assertEquals(Reason.MissingCapability, e.getReason());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class RealImapConnectionTest method open_authExternalWithAuthenticationFailure_shouldThrow.
@Test
public void open_authExternalWithAuthenticationFailure_shouldThrow() throws Exception {
settings.setAuthType(AuthType.EXTERNAL);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=EXTERNAL");
server.expect("2 AUTHENTICATE EXTERNAL " + ByteString.encodeUtf8(USERNAME).base64());
server.output("2 NO Bad certificate");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
// FIXME: improve exception message
assertThat(e.getMessage(), containsString("Bad certificate"));
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
Aggregations