summaryrefslogtreecommitdiff
path: root/app/src/main/java/se
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2020-01-23 01:06:01 -0600
committercyberta <cyberta@riseup.net>2020-01-23 01:06:01 -0600
commitb5b85dd60325730bfe1f93dd7621f87831075178 (patch)
tree135cc4f133f3c7b3cab43b7323b5b58cf571010e /app/src/main/java/se
parent91c35b8d30997b9c74a12256b289272d8b625fdb (diff)
minor refactoring in ProviderApiManagerBase
Diffstat (limited to 'app/src/main/java/se')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java17
1 files changed, 4 insertions, 13 deletions
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);
}