]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Prompt the user to edit the profile if no certificate is selected
authorTobias Brunner <tobias@strongswan.org>
Tue, 30 Sep 2025 12:19:12 +0000 (14:19 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 30 Sep 2025 14:51:08 +0000 (16:51 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.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 a7b39b6ac2047580834e885aee6fdacb67d36abb..9ff07175e316e8a9d001662a9441e8ad02b8ddcc 100644 (file)
@@ -70,6 +70,7 @@ public class VpnProfileControlActivity extends AppCompatActivity
        private static final String WAITING_FOR_RESULT = "WAITING_FOR_RESULT";
        private static final String PROFILE_NAME = "PROFILE_NAME";
        private static final String PROFILE_REQUIRES_PASSWORD = "REQUIRES_PASSWORD";
+       private static final String PROFILE_CERTIFICATE_MISSING = "CERTIFICATE_MISSING";
        private static final String PROFILE_RECONNECT = "RECONNECT";
        private static final String PROFILE_DISCONNECT = "DISCONNECT";
        private static final String DIALOG_TAG = "Dialog";
@@ -332,6 +333,8 @@ public class VpnProfileControlActivity extends AppCompatActivity
                profileInfo.putString(VpnProfileDataSource.KEY_USERNAME, profile.getUsername());
                profileInfo.putString(VpnProfileDataSource.KEY_PASSWORD, profile.getPassword());
                profileInfo.putBoolean(PROFILE_REQUIRES_PASSWORD, profile.getVpnType().has(VpnTypeFeature.USER_PASS));
+               profileInfo.putBoolean(PROFILE_CERTIFICATE_MISSING, profile.getVpnType().has(VpnTypeFeature.CERTIFICATE) &&
+                                                          profile.getUserCertificateAlias() == null);
                profileInfo.putString(PROFILE_NAME, profile.getName());
 
                removeFragmentByTag(DIALOG_TAG);
@@ -355,6 +358,13 @@ public class VpnProfileControlActivity extends AppCompatActivity
         */
        private void startVpnProfile(Bundle profileInfo)
        {
+               if (profileInfo.getBoolean(PROFILE_CERTIFICATE_MISSING))
+               {
+                       CertificateRequiredDialog dialog = new CertificateRequiredDialog();
+                       dialog.setArguments(profileInfo);
+                       dialog.show(getSupportFragmentManager(), DIALOG_TAG);
+                       return;
+               }
                if (profileInfo.getBoolean(PROFILE_REQUIRES_PASSWORD) &&
                        profileInfo.getString(VpnProfileDataSource.KEY_PASSWORD) == null)
                {
@@ -621,6 +631,36 @@ public class VpnProfileControlActivity extends AppCompatActivity
                }
        }
 
+       /**
+        * Class that displays a dialog warning about a missing certificate.
+        */
+       public static class CertificateRequiredDialog extends AppCompatDialogFragment
+       {
+               @Override
+               public Dialog onCreateDialog(Bundle savedInstanceState)
+               {
+                       final Bundle profileInfo = getArguments();
+
+                       AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+                               .setTitle(R.string.certificate_required_title)
+                               .setMessage(R.string.certificate_required_text)
+                               .setNegativeButton(android.R.string.cancel, (dialog, which) -> getActivity().finish())
+                               .setPositiveButton(R.string.edit_profile, (dialog, which) -> {
+                                       Intent editIntent = new Intent(getActivity(), VpnProfileDetailActivity.class);
+                                       editIntent.putExtra(VpnProfileDataSource.KEY_UUID, profileInfo.getString(VpnProfileDataSource.KEY_UUID));
+                                       startActivity(editIntent);
+                                       getActivity().finish();
+                               });
+                       return builder.create();
+               }
+
+               @Override
+               public void onCancel(DialogInterface dialog)
+               {
+                       getActivity().finish();
+               }
+       }
+
        /**
         * Class that displays a warning before asking the user to add the app to the
         * device's power whitelist.
index 3691a598c8c3a6e25a1fd94535031eb7ed2f076f..c282004afdb69bc8a273fd51554618b7c983ad56 100644 (file)
     <string name="cancel_retry">Wiederholen abbrechen</string>
     <string name="power_whitelist_title">Akku-Optimierung deaktivieren</string>
     <string name="power_whitelist_text">Bitte den nächsten Dialog bestätigen, um die App auf die weisse Liste für Akku-Optimierung zu setzen, so dass sie NAT keepalives und Rekeyings zeitlich korrekt planen kann, um konstant erreichbar zu bleiben während die VPN-Verbindung besteht.</string>
+    <string name="certificate_required_title">Benutzer-Zertifikat benötigt</string>
+    <string name="certificate_required_text">Bitte bearbeiten Sie das VPN Profil, um eines auszuwählen.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">VPN umschalten</string>
index 4a3b92201bccc3078046720982aa7bf4200a0a9e..82d9655369c3be39d4ed5a6e69fde67d113e41ec 100644 (file)
     <string name="cancel_retry">Cancel retry</string>
     <string name="power_whitelist_title">Disable battery optimizations</string>
     <string name="power_whitelist_text">Please confirm the next dialog to add the app to the device\'s power whitelist so it can ignore battery optimizations and schedule NAT keep-alives and rekeyings accurately in order to constantly keep reachable while the VPN is established.</string>
+    <string name="certificate_required_title">User certificate required</string>
+    <string name="certificate_required_text">Please edit the VPN profile to select one.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index bb7173e920dbd8636c045e8723a8fa06af3a425c..ac09e3e4cb273d0d29bccd0d13f8a42101a43663 100644 (file)
     <string name="cancel_retry">Cancel retry</string>
     <string name="power_whitelist_title">Disable battery optimizations</string>
     <string name="power_whitelist_text">Please confirm the next dialog to add the app to the device\'s power whitelist so it can ignore battery optimizations and schedule NAT keep-alives and rekeyings accurately in order to constantly keep reachable while the VPN is established.</string>
+    <string name="certificate_required_title">User certificate required</string>
+    <string name="certificate_required_text">Please edit the VPN profile to select one.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index c92f170b24c10c0cd8fa41a9f94d2c0289e31569..a819bc83e2afc9f3c3bae92e65eb6e28de971db5 100644 (file)
     <string name="cancel_retry">Cancel retry</string>
     <string name="power_whitelist_title">Disable battery optimizations</string>
     <string name="power_whitelist_text">Please confirm the next dialog to add the app to the device\'s power whitelist so it can ignore battery optimizations and schedule NAT keep-alives and rekeyings accurately in order to constantly keep reachable while the VPN is established.</string>
+    <string name="certificate_required_title">User certificate required</string>
+    <string name="certificate_required_text">Please edit the VPN profile to select one.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index d2b21f2271f7c906dc25ca9e9e32cf1a0585f108..a7ad193c789866a1154c0f2fa26a3c08523f4187 100644 (file)
     <string name="cancel_retry">取消重试</string>
     <string name="power_whitelist_title">禁用电池优化</string>
     <string name="power_whitelist_text">请确认下一个对话框,将应用程序添加到设备的电源白名单中,这样它就可以忽略电池优化,并准确地安排NAT保持有效和重新键入,以便在建立VPN时始终保持可访问性。</string>
+    <string name="certificate_required_title">User certificate required</string>
+    <string name="certificate_required_text">Please edit the VPN profile to select one.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">切换VPN</string>
index 6c74fc7867eb11188fe07b9c39e7675397b147d8..5331675844b2912944e7aa637214d7ea034dcb85 100644 (file)
     <string name="cancel_retry">Cancel retry</string>
     <string name="power_whitelist_title">Disable battery optimizations</string>
     <string name="power_whitelist_text">Please confirm the next dialog to add the app to the device\'s power whitelist so it can ignore battery optimizations and schedule NAT keep-alives and rekeyings accurately in order to constantly keep reachable while the VPN is established.</string>
+    <string name="certificate_required_title">User certificate required</string>
+    <string name="certificate_required_text">Please edit the VPN profile to select one.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>
index 667375864d50ee414ada24d831b7fdfc4b6d80ae..417463606c0b5311932c0fbb6f1c1f0d8648e235 100644 (file)
     <string name="cancel_retry">Cancel retry</string>
     <string name="power_whitelist_title">Disable battery optimizations</string>
     <string name="power_whitelist_text">Please confirm the next dialog to add the app to the device\'s power whitelist so it can ignore battery optimizations and schedule NAT keep-alives and rekeyings accurately in order to constantly keep reachable while the VPN is established.</string>
+    <string name="certificate_required_title">User certificate required</string>
+    <string name="certificate_required_text">Please edit the VPN profile to select one.</string>
 
     <!-- Quick Settings tile -->
     <string name="tile_default">Toggle VPN</string>