aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontends/android/AndroidManifest.xml12
-rw-r--r--src/frontends/android/res/values-de/strings.xml3
-rw-r--r--src/frontends/android/res/values-pl/strings.xml3
-rw-r--r--src/frontends/android/res/values-ru/strings.xml3
-rw-r--r--src/frontends/android/res/values-ua/strings.xml3
-rw-r--r--src/frontends/android/res/values/strings.xml3
-rw-r--r--src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateImportActivity.java62
7 files changed, 89 insertions, 0 deletions
diff --git a/src/frontends/android/AndroidManifest.xml b/src/frontends/android/AndroidManifest.xml
index e2d25e4ac..887063faa 100644
--- a/src/frontends/android/AndroidManifest.xml
+++ b/src/frontends/android/AndroidManifest.xml
@@ -67,6 +67,18 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <activity
+ android:name=".ui.TrustedCertificateImportActivity"
+ android:label="@string/import_certificate" >
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="application/x-x509-ca-cert" />
+ <data android:mimeType="application/x-x509-server-cert" />
+ <data android:mimeType="application/x-pem-file" />
+ <data android:mimeType="application/pkix-cert" />
+ </intent-filter>
+ </activity>
<service
android:name=".logic.VpnStateService"
diff --git a/src/frontends/android/res/values-de/strings.xml b/src/frontends/android/res/values-de/strings.xml
index c9b6f9d14..491fe8a8a 100644
--- a/src/frontends/android/res/values-de/strings.xml
+++ b/src/frontends/android/res/values-de/strings.xml
@@ -81,6 +81,9 @@
<string name="local_tab">Importiert</string>
<string name="delete_certificate_question">Zertifikat löschen?</string>
<string name="delete_certificate">Das Zertifikat wird permanent entfernt!</string>
+ <string name="import_certificate">Zertifikat importieren</string>
+ <string name="cert_imported_successfully">Zertifikat erfolgreich importiert</string>
+ <string name="cert_import_failed">Zertifikat-Import fehlgeschlagen</string>
<!-- VPN state fragment -->
<string name="state_label">Status:</string>
diff --git a/src/frontends/android/res/values-pl/strings.xml b/src/frontends/android/res/values-pl/strings.xml
index 5bde18c60..d0cfa48f1 100644
--- a/src/frontends/android/res/values-pl/strings.xml
+++ b/src/frontends/android/res/values-pl/strings.xml
@@ -81,6 +81,9 @@
<string name="local_tab">Imported</string>
<string name="delete_certificate_question">Delete certificate?</string>
<string name="delete_certificate">The certificate will be permanently removed!</string>
+ <string name="import_certificate">Import certificate</string>
+ <string name="cert_imported_successfully">Certificate successfully imported</string>
+ <string name="cert_import_failed">Failed to import certificate</string>
<!-- VPN state fragment -->
<string name="state_label">Status:</string>
diff --git a/src/frontends/android/res/values-ru/strings.xml b/src/frontends/android/res/values-ru/strings.xml
index f61b251fe..eb69183db 100644
--- a/src/frontends/android/res/values-ru/strings.xml
+++ b/src/frontends/android/res/values-ru/strings.xml
@@ -78,6 +78,9 @@
<string name="local_tab">Imported</string>
<string name="delete_certificate_question">Delete certificate?</string>
<string name="delete_certificate">The certificate will be permanently removed!</string>
+ <string name="import_certificate">Import certificate</string>
+ <string name="cert_imported_successfully">Certificate successfully imported</string>
+ <string name="cert_import_failed">Failed to import certificate</string>
<!-- VPN state fragment -->
<string name="state_label">Статус:</string>
diff --git a/src/frontends/android/res/values-ua/strings.xml b/src/frontends/android/res/values-ua/strings.xml
index bff97ecb1..e23b9b9b2 100644
--- a/src/frontends/android/res/values-ua/strings.xml
+++ b/src/frontends/android/res/values-ua/strings.xml
@@ -79,6 +79,9 @@
<string name="local_tab">Imported</string>
<string name="delete_certificate_question">Delete certificate?</string>
<string name="delete_certificate">The certificate will be permanently removed!</string>
+ <string name="import_certificate">Import certificate</string>
+ <string name="cert_imported_successfully">Certificate successfully imported</string>
+ <string name="cert_import_failed">Failed to import certificate</string>
<!-- VPN state fragment -->
<string name="state_label">Статус:</string>
diff --git a/src/frontends/android/res/values/strings.xml b/src/frontends/android/res/values/strings.xml
index f03d3e428..933a80aff 100644
--- a/src/frontends/android/res/values/strings.xml
+++ b/src/frontends/android/res/values/strings.xml
@@ -81,6 +81,9 @@
<string name="local_tab">Imported</string>
<string name="delete_certificate_question">Delete certificate?</string>
<string name="delete_certificate">The certificate will be permanently removed!</string>
+ <string name="import_certificate">Import certificate</string>
+ <string name="cert_imported_successfully">Certificate successfully imported</string>
+ <string name="cert_import_failed">Failed to import certificate</string>
<!-- VPN state fragment -->
<string name="state_label">Status:</string>
diff --git a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateImportActivity.java b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateImportActivity.java
new file mode 100644
index 000000000..663c414e2
--- /dev/null
+++ b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateImportActivity.java
@@ -0,0 +1,62 @@
+/*
+ * 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 <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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 java.io.InputStream;
+import java.security.KeyStore;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+import org.strongswan.android.R;
+import org.strongswan.android.logic.TrustedCertificateManager;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.Toast;
+
+public class TrustedCertificateImportActivity extends Activity
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ String action = intent.getAction();
+ if (Intent.ACTION_VIEW.equals(action))
+ {
+ try
+ {
+ CertificateFactory factory = CertificateFactory.getInstance("X.509");
+ InputStream in = getContentResolver().openInputStream(intent.getData());
+ X509Certificate certificate = (X509Certificate)factory.generateCertificate(in);
+ /* we don't check whether it's actually a CA certificate or not */
+ KeyStore store = KeyStore.getInstance("LocalCertificateStore");
+ store.load(null, null);
+ store.setCertificateEntry(null, certificate);
+ TrustedCertificateManager.getInstance().reset();
+ Toast.makeText(this, R.string.cert_imported_successfully, Toast.LENGTH_LONG).show();
+ }
+ catch (Exception e)
+ {
+ Toast.makeText(this, R.string.cert_import_failed, Toast.LENGTH_LONG).show();
+ e.printStackTrace();
+ }
+ }
+ finish();
+ }
+}