From: Markus Pfeiffer Date: Tue, 21 Nov 2023 14:37:21 +0000 (+0100) Subject: android: Prevent editing of read-only profiles X-Git-Tag: android-2.5.0^2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3391f7a465f24e41c1ca36cfe2d1ae33a7bab7c9;p=thirdparty%2Fstrongswan.git android: Prevent editing of read-only profiles Do not allow users to edit read-only VPN profiles, with the exception of the profile's password. --- diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java index 30787e1fd0..6746711a5b 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java @@ -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 *