android: Make remote identity configurable in the GUI
authorTobias Brunner <tobias@strongswan.org>
Sat, 30 Apr 2016 10:25:49 +0000 (12:25 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 May 2016 16:39:18 +0000 (18:39 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java
src/frontends/android/app/src/main/res/layout/profile_detail_view.xml
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-ua/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index fe523e1..6710342 100644 (file)
@@ -90,6 +90,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
        private RelativeLayout mTncNotice;
        private CheckBox mShowAdvanced;
        private ViewGroup mAdvancedSettings;
+       private EditText mRemoteId;
+       private TextInputLayoutHelper mRemoteIdWrap;
        private EditText mMTU;
        private TextInputLayoutHelper mMTUWrap;
        private EditText mPort;
@@ -131,6 +133,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                mShowAdvanced = (CheckBox)findViewById(R.id.show_advanced);
                mAdvancedSettings = (ViewGroup)findViewById(R.id.advanced_settings);
 
+               mRemoteId = (EditText)findViewById(R.id.remote_id);
+               mRemoteIdWrap = (TextInputLayoutHelper) findViewById(R.id.remote_id_wrap);
                mMTU = (EditText)findViewById(R.id.mtu);
                mMTUWrap = (TextInputLayoutHelper) findViewById(R.id.mtu_wrap);
                mPort = (EditText)findViewById(R.id.port);
@@ -151,10 +155,12 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                if (TextUtils.isEmpty(mGateway.getText()))
                                {
                                        mNameWrap.setHelperText(getString(R.string.profile_name_hint));
+                                       mRemoteIdWrap.setHelperText(getString(R.string.profile_remote_id_hint));
                                }
                                else
                                {
                                        mNameWrap.setHelperText(String.format(getString(R.string.profile_name_hint_gateway), mGateway.getText()));
+                                       mRemoteIdWrap.setHelperText(String.format(getString(R.string.profile_remote_id_hint_gateway), mGateway.getText()));
                                }
                        }
                });
@@ -384,7 +390,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                if (!show && mProfile != null)
                {
                        Integer st = mProfile.getSplitTunneling();
-                       show = mProfile.getMTU() != null || mProfile.getPort() != null || (st != null && st != 0);
+                       show = mProfile.getRemoteId() != null || mProfile.getMTU() != null ||
+                                  mProfile.getPort() != null || (st != null && st != 0);
                }
                mShowAdvanced.setVisibility(!show ? View.VISIBLE : View.GONE);
                mAdvancedSettings.setVisibility(show ? View.VISIBLE : View.GONE);
@@ -483,6 +490,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                }
                String certAlias = mCheckAuto.isChecked() ? null : mCertEntry.getAlias();
                mProfile.setCertificateAlias(certAlias);
+               String remote_id = mRemoteId.getText().toString().trim();
+               mProfile.setRemoteId(remote_id.isEmpty() ? null : remote_id);
                mProfile.setMTU(getInteger(mMTU));
                mProfile.setPort(getInteger(mPort));
                int st = 0;
@@ -511,6 +520,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                mVpnType = mProfile.getVpnType();
                                mUsername.setText(mProfile.getUsername());
                                mPassword.setText(mProfile.getPassword());
+                               mRemoteId.setText(mProfile.getRemoteId());
                                mMTU.setText(mProfile.getMTU() != null ? mProfile.getMTU().toString() : null);
                                mPort.setText(mProfile.getPort() != null ? mProfile.getPort().toString() : null);
                                mBlockIPv4.setChecked(mProfile.getSplitTunneling() != null ? (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4) != 0 : false);
index 4a1cc61..737c2f9 100644 (file)
                 android:text="@string/profile_advanced_label" />
 
             <org.strongswan.android.ui.widget.TextInputLayoutHelper
-                android:id="@+id/mtu_wrap"
+                android:id="@+id/remote_id_wrap"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="10dp"
+                app:helper_text="@string/profile_remote_id_hint" >
+
+                <android.support.design.widget.TextInputEditText
+                    android:id="@+id/remote_id"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:singleLine="true"
+                    android:inputType="textNoSuggestions"
+                    android:hint="@string/profile_remote_id_label" />
+
+            </org.strongswan.android.ui.widget.TextInputLayoutHelper>
+
+            <org.strongswan.android.ui.widget.TextInputLayoutHelper
+                android:id="@+id/mtu_wrap"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
                 app:helper_text="@string/profile_mtu_hint" >
 
                 <android.support.design.widget.TextInputEditText
index c2357eb..b5def06 100644 (file)
@@ -67,6 +67,9 @@
     <string name="profile_ca_select_certificate">Wählen Sie ein bestimmtes CA-Zertifikat</string>
     <string name="profile_advanced_label">Erweiterte Einstellungen</string>
     <string name="profile_show_advanced_label">Erweiterte Einstellungen anzeigen</string>
+    <string name="profile_remote_id_label">Server-Identität</string>
+    <string name="profile_remote_id_hint">Standardwert ist der konfigurierte Server. Eigene Werte werden explizit and den Server gesendet und während der Authentifizierung erzwungen</string>
+    <string name="profile_remote_id_hint_gateway">Standardwert ist \"%1$s\". Eigene Werte werden explizit and den Server gesendet und während der Authentifizierung erzwungen</string>
     <string name="profile_mtu_label">MTU des VPN Tunnel-Device</string>
     <string name="profile_mtu_hint">Falls der Standardwert in einem bestimmten Netzwerk nicht geeignet ist</string>
     <string name="profile_port_label">Server Port</string>
index c8c1595..cfd877f 100644 (file)
@@ -67,6 +67,9 @@
     <string name="profile_ca_select_certificate">Wybierz określony certyfikat CA</string>
     <string name="profile_advanced_label">Advanced settings</string>
     <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_remote_id_label">Server identity</string>
+    <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
index 0550fb2..cfd8129 100644 (file)
@@ -64,6 +64,9 @@
     <string name="profile_ca_select_certificate">Выбрать CA сертификат</string>
     <string name="profile_advanced_label">Advanced settings</string>
     <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_remote_id_label">Server identity</string>
+    <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
index a520748..8596989 100644 (file)
@@ -65,6 +65,9 @@
     <string name="profile_ca_select_certificate">Вибрати спеціальний сертифікат CA</string>
     <string name="profile_advanced_label">Advanced settings</string>
     <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_remote_id_label">Server identity</string>
+    <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
index 76886cd..d704da0 100644 (file)
@@ -67,6 +67,9 @@
     <string name="profile_ca_select_certificate">Select a specific CA certificate</string>
     <string name="profile_advanced_label">Advanced settings</string>
     <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_remote_id_label">Server identity</string>
+    <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>