]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Prevent editing of read-only profiles
authorMarkus Pfeiffer <markus.pfeiffer@relution.io>
Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Feb 2024 11:24:53 +0000 (12:24 +0100)
Do not allow users to edit read-only VPN profiles, with the exception of
the profile's password.

src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java

index 30787e1fd0c243c0ba24586584db8cff76bb95f8..6746711a5bc8ffe2f1b778bce5b117a5c82ffe01 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2023 Relution GmbH
  * Copyright (C) 2012-2020 Tobias Brunner
  * Copyright (C) 2012 Giuliano Grassi
  * Copyright (C) 2012 Ralf Sager
@@ -787,6 +788,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                local_id = mProfile.getLocalId();
                                alias = mProfile.getCertificateAlias();
                                getSupportActionBar().setTitle(mProfile.getName());
+
+                               setReadOnly(mProfile.isReadOnly());
                        }
                        else
                        {
@@ -851,6 +854,44 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                }
        }
 
+       private void setReadOnly(final boolean readOnly)
+       {
+               mName.setEnabled(!readOnly);
+               mGateway.setEnabled(!readOnly);
+               mUsername.setEnabled(!readOnly);
+               mRemoteId.setEnabled(!readOnly);
+               mLocalId.setEnabled(!readOnly);
+               mMTU.setEnabled(!readOnly);
+               mPort.setEnabled(!readOnly);
+               mNATKeepalive.setEnabled(!readOnly);
+               mIncludedSubnets.setEnabled(!readOnly);
+               mExcludedSubnets.setEnabled(!readOnly);
+               mBlockIPv4.setEnabled(!readOnly);
+               mBlockIPv6.setEnabled(!readOnly);
+               mIkeProposal.setEnabled(!readOnly);
+               mEspProposal.setEnabled(!readOnly);
+               mDnsServers.setEnabled(!readOnly);
+
+               mSelectVpnType.setEnabled(!readOnly);
+               mCertReq.setEnabled(!readOnly);
+               mUseCrl.setEnabled(!readOnly);
+               mUseOcsp.setEnabled(!readOnly);
+               mStrictRevocation.setEnabled(!readOnly);
+               mRsaPss.setEnabled(!readOnly);
+               mIPv6Transport.setEnabled(!readOnly);
+
+               mCheckAuto.setEnabled(!readOnly);
+               mSelectSelectedAppsHandling.setEnabled(!readOnly);
+
+               findViewById(R.id.install_user_certificate).setEnabled(!readOnly);
+
+               if (readOnly)
+               {
+                       mSelectCert.setOnClickListener(null);
+                       mSelectUserCert.setOnClickListener(null);
+               }
+       }
+
        /**
         * Get the string value in the given text box or null if empty
         *