diff options
author | Tobias Brunner <tobias@strongswan.org> | 2014-05-30 16:15:25 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2014-07-22 10:41:49 +0200 |
commit | f21a69dbece0bb1dd7ed720ddcb14fa8e1553fcf (patch) | |
tree | 32e0e6d6fcab609239847fc44273881a1a7efee8 /src | |
parent | 3b2b536b707520f4084cd6ab8ccab41d515aced2 (diff) | |
download | strongswan-f21a69dbece0bb1dd7ed720ddcb14fa8e1553fcf.tar.bz2 strongswan-f21a69dbece0bb1dd7ed720ddcb14fa8e1553fcf.tar.xz |
android: Allow selection of local certificates
Diffstat (limited to 'src')
7 files changed, 31 insertions, 19 deletions
diff --git a/src/frontends/android/res/values-de/strings.xml b/src/frontends/android/res/values-de/strings.xml index db7698135..1f283bbf5 100644 --- a/src/frontends/android/res/values-de/strings.xml +++ b/src/frontends/android/res/values-de/strings.xml @@ -78,6 +78,7 @@ <string name="no_certificates">Keine Zertifikate</string> <string name="system_tab">System</string> <string name="user_tab">Benutzer</string> + <string name="local_tab">Importiert</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 7aa9c51a7..8b13d4abe 100644 --- a/src/frontends/android/res/values-pl/strings.xml +++ b/src/frontends/android/res/values-pl/strings.xml @@ -78,6 +78,7 @@ <string name="no_certificates">Brak certyfikatów</string> <string name="system_tab">System</string> <string name="user_tab">Użytkownik</string> + <string name="local_tab">Imported</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 3838485af..4a20a9b86 100644 --- a/src/frontends/android/res/values-ru/strings.xml +++ b/src/frontends/android/res/values-ru/strings.xml @@ -75,6 +75,7 @@ <string name="no_certificates">Нет доступных сертификатов</string> <string name="system_tab">Система</string> <string name="user_tab">Пользователь</string> + <string name="local_tab">Imported</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 df016ff8f..18759f3ea 100644 --- a/src/frontends/android/res/values-ua/strings.xml +++ b/src/frontends/android/res/values-ua/strings.xml @@ -76,6 +76,7 @@ <string name="no_certificates">Немає сертифікатів</string> <string name="system_tab">Система</string> <string name="user_tab">Користувач</string> + <string name="local_tab">Imported</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 180948969..e5f47fc6c 100644 --- a/src/frontends/android/res/values/strings.xml +++ b/src/frontends/android/res/values/strings.xml @@ -78,6 +78,7 @@ <string name="no_certificates">No certificates</string> <string name="system_tab">System</string> <string name="user_tab">User</string> + <string name="local_tab">Imported</string> <!-- VPN state fragment --> <string name="state_label">Status:</string> diff --git a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java index 918393fe6..ba4445fcf 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java +++ b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Tobias Brunner + * Copyright (C) 2012-2014 Tobias Brunner * Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it @@ -46,9 +46,10 @@ import android.widget.SearchView.OnQueryTextListener; public class TrustedCertificateListFragment extends ListFragment implements LoaderCallbacks<List<TrustedCertificateEntry>>, OnQueryTextListener { + public static final String EXTRA_CERTIFICATE_SOURCE = "certificate_source"; private OnTrustedCertificateSelectedListener mListener; private TrustedCertificateAdapter mAdapter; - private boolean mUser; + private TrustedCertificateSource mSource = TrustedCertificateSource.SYSTEM; /** * The activity containing this fragment should implement this interface @@ -70,8 +71,11 @@ public class TrustedCertificateListFragment extends ListFragment implements Load setListShown(false); - /* non empty arguments mean we list user certificate */ - mUser = getArguments() != null; + Bundle arguments = getArguments(); + if (arguments != null) + { + mSource = (TrustedCertificateSource)arguments.getSerializable(EXTRA_CERTIFICATE_SOURCE); + } getLoaderManager().initLoader(0, null, this); } @@ -122,7 +126,7 @@ public class TrustedCertificateListFragment extends ListFragment implements Load @Override public Loader<List<TrustedCertificateEntry>> onCreateLoader(int id, Bundle args) { /* we don't need the id as we have only one loader */ - return new CertificateListLoader(getActivity(), mUser); + return new CertificateListLoader(getActivity(), mSource); } @Override @@ -158,22 +162,21 @@ public class TrustedCertificateListFragment extends ListFragment implements Load public static class CertificateListLoader extends AsyncTaskLoader<List<TrustedCertificateEntry>> { private List<TrustedCertificateEntry> mData; - private final boolean mUser; + private final TrustedCertificateSource mSource; - public CertificateListLoader(Context context, boolean user) + public CertificateListLoader(Context context, TrustedCertificateSource source) { super(context); - mUser = user; + mSource = source; } @Override public List<TrustedCertificateEntry> loadInBackground() { TrustedCertificateManager certman = TrustedCertificateManager.getInstance().load(); - Hashtable<String,X509Certificate> certificates; + Hashtable<String,X509Certificate> certificates = certman.getCACertificates(mSource); List<TrustedCertificateEntry> selected; - certificates = mUser ? certman.getCACertificates(TrustedCertificateSource.USER) : certman.getCACertificates(TrustedCertificateSource.SYSTEM); selected = new ArrayList<TrustedCertificateEntry>(); for (Entry<String, X509Certificate> entry : certificates.entrySet()) { 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 2874207e8..3ee378196 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java +++ b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java @@ -17,6 +17,7 @@ package org.strongswan.android.ui; import org.strongswan.android.R; import org.strongswan.android.data.VpnProfileDataSource; +import org.strongswan.android.logic.TrustedCertificateManager.TrustedCertificateSource; import org.strongswan.android.security.TrustedCertificateEntry; import android.app.ActionBar; @@ -43,11 +44,15 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert actionBar.addTab(actionBar .newTab() .setText(R.string.system_tab) - .setTabListener(new TrustedCertificatesTabListener(this, "system", false))); + .setTabListener(new TrustedCertificatesTabListener(this, "system", TrustedCertificateSource.SYSTEM))); actionBar.addTab(actionBar .newTab() .setText(R.string.user_tab) - .setTabListener(new TrustedCertificatesTabListener(this, "user", true))); + .setTabListener(new TrustedCertificatesTabListener(this, "user", TrustedCertificateSource.USER))); + actionBar.addTab(actionBar + .newTab() + .setText(R.string.local_tab) + .setTabListener(new TrustedCertificatesTabListener(this, "local", TrustedCertificateSource.LOCAL))); if (savedInstanceState != null) { @@ -87,13 +92,13 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert public static class TrustedCertificatesTabListener implements ActionBar.TabListener { private final String mTag; - private final boolean mUser; + private final TrustedCertificateSource mSource; private Fragment mFragment; - public TrustedCertificatesTabListener(Activity activity, String tag, boolean user) + public TrustedCertificatesTabListener(Activity activity, String tag, TrustedCertificateSource source) { mTag = tag; - mUser = user; + mSource = source; /* check to see if we already have a fragment for this tab, probably * from a previously saved state. if so, deactivate it, because the * initial state is that no tab is shown */ @@ -112,10 +117,9 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert if (mFragment == null) { mFragment = new TrustedCertificateListFragment(); - if (mUser) - { /* use non empty arguments to indicate this */ - mFragment.setArguments(new Bundle()); - } + Bundle args = new Bundle(); + args.putSerializable(TrustedCertificateListFragment.EXTRA_CERTIFICATE_SOURCE, mSource); + mFragment.setArguments(args); ft.add(android.R.id.content, mFragment, mTag); } else |