summaryrefslogtreecommitdiff
path: root/app/src/debug
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-01-13 13:48:34 +0100
committerParménides GV <parmegv@sdf.org>2015-01-19 16:00:06 +0100
commitb3ea137781af2eacd0a5b75f24030cfbc3c9d962 (patch)
tree2e21721c2213f8f7ee7dffd6118fb5e399275357 /app/src/debug
parente1f028e6a27f209ed1f1773c234faf85085d87ab (diff)
Reusing methods to download certificate.
This makes sure that if a a certificate is not valid, a new one is downloaded. Unit tests don't apply to this, I've already added one to the certificate validator, whose result will determine if a new certificate will be downloaded.
Diffstat (limited to 'app/src/debug')
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java15
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java16
2 files changed, 11 insertions, 20 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
index f180b444..faf3779a 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -62,9 +62,6 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
private Provider selected_provider;
final public static String TAG = ConfigurationWizard.class.getSimpleName();
- final public static String TYPE_OF_CERTIFICATE = "type_of_certificate";
- final public static String ANON_CERTIFICATE = "anon_certificate";
- final public static String AUTHED_CERTIFICATE = "authed_certificate";
final protected static String PROVIDER_SET = "PROVIDER SET";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
@@ -83,7 +80,7 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
private int progress = -1;
private void initProviderList() {
- List<Renderer<Provider>> prototypes = new ArrayList<Renderer<Provider>>();
+ List<Renderer<Provider>> prototypes = new ArrayList<>();
prototypes.add(new ProviderRenderer(this));
ProviderRendererBuilder providerRendererBuilder = new ProviderRendererBuilder(prototypes);
adapter = new ProviderListAdapter(getLayoutInflater(), providerRendererBuilder, provider_manager);
@@ -186,7 +183,7 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
if (preferences.getBoolean(Constants.ALLOWED_ANON, false)){
mConfigState.putExtra(SERVICES_RETRIEVED, true);
- downloadAnonCert();
+ downloadVpnCertificate();
} else {
mProgressBar.incrementProgressBy(1);
hideProgressBar();
@@ -305,17 +302,11 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download
/**
* Asks ProviderAPI to download an anonymous (anon) VPN certificate.
*/
- private void downloadAnonCert() {
+ private void downloadVpnCertificate() {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle parameters = new Bundle();
-
- parameters.putString(TYPE_OF_CERTIFICATE, ANON_CERTIFICATE);
-
provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
-
startService(provider_API_command);
}
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
index d63d641a..1dbe11d3 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -187,7 +187,7 @@ public class ProviderAPI extends IntentService {
if(validUserLoginData(username, password)) {
session_id_bundle = register(username, password);
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
} else {
if(!wellFormedPassword(password)) {
session_id_bundle.putBoolean(RESULT_KEY, false);
@@ -236,7 +236,7 @@ public class ProviderAPI extends IntentService {
String password = task.getString(SessionDialog.PASSWORD);
if(validUserLoginData(username, password)) {
result = authenticate(username, password);
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
} else {
if(!wellFormedPassword(password)) {
result.putBoolean(RESULT_KEY, false);
@@ -317,7 +317,7 @@ public class ProviderAPI extends IntentService {
* and sends it as a broadcast.
* @param progress
*/
- private void broadcast_progress(int progress) {
+ private void broadcastProgress(int progress) {
Intent intentUpdate = new Intent();
intentUpdate.setAction(UPDATE_PROGRESSBAR);
intentUpdate.addCategory(Intent.CATEGORY_DEFAULT);
@@ -507,16 +507,16 @@ public class ProviderAPI extends IntentService {
if(!PROVIDER_JSON_DOWNLOADED)
current_download = getAndSetProviderJson(last_provider_main_url, last_danger_on);
if(PROVIDER_JSON_DOWNLOADED || (current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY))) {
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
PROVIDER_JSON_DOWNLOADED = true;
current_download = downloadCACert(last_danger_on);
if(CA_CERT_DOWNLOADED || (current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY))) {
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
CA_CERT_DOWNLOADED = true;
current_download = getAndSetEipServiceJson();
if(current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY)) {
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
EIP_SERVICE_JSON_DOWNLOADED = true;
}
}
@@ -847,7 +847,7 @@ public class ProviderAPI extends IntentService {
urlConnection.setSSLSocketFactory(getProviderSSLSocketFactory());
responseCode = urlConnection.getResponseCode();
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
LeapSRPSession.setToken("");
Log.d(TAG, Integer.toString(responseCode));
} catch (ClientProtocolException e) {
@@ -864,7 +864,7 @@ public class ProviderAPI extends IntentService {
if(urlConnection != null) {
responseCode = urlConnection.getResponseCode();
if(responseCode == 401) {
- broadcast_progress(progress++);
+ broadcastProgress(progress++);
LeapSRPSession.setToken("");
Log.d(TAG, Integer.toString(responseCode));
return true;