summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/leapclient')
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java7
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java40
-rw-r--r--src/se/leap/leapclient/Dashboard.java42
-rw-r--r--src/se/leap/leapclient/LogInDialog.java8
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java74
5 files changed, 103 insertions, 68 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 62ebf8f1..e139bf62 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -52,18 +52,11 @@ public class ConfigHelper {
final public static String
ABOUT_FRAGMENT = "aboutFragment",
- DOWNLOAD_JSON_FILES_BUNDLE_EXTRA = "downloadJSONFiles",
- UPDATE_PROVIDER_DOTJSON = "updateProviderDotJSON",
- DOWNLOAD_NEW_PROVIDER_DOTJSON = "downloadNewProviderDotJSON",
LOG_IN_DIALOG = "logInDialog",
NEW_PROVIDER_DIALOG = "logInDialog",
- SRP_REGISTER = "srpRegister",
- SRP_AUTH = "srpAuth",
M1_KEY = "M1",
M2_KEY = "M2",
LOG_IN = "logIn",
- LOG_OUT = "logOut",
- DOWNLOAD_CERTIFICATE = "downloadUserAuthedCertificate",
API_VERSION_KEY = "api_version",
API_RETURN_SERIAL_KEY = "serial",
RESULT_KEY = "result",
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index 934e2ea0..4ddac803 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -265,14 +265,15 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
private void downloadJSONFiles(ProviderItem provider) {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
+ Bundle parameters = new Bundle();
- method_and_parameters.putString(ConfigHelper.PROVIDER_KEY, provider.name);
- method_and_parameters.putString(ConfigHelper.MAIN_CERT_KEY, provider.cert_json_url);
- method_and_parameters.putString(ConfigHelper.EIP_SERVICE_KEY, provider.eip_service_json_url);
- method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, provider.danger_on);
+ parameters.putString(ConfigHelper.PROVIDER_KEY, provider.name);
+ parameters.putString(ConfigHelper.MAIN_CERT_KEY, provider.cert_json_url);
+ parameters.putString(ConfigHelper.EIP_SERVICE_KEY, provider.eip_service_json_url);
+ parameters.putBoolean(ConfigHelper.DANGER_ON, provider.danger_on);
- provider_API_command.putExtra(ConfigHelper.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
@@ -284,11 +285,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
private void downloadAnonCert() {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
+ Bundle parameters = new Bundle();
- method_and_parameters.putString(ConfigHelper.TYPE_OF_CERTIFICATE, ConfigHelper.ANON_CERTIFICATE);
+ parameters.putString(ConfigHelper.TYPE_OF_CERTIFICATE, ConfigHelper.ANON_CERTIFICATE);
- provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
@@ -332,11 +334,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
public void saveAndSelectProvider(String provider_main_url, boolean danger_on) {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
- method_and_parameters.putString(ConfigHelper.PROVIDER_MAIN_URL, provider_main_url);
- method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
+ Bundle parameters = new Bundle();
+ parameters.putString(ConfigHelper.PROVIDER_MAIN_URL, provider_main_url);
+ parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
- provider_API_command.putExtra(ConfigHelper.DOWNLOAD_NEW_PROVIDER_DOTJSON, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.DOWNLOAD_NEW_PROVIDER_DOTJSON);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
@@ -351,12 +354,13 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
public void updateProviderDotJson(String provider_name, String provider_json_url, boolean danger_on) {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
- method_and_parameters.putString(ConfigHelper.PROVIDER_NAME, provider_name);
- method_and_parameters.putString(ConfigHelper.PROVIDER_JSON_URL, provider_json_url);
- method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
+ Bundle parameters = new Bundle();
+ parameters.putString(ConfigHelper.PROVIDER_NAME, provider_name);
+ parameters.putString(ConfigHelper.PROVIDER_JSON_URL, provider_json_url);
+ parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
- provider_API_command.putExtra(ConfigHelper.UPDATE_PROVIDER_DOTJSON, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.UPDATE_PROVIDER_DOTJSON);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java
index d81c3def..bb4331d5 100644
--- a/src/se/leap/leapclient/Dashboard.java
+++ b/src/se/leap/leapclient/Dashboard.java
@@ -90,7 +90,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
buildDashboard();
if(data != null && data.hasExtra(ConfigHelper.LOG_IN)) {
View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
- logInDialog(view, "");
+ logInDialog(view, Bundle.EMPTY);
}
} else if(resultCode == RESULT_CANCELED && data.hasExtra(ConfigHelper.QUIT)) {
finish();
@@ -195,7 +195,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
return true;
case R.id.login_button:
View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
- logInDialog(view, "");
+ logInDialog(view, Bundle.EMPTY);
return true;
case R.id.logout_button:
logOut();
@@ -213,20 +213,21 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
- method_and_parameters.putString(ConfigHelper.USERNAME_KEY, username);
- method_and_parameters.putString(ConfigHelper.PASSWORD_KEY, password);
+ Bundle parameters = new Bundle();
+ parameters.putString(ConfigHelper.USERNAME_KEY, username);
+ parameters.putString(ConfigHelper.PASSWORD_KEY, password);
JSONObject provider_json;
try {
provider_json = new JSONObject(preferences.getString(ConfigHelper.PROVIDER_KEY, ""));
- method_and_parameters.putString(ConfigHelper.API_URL_KEY, provider_json.getString(ConfigHelper.API_URL_KEY) + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY));
+ parameters.putString(ConfigHelper.API_URL_KEY, provider_json.getString(ConfigHelper.API_URL_KEY) + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- provider_API_command.putExtra(ConfigHelper.SRP_AUTH, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.SRP_AUTH);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
if(mProgressDialog != null) mProgressDialog.dismiss();
@@ -242,18 +243,19 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
providerAPI_result_receiver.setReceiver(this);
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
+ Bundle parameters = new Bundle();
JSONObject provider_json;
try {
provider_json = new JSONObject(preferences.getString(ConfigHelper.PROVIDER_KEY, ""));
- method_and_parameters.putString(ConfigHelper.API_URL_KEY, provider_json.getString(ConfigHelper.API_URL_KEY) + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY));
+ parameters.putString(ConfigHelper.API_URL_KEY, provider_json.getString(ConfigHelper.API_URL_KEY) + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- provider_API_command.putExtra(ConfigHelper.LOG_OUT, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.LOG_OUT);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
if(mProgressDialog != null) mProgressDialog.dismiss();
@@ -265,7 +267,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
* Shows the log in dialog.
* @param view from which the dialog is created.
*/
- public void logInDialog(View view, String user_message) {
+ public void logInDialog(View view, Bundle resultData) {
FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction();
Fragment previous_log_in_dialog = getFragmentManager().findFragmentByTag(ConfigHelper.LOG_IN_DIALOG);
if (previous_log_in_dialog != null) {
@@ -274,9 +276,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
fragment_transaction.addToBackStack(null);
DialogFragment newFragment = LogInDialog.newInstance();
- if(user_message != null && !user_message.isEmpty()) {
+ if(resultData != null && !resultData.isEmpty()) {
Bundle user_message_bundle = new Bundle();
+ String user_message = resultData.getString(getResources().getString(R.string.user_message));
+ String username = resultData.getString(ConfigHelper.USERNAME_KEY);
user_message_bundle.putString(getResources().getString(R.string.user_message), user_message);
+ user_message_bundle.putString(ConfigHelper.USERNAME_KEY, username);
newFragment.setArguments(user_message_bundle);
}
newFragment.show(fragment_transaction, ConfigHelper.LOG_IN_DIALOG);
@@ -292,12 +297,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle method_and_parameters = new Bundle();
- method_and_parameters.putString(ConfigHelper.TYPE_OF_CERTIFICATE, ConfigHelper.AUTHED_CERTIFICATE);
- method_and_parameters.putString(ConfigHelper.SESSION_ID_COOKIE_KEY, session_id.getName());
- method_and_parameters.putString(ConfigHelper.SESSION_ID_KEY, session_id.getValue());
+ Bundle parameters = new Bundle();
+ parameters.putString(ConfigHelper.TYPE_OF_CERTIFICATE, ConfigHelper.AUTHED_CERTIFICATE);
+ parameters.putString(ConfigHelper.SESSION_ID_COOKIE_KEY, session_id.getName());
+ parameters.putString(ConfigHelper.SESSION_ID_KEY, session_id.getValue());
- provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
+ provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
@@ -316,7 +322,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
downloadAuthedUserCertificate(session_id);
} else if(resultCode == ConfigHelper.SRP_AUTHENTICATION_FAILED) {
mProgressDialog.dismiss();
- logInDialog(getCurrentFocus(), resultData.getString(getResources().getString(R.string.user_message)));
+ logInDialog(getCurrentFocus(), resultData);
} else if(resultCode == ConfigHelper.LOGOUT_SUCCESSFUL) {
authed = false;
invalidateOptionsMenu();
diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java
index 8b3f9e80..8e8bb65a 100644
--- a/src/se/leap/leapclient/LogInDialog.java
+++ b/src/se/leap/leapclient/LogInDialog.java
@@ -48,8 +48,16 @@ public class LogInDialog extends DialogFragment {
if(getArguments() != null && getArguments().containsKey(getResources().getString(R.string.user_message))) {
user_message.setText(getArguments().getString(getResources().getString(R.string.user_message)));
} else user_message.setVisibility(View.GONE);
+
final EditText username_field = (EditText)log_in_dialog_view.findViewById(R.id.username_entered);
+ if(getArguments() != null && getArguments().containsKey(getResources().getString(R.string.user_message))) {
+ String username = getArguments().getString(ConfigHelper.USERNAME_KEY);
+ username_field.setText(username);
+ username_field.setHint("");
+ }
final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered);
+ if(!username_field.getText().toString().isEmpty() && password_field.isFocusable())
+ password_field.requestFocus();
builder.setView(log_in_dialog_view)
.setPositiveButton(R.string.login_button, new DialogInterface.OnClickListener() {
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index 944a0e7f..dc0b2aa6 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -17,6 +17,7 @@
package se.leap.leapclient;
import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
@@ -88,6 +89,17 @@ public class ProviderAPI extends IntentService {
private Handler mHandler;
+ final public static String
+ DOWNLOAD_JSON_FILES_BUNDLE_EXTRA = "downloadJSONFiles",
+ UPDATE_PROVIDER_DOTJSON = "updateProviderDotJSON",
+ DOWNLOAD_NEW_PROVIDER_DOTJSON = "downloadNewProviderDotJSON",
+ SRP_REGISTER = "srpRegister",
+ SRP_AUTH = "srpAuth",
+ LOG_OUT = "logOut",
+ DOWNLOAD_CERTIFICATE = "downloadUserAuthedCertificate",
+ PARAMETERS = "parameters"
+ ;
+
public ProviderAPI() {
super("ProviderAPI");
Log.v("ClassName", "Provider API");
@@ -110,53 +122,46 @@ public class ProviderAPI extends IntentService {
}
@Override
- protected void onHandleIntent(Intent task_for) {
- final ResultReceiver receiver = task_for.getParcelableExtra("receiver");
+ protected void onHandleIntent(Intent command) {
+ final ResultReceiver receiver = command.getParcelableExtra("receiver");
+ String action = command.getAction();
+ Bundle parameters = command.getBundleExtra(PARAMETERS);
- Bundle task;
- if((task = task_for.getBundleExtra(ConfigHelper.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA)) != null) {
- if(!downloadJsonFiles(task)) {
+ if(action.equalsIgnoreCase(DOWNLOAD_JSON_FILES_BUNDLE_EXTRA)) {
+ if(!downloadJsonFiles(parameters)) {
receiver.send(ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES, Bundle.EMPTY);
} else {
receiver.send(ConfigHelper.CORRECTLY_DOWNLOADED_JSON_FILES, Bundle.EMPTY);
}
- }
- else if ((task = task_for.getBundleExtra(ConfigHelper.UPDATE_PROVIDER_DOTJSON)) != null) {
- Bundle result = updateProviderDotJSON(task);
+ } else if(action.equalsIgnoreCase(UPDATE_PROVIDER_DOTJSON)) {
+ Bundle result = updateProviderDotJSON(parameters);
if(result.getBoolean(ConfigHelper.RESULT_KEY)) {
receiver.send(ConfigHelper.CORRECTLY_UPDATED_PROVIDER_DOT_JSON, result);
- } else {
+ } else {
receiver.send(ConfigHelper.INCORRECTLY_UPDATED_PROVIDER_DOT_JSON, Bundle.EMPTY);
}
- }
- else if ((task = task_for.getBundleExtra(ConfigHelper.DOWNLOAD_NEW_PROVIDER_DOTJSON)) != null) {
- Bundle result = downloadNewProviderDotJSON(task);
+ } else if (action.equalsIgnoreCase(DOWNLOAD_NEW_PROVIDER_DOTJSON)) {
+ Bundle result = downloadNewProviderDotJSON(parameters);
if(result.getBoolean(ConfigHelper.RESULT_KEY)) {
receiver.send(ConfigHelper.CORRECTLY_UPDATED_PROVIDER_DOT_JSON, result);
} else {
receiver.send(ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES, Bundle.EMPTY);
}
- }
- else if ((task = task_for.getBundleExtra(ConfigHelper.SRP_AUTH)) != null) {
- Bundle session_id_bundle = authenticateBySRP(task);
+ } else if (action.equalsIgnoreCase(SRP_AUTH)) {
+ Bundle session_id_bundle = authenticateBySRP(parameters);
if(session_id_bundle.getBoolean(ConfigHelper.RESULT_KEY)) {
receiver.send(ConfigHelper.SRP_AUTHENTICATION_SUCCESSFUL, session_id_bundle);
} else {
- Bundle user_message_bundle = new Bundle();
- String user_message_key = getResources().getString(R.string.user_message);
- user_message_bundle.putString(user_message_key, session_id_bundle.getString(user_message_key));
- receiver.send(ConfigHelper.SRP_AUTHENTICATION_FAILED, user_message_bundle);
+ receiver.send(ConfigHelper.SRP_AUTHENTICATION_FAILED, session_id_bundle);
}
- }
- else if ((task = task_for.getBundleExtra(ConfigHelper.LOG_OUT)) != null) {
- if(logOut(task)) {
+ } else if (action.equalsIgnoreCase(LOG_OUT)) {
+ if(logOut(parameters)) {
receiver.send(ConfigHelper.LOGOUT_SUCCESSFUL, Bundle.EMPTY);
} else {
receiver.send(ConfigHelper.LOGOUT_FAILED, Bundle.EMPTY);
}
- }
- else if ((task = task_for.getBundleExtra(ConfigHelper.DOWNLOAD_CERTIFICATE)) != null) {
- if(getNewCert(task)) {
+ } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
+ if(getNewCert(parameters)) {
receiver.send(ConfigHelper.CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
} else {
receiver.send(ConfigHelper.INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
@@ -215,27 +220,34 @@ public class ProviderAPI extends IntentService {
} else {
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_bad_user_password_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
}
} else {
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_bad_user_password_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
}
} catch (ClientProtocolException e) {
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_client_http_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
} catch (IOException e) {
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_io_exception_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
} catch (JSONException e) {
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_json_exception_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
} catch (NoSuchAlgorithmException e) {
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_no_such_algorithm_exception_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
}
} else {
session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false);
session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_not_valid_password_user_message));
+ session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username);
}
return session_id_bundle;
@@ -407,6 +419,9 @@ public class ProviderAPI extends IntentService {
displayToast(R.string.malformed_url);
} catch(SocketTimeoutException e) {
displayToast(R.string.server_is_down_message);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ displayToast(R.string.server_is_down_message);
} catch (IOException e) {
if(provider_url != null) {
json_file_content = getStringFromProviderWithCACertAdded(provider_url, danger_on);
@@ -447,6 +462,9 @@ public class ProviderAPI extends IntentService {
json_string = new Scanner(urlConnection.getInputStream()).useDelimiter("\\A").next();
} catch (MalformedURLException e) {
displayToast(R.string.malformed_url);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ displayToast(R.string.server_is_down_message);
} catch (IOException e) {
json_string = getStringFromProviderIgnoringCertificate(string_url);
}
@@ -499,6 +517,9 @@ public class ProviderAPI extends IntentService {
e.printStackTrace();
} catch (UnknownHostException e) {
displayToast(R.string.server_is_down_message);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ displayToast(R.string.server_is_down_message);
} catch (IOException e) {
// The downloaded certificate doesn't validate our https connection.
if(danger_on) {
@@ -552,6 +573,9 @@ public class ProviderAPI extends IntentService {
});
string = new Scanner(urlConnection.getInputStream()).useDelimiter("\\A").next();
System.out.println("String ignoring certificate = " + string);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ displayToast(R.string.server_is_down_message);
} catch (IOException e) {
// The downloaded certificate doesn't validate our https connection.
e.printStackTrace();