summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/Settings_Authentication.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/blinkt/openvpn/Settings_Authentication.java')
-rw-r--r--src/de/blinkt/openvpn/Settings_Authentication.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/Settings_Authentication.java b/src/de/blinkt/openvpn/Settings_Authentication.java
new file mode 100644
index 00000000..1f96c6ca
--- /dev/null
+++ b/src/de/blinkt/openvpn/Settings_Authentication.java
@@ -0,0 +1,66 @@
+package de.blinkt.openvpn;
+
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.EditTextPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceFragment;
+
+public class Settings_Authentication extends PreferenceFragment implements OnPreferenceChangeListener {
+ private CheckBoxPreference mExpectTLSCert;
+ private CheckBoxPreference mCheckRemoteCN;
+ private EditTextPreference mRemoteCN;
+ private VpnProfile mProfile;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.vpn_authentification);
+
+ mExpectTLSCert = (CheckBoxPreference) findPreference("remoteServerTLS");
+ mCheckRemoteCN = (CheckBoxPreference) findPreference("checkRemoteCN");
+ mRemoteCN = (EditTextPreference) findPreference("remotecn");
+ mRemoteCN.setOnPreferenceChangeListener(this);
+ String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID");
+ mProfile = ProfileManager.get(profileUUID);
+
+ loadSettings();
+
+ }
+
+ private void loadSettings() {
+
+ mExpectTLSCert.setChecked(mProfile.mExpectTLSCert);
+ mCheckRemoteCN.setChecked(mProfile.mCheckRemoteCN);
+ mRemoteCN.setText(mProfile.mRemoteCN);
+ onPreferenceChange(mRemoteCN, mProfile.mRemoteCN);
+
+ }
+
+ private void saveSettings() {
+ mProfile.mExpectTLSCert=mExpectTLSCert.isChecked();
+ mProfile.mCheckRemoteCN=mCheckRemoteCN.isChecked();
+ mProfile.mRemoteCN=mRemoteCN.getText();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ saveSettings();
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if(preference==mRemoteCN) {
+ if ("".equals(newValue))
+ preference.setSummary(mProfile.mServerName);
+ else
+ preference.setSummary((String)newValue);
+ }
+ saveSettings();
+ return true;
+ }
+} \ No newline at end of file