From b5b85dd60325730bfe1f93dd7621f87831075178 Mon Sep 17 00:00:00 2001 From: cyberta Date: Thu, 23 Jan 2020 01:06:01 -0600 Subject: minor refactoring in ProviderApiManagerBase --- .../se/leap/bitmaskclient/ProviderApiManagerBase.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java index b632abc2..7577f098 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java @@ -609,11 +609,11 @@ public abstract class ProviderApiManagerBase { return plainResponseBody; } - private boolean canConnect(String caCert, JSONObject providerDefinition, Bundle result) { + private boolean canConnect(Provider provider, Bundle result) { JSONObject errorJson = new JSONObject(); - String providerUrl = getApiUrl(providerDefinition) + "/provider.json"; + String providerUrl = provider.getApiUrlString() + "/provider.json"; - OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(caCert, errorJson); + OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(provider.getCaCert(), errorJson); if (okHttpClient == null) { result.putString(ERRORS, errorJson.toString()); return false; @@ -752,7 +752,7 @@ public abstract class ProviderApiManagerBase { return setErrorResult(result, warning_corrupted_provider_cert, ERROR_CERTIFICATE_PINNING.toString()); } - if (!canConnect(caCert, provider.getDefinition(), result)) { + if (!canConnect(provider, result)) { return result; } } catch (NoSuchAlgorithmException e ) { @@ -787,15 +787,6 @@ public abstract class ProviderApiManagerBase { return result; } - protected String getApiUrl(JSONObject providerDefinition) { - try { - return providerDefinition.getString(Provider.API_URL); - } catch (JSONException e) { - e.printStackTrace(); - } - return ""; - } - protected String getPersistedPrivateKey(String providerDomain) { return getFromPersistedProvider(PROVIDER_PRIVATE_KEY, providerDomain, preferences); } -- cgit v1.2.3