From ac08f520ae7f69d343b5338b7abd27e9188d34de Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 18 Aug 2014 05:08:01 +0200 Subject: [PATCH] Remove KeyChainKeyManager's dependency on 'K9.app' --- src/com/fsck/k9/net/ssl/KeyChainKeyManager.java | 13 +++++++------ src/com/fsck/k9/net/ssl/SslHelper.java | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java b/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java index 53c08e739..b1e1f88f6 100644 --- a/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java +++ b/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java @@ -51,20 +51,21 @@ public class KeyChainKeyManager extends X509ExtendedKeyManager { * Indicates an error in retrieving the certificate for the alias * (likely because the alias is invalid or the certificate was deleted) */ - public KeyChainKeyManager(String alias) throws MessagingException { + public KeyChainKeyManager(Context context, String alias) throws MessagingException { mAlias = alias; - Context context = K9.app; try { mChain = fetchCertificateChain(context, alias); mPrivateKey = fetchPrivateKey(context, alias); } catch (KeyChainException e) { // The certificate was possibly deleted. Notify user of error. - throw new CertificateValidationException(K9.app.getString( - R.string.client_certificate_retrieval_failure, alias), e); + final String message = context.getString( + R.string.client_certificate_retrieval_failure, alias); + throw new CertificateValidationException(message, e); } catch (InterruptedException e) { - throw new MessagingException(K9.app.getString( - R.string.client_certificate_retrieval_failure, alias), e); + final String message = context.getString( + R.string.client_certificate_retrieval_failure, alias); + throw new MessagingException(message, e); } } diff --git a/src/com/fsck/k9/net/ssl/SslHelper.java b/src/com/fsck/k9/net/ssl/SslHelper.java index bf1c198a7..38e281bf0 100644 --- a/src/com/fsck/k9/net/ssl/SslHelper.java +++ b/src/com/fsck/k9/net/ssl/SslHelper.java @@ -32,8 +32,7 @@ public class SslHelper { if (clientCertificateAlias == null || clientCertificateAlias.isEmpty()) { keyManagers = null; } else { - keyManagers = new KeyManager[] { new KeyChainKeyManager( - clientCertificateAlias) }; + keyManagers = new KeyManager[] { new KeyChainKeyManager(K9.app, clientCertificateAlias) }; } SSLContext sslContext = SSLContext.getInstance("TLS");