]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
android: Add adapter for user ID selection
authorTobias Brunner <tobias@strongswan.org>
Sat, 30 Apr 2016 14:59:00 +0000 (16:59 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 May 2016 16:39:18 +0000 (18:39 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/adapter/CertificateIdentitiesAdapter.java [new file with mode: 0644]
src/frontends/android/app/src/main/res/values-de/strings.xml
src/frontends/android/app/src/main/res/values-pl/strings.xml
src/frontends/android/app/src/main/res/values-ru/strings.xml
src/frontends/android/app/src/main/res/values-ua/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/adapter/CertificateIdentitiesAdapter.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/adapter/CertificateIdentitiesAdapter.java
new file mode 100644 (file)
index 0000000..c8e3df3
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 Tobias Brunner
+ * HSR 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.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import org.strongswan.android.R;
+import org.strongswan.android.security.TrustedCertificateEntry;
+
+import java.util.List;
+
+public class CertificateIdentitiesAdapter extends ArrayAdapter<String>
+{
+       TrustedCertificateEntry mCertificate;
+
+       public CertificateIdentitiesAdapter(Context context)
+       {
+               super(context, android.R.layout.simple_dropdown_item_1line);
+               extractIdentities();
+       }
+
+       /**
+        * Set a new certificate for this adapter.
+        *
+        * @param certificate the certificate to extract identities from (null to clear)
+        */
+       public void setCertificate(TrustedCertificateEntry certificate)
+       {
+               mCertificate = certificate;
+               clear();
+               extractIdentities();
+       }
+
+       private void extractIdentities()
+       {
+               if (mCertificate == null)
+               {
+                       add(getContext().getString(R.string.profile_user_select_id_init));
+               }
+               else
+               {
+                       add(String.format(getContext().getString(R.string.profile_user_select_id_default),
+                                                         mCertificate.getCertificate().getSubjectDN().getName()));
+                       addAll(mCertificate.getSubjectAltNames());
+               }
+       }
+}
index b5def060a7da7cefe3f84443a3f0a48b5f3af35e..15ccf24fd44be81055e66924af1869a676cc8e46 100644 (file)
@@ -61,6 +61,9 @@
     <string name="profile_user_certificate_label">Benutzer-Zertifikat</string>
     <string name="profile_user_select_certificate_label">Benutzer-Zertifikat auswählen</string>
     <string name="profile_user_select_certificate">Wählen Sie ein bestimmtes Benutzer-Zertifikat</string>
+    <string name="profile_user_select_id_label">Benutzer-Identität</string>
+    <string name="profile_user_select_id_init">Wählen Sie zuerst ein Benutzer-Zertifikat</string>
+    <string name="profile_user_select_id_default">Standardwert (%1$s)</string>
     <string name="profile_ca_label">CA-Zertifikat</string>
     <string name="profile_ca_auto_label">Automatisch wählen</string>
     <string name="profile_ca_select_certificate_label">CA-Zertifikat auswählen</string>
index cfd877f5089967c8d73f62b7ef10764f9daac5cf..c7aadb99439b6db9e7d1fb616e796ac30afca4e1 100644 (file)
@@ -61,6 +61,9 @@
     <string name="profile_user_certificate_label">Certyfikat użytkownika</string>
     <string name="profile_user_select_certificate_label">Wybierz certyfikat użytkownika</string>
     <string name="profile_user_select_certificate">>Wybierz określony certyfikat użytkownika</string>
+    <string name="profile_user_select_id_label">User identity</string>
+    <string name="profile_user_select_id_init">Select a certificate first</string>
+    <string name="profile_user_select_id_default">Default (%1$s)</string>
     <string name="profile_ca_label">Certyfikat CA</string>
     <string name="profile_ca_auto_label">Wybierz automatycznie</string>
     <string name="profile_ca_select_certificate_label">Wybierz certyfikat CA</string>
index cfd8129bdebfae6b85106dd465e73cc3baa44f04..c0a6484f836d5b2598c44a8969a13328ded625b6 100644 (file)
@@ -58,6 +58,9 @@
     <string name="profile_user_certificate_label">Сертификат пользователя</string>
     <string name="profile_user_select_certificate_label">Выбрать сертификат пользователя</string>
     <string name="profile_user_select_certificate">Выбрать сертификат пользователя</string>
+    <string name="profile_user_select_id_label">User identity</string>
+    <string name="profile_user_select_id_init">Select a certificate first</string>
+    <string name="profile_user_select_id_default">Default (%1$s)</string>
     <string name="profile_ca_label">Сертификат CA</string>
     <string name="profile_ca_auto_label">Выбрать автоматически</string>
     <string name="profile_ca_select_certificate_label">Выбрать сертификат CA</string>
index 85969898f855d0fd7abca0b489b57bdb552e4cf6..a852dfdbaac6db680fe81e4feae9c19decbb8b21 100644 (file)
@@ -59,6 +59,9 @@
     <string name="profile_user_certificate_label">Сертифікат користувача</string>
     <string name="profile_user_select_certificate_label">Виберіть сертифікат користувача</string>
     <string name="profile_user_select_certificate">Вибрати спеціальний сертифікат користувача</string>
+    <string name="profile_user_select_id_label">User identity</string>
+    <string name="profile_user_select_id_init">Select a certificate first</string>
+    <string name="profile_user_select_id_default">Default (%1$s)</string>
     <string name="profile_ca_label">Сертифікат CA</string>
     <string name="profile_ca_auto_label">Вибрати автоматично</string>
     <string name="profile_ca_select_certificate_label">Вибрати сертифікат CA</string>
index d704da062b52ad1beebe71719ce86b7248ecbb9c..d70712181d2936599efa0a50793187616dc0609f 100644 (file)
@@ -61,6 +61,9 @@
     <string name="profile_user_certificate_label">User certificate</string>
     <string name="profile_user_select_certificate_label">Select user certificate</string>
     <string name="profile_user_select_certificate">Select a specific user certificate</string>
+    <string name="profile_user_select_id_label">User identity</string>
+    <string name="profile_user_select_id_init">Select a certificate first</string>
+    <string name="profile_user_select_id_default">Default (%1$s)</string>
     <string name="profile_ca_label">CA certificate</string>
     <string name="profile_ca_auto_label">Select automatically</string>
     <string name="profile_ca_select_certificate_label">Select CA certificate</string>