Search in sources :

Example 11 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class SmtpTransportTest method startServerAndCreateSmtpTransport.

private SmtpTransport startServerAndCreateSmtpTransport(MockSmtpServer server, AuthType authenticationType, ConnectionSecurity connectionSecurity, String password) throws IOException, MessagingException {
    server.start();
    String host = server.getHost();
    int port = server.getPort();
    ServerSettings serverSettings = new ServerSettings(Type.SMTP, host, port, connectionSecurity, authenticationType, USERNAME, password, CLIENT_CERTIFICATE_ALIAS);
    String uri = SmtpTransport.createUri(serverSettings);
    StoreConfig storeConfig = createStoreConfigWithTransportUri(uri);
    return new TestSmtpTransport(storeConfig, socketFactory, oAuth2TokenProvider);
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) StoreConfig(com.fsck.k9.mail.store.StoreConfig) Matchers.anyString(org.mockito.Matchers.anyString)

Example 12 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class SmtpTransportUriTest method createUri_canEncodeSmtpUri.

@Test
public void createUri_canEncodeSmtpUri() {
    ServerSettings serverSettings = new ServerSettings(ServerSettings.Type.SMTP, "server", 123456, ConnectionSecurity.NONE, AuthType.CRAM_MD5, "user", "password", "clientCert");
    String result = SmtpTransport.createUri(serverSettings);
    assertEquals("smtp://user:password:CRAM_MD5@server:123456", result);
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Example 13 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class SmtpTransportUriTest method decodeUri_canDecodeClientCert.

@Test
public void decodeUri_canDecodeClientCert() {
    String storeUri = "smtp+ssl+://user:clientCert:EXTERNAL@server:123456";
    ServerSettings result = SmtpTransport.decodeUri(storeUri);
    assertEquals("clientCert", result.clientCertificateAlias);
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Example 14 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class AccountSetupBasics method onManualSetup.

private void onManualSetup() {
    String email = mEmailView.getText().toString();
    String[] emailParts = splitEmail(email);
    String user = email;
    String domain = emailParts[1];
    String password = null;
    String clientCertificateAlias = null;
    AuthType authenticationType;
    if (mClientCertificateCheckBox.isChecked()) {
        authenticationType = AuthType.EXTERNAL;
        clientCertificateAlias = mClientCertificateSpinner.getAlias();
    } else {
        authenticationType = AuthType.PLAIN;
        password = mPasswordView.getText().toString();
    }
    if (mAccount == null) {
        mAccount = Preferences.getPreferences(this).newAccount();
    }
    mAccount.setName(getOwnerName());
    mAccount.setEmail(email);
    // set default uris
    // NOTE: they will be changed again in AccountSetupAccountType!
    ServerSettings storeServer = new ServerSettings(ServerSettings.Type.IMAP, "mail." + domain, -1, ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, user, password, clientCertificateAlias);
    ServerSettings transportServer = new ServerSettings(ServerSettings.Type.SMTP, "mail." + domain, -1, ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, user, password, clientCertificateAlias);
    String storeUri = RemoteStore.createStoreUri(storeServer);
    String transportUri = Transport.createTransportUri(transportServer);
    mAccount.setStoreUri(storeUri);
    mAccount.setTransportUri(transportUri);
    setupFolderNames(domain);
    AccountSetupAccountType.actionSelectAccountType(this, mAccount, false);
    finish();
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) AuthType(com.fsck.k9.mail.AuthType)

Example 15 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class AccountSetupOutgoing method onNext.

protected void onNext() {
    ConnectionSecurity securityType = getSelectedSecurity();
    String uri;
    String username = null;
    String password = null;
    String clientCertificateAlias = null;
    AuthType authType = null;
    if (mRequireLoginView.isChecked()) {
        username = mUsernameView.getText().toString();
        authType = getSelectedAuthType();
        if (AuthType.EXTERNAL == authType) {
            clientCertificateAlias = mClientCertificateSpinner.getAlias();
        } else {
            password = mPasswordView.getText().toString();
        }
    }
    String newHost = mServerView.getText().toString();
    int newPort = Integer.parseInt(mPortView.getText().toString());
    ServerSettings server = new ServerSettings(Type.SMTP, newHost, newPort, securityType, authType, username, password, clientCertificateAlias);
    uri = Transport.createTransportUri(server);
    mAccount.deleteCertificate(newHost, newPort, CheckDirection.OUTGOING);
    mAccount.setTransportUri(uri);
    AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.OUTGOING);
}
Also used : ConnectionSecurity(com.fsck.k9.mail.ConnectionSecurity) ServerSettings(com.fsck.k9.mail.ServerSettings) AuthType(com.fsck.k9.mail.AuthType)

Aggregations

ServerSettings (com.fsck.k9.mail.ServerSettings)45 Test (org.junit.Test)34 URISyntaxException (java.net.URISyntaxException)9 AuthType (com.fsck.k9.mail.AuthType)8 URI (java.net.URI)7 HashMap (java.util.HashMap)5 ConnectionSecurity (com.fsck.k9.mail.ConnectionSecurity)4 InvalidSettingValueException (com.fsck.k9.preferences.Settings.InvalidSettingValueException)2 Map (java.util.Map)2 SharedPreferences (android.content.SharedPreferences)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 Account (com.fsck.k9.Account)1 Preferences (com.fsck.k9.Preferences)1 Store (com.fsck.k9.mail.Store)1 RemoteStore (com.fsck.k9.mail.store.RemoteStore)1 StoreConfig (com.fsck.k9.mail.store.StoreConfig)1 ImapStoreSettings (com.fsck.k9.mail.store.imap.ImapStoreSettings)1 WebDavStoreSettings (com.fsck.k9.mail.store.webdav.WebDavStoreSettings)1 SettingsDescription (com.fsck.k9.preferences.Settings.SettingsDescription)1 ArrayList (java.util.ArrayList)1