@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(); }
public void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { throw new IllegalStateException("open() called after close(). " + "Check wrapped exception to see where close() was called.", stacktraceForClose); } open = true; boolean authSuccess = false; nextCommandTag = 1; adjustDNSCacheTTL(); try { socket = connect(); configureSocket(); setUpStreamsAndParserFromSocket(); readInitialResponse(); requestCapabilitiesIfNecessary(); upgradeToTlsIfNecessary(); List<ImapResponse> responses = authenticate(); authSuccess = true; extractOrRequestCapabilities(responses); enableCompressionIfRequested(); retrievePathPrefixIfNecessary(); retrievePathDelimiterIfNecessary(); } catch (SSLException e) { handleSslException(e); } catch (ConnectException e) { handleConnectException(e); } catch (GeneralSecurityException e) { throw new MessagingException("Unable to open connection to IMAP server due to security error.", e); } finally { if (!authSuccess) { Timber.e("Failed to login, closing connection for %s", getLogId()); close(); } } }
ImapConnection { public void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { throw new IllegalStateException("open() called after close(). " + "Check wrapped exception to see where close() was called.", stacktraceForClose); } open = true; boolean authSuccess = false; nextCommandTag = 1; adjustDNSCacheTTL(); try { socket = connect(); configureSocket(); setUpStreamsAndParserFromSocket(); readInitialResponse(); requestCapabilitiesIfNecessary(); upgradeToTlsIfNecessary(); List<ImapResponse> responses = authenticate(); authSuccess = true; extractOrRequestCapabilities(responses); enableCompressionIfRequested(); retrievePathPrefixIfNecessary(); retrievePathDelimiterIfNecessary(); } catch (SSLException e) { handleSslException(e); } catch (ConnectException e) { handleConnectException(e); } catch (GeneralSecurityException e) { throw new MessagingException("Unable to open connection to IMAP server due to security error.", e); } finally { if (!authSuccess) { Timber.e("Failed to login, closing connection for %s", getLogId()); close(); } } } }
ImapConnection { public void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { throw new IllegalStateException("open() called after close(). " + "Check wrapped exception to see where close() was called.", stacktraceForClose); } open = true; boolean authSuccess = false; nextCommandTag = 1; adjustDNSCacheTTL(); try { socket = connect(); configureSocket(); setUpStreamsAndParserFromSocket(); readInitialResponse(); requestCapabilitiesIfNecessary(); upgradeToTlsIfNecessary(); List<ImapResponse> responses = authenticate(); authSuccess = true; extractOrRequestCapabilities(responses); enableCompressionIfRequested(); retrievePathPrefixIfNecessary(); retrievePathDelimiterIfNecessary(); } catch (SSLException e) { handleSslException(e); } catch (ConnectException e) { handleConnectException(e); } catch (GeneralSecurityException e) { throw new MessagingException("Unable to open connection to IMAP server due to security error.", e); } finally { if (!authSuccess) { Timber.e("Failed to login, closing connection for %s", getLogId()); close(); } } } ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider);   ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider,
            int socketConnectTimeout, int socketReadTimeout); }
ImapConnection { public void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { throw new IllegalStateException("open() called after close(). " + "Check wrapped exception to see where close() was called.", stacktraceForClose); } open = true; boolean authSuccess = false; nextCommandTag = 1; adjustDNSCacheTTL(); try { socket = connect(); configureSocket(); setUpStreamsAndParserFromSocket(); readInitialResponse(); requestCapabilitiesIfNecessary(); upgradeToTlsIfNecessary(); List<ImapResponse> responses = authenticate(); authSuccess = true; extractOrRequestCapabilities(responses); enableCompressionIfRequested(); retrievePathPrefixIfNecessary(); retrievePathDelimiterIfNecessary(); } catch (SSLException e) { handleSslException(e); } catch (ConnectException e) { handleConnectException(e); } catch (GeneralSecurityException e) { throw new MessagingException("Unable to open connection to IMAP server due to security error.", e); } finally { if (!authSuccess) { Timber.e("Failed to login, closing connection for %s", getLogId()); close(); } } } ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider);   ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider,
            int socketConnectTimeout, int socketReadTimeout); void open(); boolean isConnected(); void close(); OutputStream getOutputStream(); List<ImapResponse> executeSimpleCommand(String command); List<ImapResponse> executeSimpleCommand(String command, boolean sensitive); List<ImapResponse> readStatusResponse(String tag, String commandToLog, UntaggedHandler untaggedHandler); String sendSaslIrCommand(String command, String initialClientResponse, boolean sensitive); String sendCommand(String command, boolean sensitive); void sendContinuation(String continuation); ImapResponse readResponse(); ImapResponse readResponse(ImapResponseCallback callback); }
ImapConnection { public void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { throw new IllegalStateException("open() called after close(). " + "Check wrapped exception to see where close() was called.", stacktraceForClose); } open = true; boolean authSuccess = false; nextCommandTag = 1; adjustDNSCacheTTL(); try { socket = connect(); configureSocket(); setUpStreamsAndParserFromSocket(); readInitialResponse(); requestCapabilitiesIfNecessary(); upgradeToTlsIfNecessary(); List<ImapResponse> responses = authenticate(); authSuccess = true; extractOrRequestCapabilities(responses); enableCompressionIfRequested(); retrievePathPrefixIfNecessary(); retrievePathDelimiterIfNecessary(); } catch (SSLException e) { handleSslException(e); } catch (ConnectException e) { handleConnectException(e); } catch (GeneralSecurityException e) { throw new MessagingException("Unable to open connection to IMAP server due to security error.", e); } finally { if (!authSuccess) { Timber.e("Failed to login, closing connection for %s", getLogId()); close(); } } } ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider);   ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider,
            int socketConnectTimeout, int socketReadTimeout); void open(); boolean isConnected(); void close(); OutputStream getOutputStream(); List<ImapResponse> executeSimpleCommand(String command); List<ImapResponse> executeSimpleCommand(String command, boolean sensitive); List<ImapResponse> readStatusResponse(String tag, String commandToLog, UntaggedHandler untaggedHandler); String sendSaslIrCommand(String command, String initialClientResponse, boolean sensitive); String sendCommand(String command, boolean sensitive); void sendContinuation(String continuation); ImapResponse readResponse(); ImapResponse readResponse(ImapResponseCallback callback);  }