]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Allow selecting a user certificate for managed profiles
authorTobias Brunner <tobias@strongswan.org>
Thu, 25 Sep 2025 16:37:15 +0000 (18:37 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 30 Sep 2025 09:26:41 +0000 (11:26 +0200)
This is only enabled for profiles that are not distributed with a
certificate.

src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfileManagedDataSource.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java
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-uk/strings.xml
src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index 0f6ec6292df3f6f3f6fc12fa7bf6a30a94be8f24..eaf0cfaac8cebf7ac61e2a2b0579ce8a8e677319 100644 (file)
@@ -33,6 +33,7 @@ import java.util.UUID;
 public class VpnProfileManagedDataSource implements VpnProfileDataSource
 {
        private static final String NAME_MANAGED_VPN_PROFILES = "org.strongswan.android.data.VpnProfileManagedDataSource.preferences";
+       private static final String PREFIX_USER_CERT = "usercert:";
 
        private final ManagedConfigurationService mManagedConfigurationService;
        private final SharedPreferences mSharedPreferences;
@@ -52,11 +53,14 @@ public class VpnProfileManagedDataSource implements VpnProfileDataSource
        @Override
        public void close()
        {
-               /* remove passwords that are no longer referenced by a VPN profile */
-               final Set<String> actualKeys = mManagedConfigurationService.getManagedProfiles().keySet();
-
+               /* remove settings not referenced by a VPN profile */
                final Set<String> storedKeys = new HashSet<>(mSharedPreferences.getAll().keySet());
-               storedKeys.removeAll(actualKeys);
+
+               for (String uuid : mManagedConfigurationService.getManagedProfiles().keySet())
+               {
+                       storedKeys.remove(uuid);
+                       storedKeys.remove(PREFIX_USER_CERT + uuid);
+               }
 
                final SharedPreferences.Editor editor = mSharedPreferences.edit();
                for (String key : storedKeys)
@@ -84,6 +88,7 @@ public class VpnProfileManagedDataSource implements VpnProfileDataSource
 
                final SharedPreferences.Editor editor = mSharedPreferences.edit();
                editor.putString(profile.getUUID().toString(), profile.getPassword());
+               editor.putString(PREFIX_USER_CERT + profile.getUUID().toString(), profile.getUserCertificateAlias());
                return editor.commit();
        }
 
@@ -100,8 +105,10 @@ public class VpnProfileManagedDataSource implements VpnProfileDataSource
        private VpnProfile prepareVpnProfile(VpnProfile managedProfile)
        {
                final String password = mSharedPreferences.getString(managedProfile.getUUID().toString(), managedProfile.getPassword());
+               final String alias = mSharedPreferences.getString(PREFIX_USER_CERT + managedProfile.getUUID().toString(), managedProfile.getUserCertificateAlias());
                final VpnProfile vpnProfile = managedProfile.clone();
                vpnProfile.setPassword(password);
+               vpnProfile.setUserCertificateAlias(alias);
                vpnProfile.setDataSource(this);
                return vpnProfile;
        }
index 13e38273e6c48556e5f8d195eefccfcc757cda17..aeef179ce559a2d32cae632ef53bb4aaae7ea650 100644 (file)
@@ -54,6 +54,7 @@ import android.widget.Spinner;
 import android.widget.TextView;
 
 import org.strongswan.android.R;
+import org.strongswan.android.data.ManagedVpnProfile;
 import org.strongswan.android.data.VpnProfile;
 import org.strongswan.android.data.VpnProfile.SelectedAppsHandling;
 import org.strongswan.android.data.VpnProfileDataSource;
@@ -817,7 +818,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                alias = mProfile.getCertificateAlias();
                                getSupportActionBar().setTitle(mProfile.getName());
 
-                               setReadOnly(mProfile.isReadOnly());
+                               setReadOnly(mProfile);
                        }
                        else
                        {
@@ -882,8 +883,10 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                }
        }
 
-       private void setReadOnly(final boolean readOnly)
+       private void setReadOnly(final VpnProfile profile)
        {
+               final boolean readOnly = profile.isReadOnly();
+
                mManagedProfile.setVisibility(readOnly ? View.VISIBLE : View.GONE);
 
                mName.setEnabled(!readOnly);
@@ -920,8 +923,12 @@ public class VpnProfileDetailActivity extends AppCompatActivity
 
                if (readOnly)
                {
+                       ManagedVpnProfile managedProfile = (ManagedVpnProfile)profile;
                        mSelectCert.setOnClickListener(null);
-                       mSelectUserCert.setOnClickListener(null);
+                       if (managedProfile.getUserCertificate() != null)
+                       {
+                               mSelectUserCert.setOnClickListener(null);
+                       }
                }
        }
 
index 6047ed63f054f5881e213e66935924b3c8b7f13b..3691a598c8c3a6e25a1fd94535031eb7ed2f076f 100644 (file)
     <string name="alert_text_no_subnets">Bitte geben Sie mit Leerzeichen getrennte, gültige Subnetzte und/oder IP-Adressen ein</string>
     <string name="alert_text_no_ips">Bitte geben Sie mit Leerzeichen getrennte, gültige IP-Adressen ein</string>
     <string name="alert_text_no_proposal">Bitte geben Sie eine mit Bindestrichen getrennte, gültige Liste von Algorithmen ein</string>
