diff --git a/src/frontends/android/res/values-de/strings.xml b/src/frontends/android/res/values-de/strings.xml
index 269ac67ab..c9b6f9d14 100644
--- a/src/frontends/android/res/values-de/strings.xml
+++ b/src/frontends/android/res/values-de/strings.xml
@@ -79,6 +79,8 @@
System
Benutzer
Importiert
+ Zertifikat löschen?
+ Das Zertifikat wird permanent entfernt!
Status:
diff --git a/src/frontends/android/res/values-pl/strings.xml b/src/frontends/android/res/values-pl/strings.xml
index 1e05a66a5..5bde18c60 100644
--- a/src/frontends/android/res/values-pl/strings.xml
+++ b/src/frontends/android/res/values-pl/strings.xml
@@ -79,6 +79,8 @@
System
Użytkownik
Imported
+ Delete certificate?
+ The certificate will be permanently removed!
Status:
diff --git a/src/frontends/android/res/values-ru/strings.xml b/src/frontends/android/res/values-ru/strings.xml
index d90c28f9c..f61b251fe 100644
--- a/src/frontends/android/res/values-ru/strings.xml
+++ b/src/frontends/android/res/values-ru/strings.xml
@@ -76,6 +76,8 @@
Система
Пользователь
Imported
+ Delete certificate?
+ The certificate will be permanently removed!
Статус:
diff --git a/src/frontends/android/res/values-ua/strings.xml b/src/frontends/android/res/values-ua/strings.xml
index fe1e619ba..bff97ecb1 100644
--- a/src/frontends/android/res/values-ua/strings.xml
+++ b/src/frontends/android/res/values-ua/strings.xml
@@ -77,6 +77,8 @@
Система
Користувач
Imported
+ Delete certificate?
+ The certificate will be permanently removed!
Статус:
diff --git a/src/frontends/android/res/values/strings.xml b/src/frontends/android/res/values/strings.xml
index 7a8008888..f03d3e428 100644
--- a/src/frontends/android/res/values/strings.xml
+++ b/src/frontends/android/res/values/strings.xml
@@ -79,6 +79,8 @@
System
User
Imported
+ Delete certificate?
+ The certificate will be permanently removed!
Status:
diff --git a/src/frontends/android/src/org/strongswan/android/ui/CertificateDeleteConfirmationDialog.java b/src/frontends/android/src/org/strongswan/android/ui/CertificateDeleteConfirmationDialog.java
new file mode 100644
index 000000000..c381900c6
--- /dev/null
+++ b/src/frontends/android/src/org/strongswan/android/ui/CertificateDeleteConfirmationDialog.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 Tobias Brunner
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See .
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+package org.strongswan.android.ui;
+
+import org.strongswan.android.R;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
+/**
+ * Class that displays a confirmation dialog to delete a selected local
+ * certificate.
+ */
+public class CertificateDeleteConfirmationDialog extends DialogFragment
+{
+ public static final String ALIAS = "alias";
+ OnCertificateDeleteListener mListener;
+
+ /**
+ * Interface that can be implemented by parent activities to get the
+ * alias of the certificate to delete, if the user confirms the deletion.
+ */
+ public interface OnCertificateDeleteListener
+ {
+ public void onDelete(String alias);
+ }
+
+ @Override
+ public void onAttach(Activity activity)
+ {
+ super.onAttach(activity);
+ if (activity instanceof OnCertificateDeleteListener)
+ {
+ mListener = (OnCertificateDeleteListener)activity;
+ }
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState)
+ {
+ return new AlertDialog.Builder(getActivity())
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setTitle(R.string.delete_certificate_question)
+ .setMessage(R.string.delete_certificate)
+ .setPositiveButton(R.string.delete_profile, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton)
+ {
+ if (mListener != null)
+ {
+ mListener.onDelete(getArguments().getString(ALIAS));
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ dismiss();
+ }
+ }).create();
+ }
+}
diff --git a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java
index c175fb9bf..1211ef545 100644
--- a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java
+++ b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java
@@ -15,11 +15,14 @@
package org.strongswan.android.ui;
+import java.security.KeyStore;
+
import org.strongswan.android.R;
import org.strongswan.android.data.VpnProfileDataSource;
import org.strongswan.android.logic.TrustedCertificateManager;
import org.strongswan.android.logic.TrustedCertificateManager.TrustedCertificateSource;
import org.strongswan.android.security.TrustedCertificateEntry;
+import org.strongswan.android.ui.CertificateDeleteConfirmationDialog.OnCertificateDeleteListener;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
@@ -31,9 +34,10 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
-public class TrustedCertificatesActivity extends Activity implements TrustedCertificateListFragment.OnTrustedCertificateSelectedListener
+public class TrustedCertificatesActivity extends Activity implements TrustedCertificateListFragment.OnTrustedCertificateSelectedListener, OnCertificateDeleteListener
{
public static final String SELECT_CERTIFICATE = "org.strongswan.android.action.SELECT_CERTIFICATE";
+ private static final String DIALOG_TAG = "Dialog";
private boolean mSelect;
@Override
@@ -113,6 +117,35 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
setResult(Activity.RESULT_OK, intent);
finish();
}
+ else
+ {
+ TrustedCertificatesTabListener listener;
+ listener = (TrustedCertificatesTabListener)getActionBar().getSelectedTab().getTag();
+ if (listener.mTag == "local")
+ {
+ Bundle args = new Bundle();
+ args.putString(CertificateDeleteConfirmationDialog.ALIAS, selected.getAlias());
+ CertificateDeleteConfirmationDialog dialog = new CertificateDeleteConfirmationDialog();
+ dialog.setArguments(args);
+ dialog.show(this.getFragmentManager(), DIALOG_TAG);
+ }
+ }
+ }
+
+ @Override
+ public void onDelete(String alias)
+ {
+ try
+ {
+ KeyStore store = KeyStore.getInstance("LocalCertificateStore");
+ store.load(null, null);
+ store.deleteEntry(alias);
+ reloadCertificates();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
private void reloadCertificates()