Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 765b390e authored by cketti's avatar cketti
Browse files

Remove LocalKeyStore's dependency on K9.app

parent 2a9ac867
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -1873,15 +1873,16 @@ public class Account implements BaseAccount {
    /**
     * Add a new certificate for the incoming or outgoing server to the local key store.
     */
    public void addCertificate(CheckDirection direction, X509Certificate certificate)
            throws CertificateException {
    public void addCertificate(Context context, CheckDirection direction,
            X509Certificate certificate) throws CertificateException {
        Uri uri;
        if (direction.equals(CheckDirection.INCOMING)) {
            uri = Uri.parse(getStoreUri());
        } else {
            uri = Uri.parse(getTransportUri());
        }
        LocalKeyStore.getInstance().addCertificate(uri.getHost(), uri.getPort(), certificate);
        LocalKeyStore localKeyStore = LocalKeyStore.getInstance(context);
        localKeyStore.addCertificate(uri.getHost(), uri.getPort(), certificate);
    }

    /**
@@ -1889,7 +1890,8 @@ public class Account implements BaseAccount {
     * new host/port, then try and delete any (possibly non-existent) certificate stored for the
     * old host/port.
     */
    public void deleteCertificate(String newHost, int newPort, CheckDirection direction) {
    public void deleteCertificate(Context context, String newHost, int newPort,
            CheckDirection direction) {
        Uri uri;
        if (direction.equals(CheckDirection.INCOMING)) {
            uri = Uri.parse(getStoreUri());
@@ -1899,7 +1901,8 @@ public class Account implements BaseAccount {
        String oldHost = uri.getHost();
        int oldPort = uri.getPort();
        if (!newHost.equals(oldHost) || newPort != oldPort) {
            LocalKeyStore.getInstance().deleteCertificate(oldHost, oldPort);
            LocalKeyStore localKeyStore = LocalKeyStore.getInstance(context);
            localKeyStore.deleteCertificate(oldHost, oldPort);
        }
    }

@@ -1907,8 +1910,8 @@ public class Account implements BaseAccount {
     * Examine the settings for the account and attempt to delete (possibly non-existent)
     * certificates for the incoming and outgoing servers.
     */
    public void deleteCertificates() {
        LocalKeyStore localKeyStore = LocalKeyStore.getInstance();
    public void deleteCertificates(Context context) {
        LocalKeyStore localKeyStore = LocalKeyStore.getInstance(context);

        Uri uri = Uri.parse(getStoreUri());
        localKeyStore.deleteCertificate(uri.getHost(), uri.getPort());
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class Preferences {

        Store.removeAccount(account);

        account.deleteCertificates();
        account.deleteCertificates(mContext);
        account.delete(this);

        if (newAccount == account) {
+1 −1
Original line number Diff line number Diff line
@@ -363,7 +363,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            mAccount.addCertificate(mDirection, chain[0]);
                            mAccount.addCertificate(getApplicationContext(), mDirection, chain[0]);
                        } catch (CertificateException e) {
                            showErrorDialog(
                                R.string.account_setup_failed_dlg_certificate_message_fmt,
+1 −1
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
                        mWebdavMailboxPathView.getText().toString());
            }

            mAccount.deleteCertificate(host, port, CheckDirection.INCOMING);
            mAccount.deleteCertificate(this, host, port, CheckDirection.INCOMING);
            ServerSettings settings = new ServerSettings(mStoreType, host, port,
                    connectionSecurity, authType, username, password, extra);

+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
            String newHost = mServerView.getText().toString();
            int newPort = Integer.parseInt(mPortView.getText().toString());
            uri = new URI(smtpSchemes[securityType], userInfo, newHost, newPort, null, null, null);
            mAccount.deleteCertificate(newHost, newPort, CheckDirection.OUTGOING);
            mAccount.deleteCertificate(this, newHost, newPort, CheckDirection.OUTGOING);
            mAccount.setTransportUri(uri.toString());
            AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.OUTGOING);
        } catch (UnsupportedEncodingException enc) {
Loading