-    <string name="alert_text_vpn_profile_read_only">Dieses Profil wird von Ihrem Administrator verwaltet und kann nicht bearbeitet werden. Nur das Passwort kann geändert werden</string>
+    <string name="alert_text_vpn_profile_read_only">Dieses Profil wird von Ihrem Administrator verwaltet und kann nicht bearbeitet werden. Nur das Passwort bzw. Benutzer-Zertifikat kann geändert werden</string>
     <string name="tnc_notice_title">EAP-TNC kann Ihre Privatsphäre beeinträchtigen</string>
     <string name="tnc_notice_subtitle">Gerätedaten werden an den Server-Betreiber gesendet</string>
     <string name="tnc_notice_details"><![CDATA[<p>Trusted Network Connect (TNC) erlaubt Server-Betreibern den Gesundheitszustand von Endgeräten zu prüfen.</p><p>Dazu kann der Betreiber Daten verlangen, wie etwa eine eindeutige Identifikationsnummer, eine Liste der installierten Pakete, Systemeinstellungen oder kryptografische Prüfsummen von Dateien.</p><b>Solche Daten werden nur übermittelt nachdem die Identität des Servers geprüft wurde.</b>]]></string>
index 8d98fe36b81dd85683812248b2b0553c9b5e0a00..4a3b92201bccc3078046720982aa7bf4200a0a9e 100644 (file)
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
     <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
-    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password</string>
+    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password or user certificate</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
     <string name="tnc_notice_details"><![CDATA[<p>Trusted Network Connect (TNC) allows server operators to assess the health of a client device.</p><p>For that purpose the server operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.</p><b>Any data will be sent only after verifying the server\'s identity.</b>]]></string>
index 0f8c724ad734e846f065802716f317efab013505..bb7173e920dbd8636c045e8723a8fa06af3a425c 100644 (file)
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
     <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
-    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password</string>
+    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password or user certificate</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
     <string name="tnc_notice_details"><![CDATA[<p>Trusted Network Connect (TNC) allows server operators to assess the health of a client device.</p><p>For that purpose the server operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.</p><b>Any data will be sent only after verifying the server\'s identity.</b>]]></string>
index 2b552b60646895cab0016d4248dcc84cc2cf22a4..c92f170b24c10c0cd8fa41a9f94d2c0289e31569 100644 (file)
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
     <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
-    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password</string>
+    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password or user certificate</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
     <string name="tnc_notice_details"><![CDATA[<p>Trusted Network Connect (TNC) allows server operators to assess the health of a client device.</p><p>For that purpose the server operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.</p><b>Any data will be sent only after verifying the server\'s identity.</b>]]></string>
index fe96028367f4810e4a72f812ef3aedb9772955e0..d2b21f2271f7c906dc25ca9e9e32cf1a0585f108 100644 (file)
     <string name="alert_text_no_subnets">请输入有效的子网和/或IP地址,用空格分隔</string>
     <string name="alert_text_no_ips">请输入有效的IP地址,以空格分隔</string>
     <string name="alert_text_no_proposal">请输入用连字符分隔的有效算法列表</string>
-    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password</string>
+    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password or user certificate</string>
     <string name="tnc_notice_title">EAP-TNC可能会影响您的隐私</string>
     <string name="tnc_notice_subtitle">设备数据已被发送至服务器管理员</string>
     <string name="tnc_notice_details"><![CDATA[<p>可信网络连接t (TNC) 允许服务器管理员评定一个用户设备的状况。</p><p>出于此目的,服务器管理员可能要求以下数据如独立ID、已安装软件列表、系统设置、或加密过的文件校验值。</p><b>任何数据都仅将在验证过服务器的身份ID之后被发出。</b>]]></string>
index 26f3e80a10db24b5df03837fbea2c0e1196a46da..6c74fc7867eb11188fe07b9c39e7675397b147d8 100644 (file)
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
     <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
-    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password</string>
+    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password or user certificate</string>
     <string name="tnc_notice_title">EAP-TNC可能會影響您的隱私安全</string>
     <string name="tnc_notice_subtitle">裝置資料已經發送給伺服器管理者</string>
     <string name="tnc_notice_details"><![CDATA[<p>Trusted Network Connect (TNC) 可以讓伺服器管理者評估用戶裝置的狀況。</p><p>在這個目的下,伺服器管理者可能會要求以下資料,例如ID、已安裝的App項目、系統設定、或加密檔案驗證值。</p><b>任何資料都只有在驗證伺服器的身分ID之後才會被送出。</b>]]></string>
index 7f031bec83e49b5204870433b993eb80c83bed05..667375864d50ee414ada24d831b7fdfc4b6d80ae 100644 (file)
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
     <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
-    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password</string>
+    <string name="alert_text_vpn_profile_read_only">This VPN profile is managed by your administrator and can\'t be modified. You can only change the password or user certificate</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
     <string name="tnc_notice_details"><![CDATA[<p>Trusted Network Connect (TNC) allows server operators to assess the health of a client device.</p><p>For that purpose the server operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.</p><b>Any data will be sent only after verifying the server\'s identity.</b>]]></string>