summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/vpn/VpnSettings.java
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2009-07-08 16:39:48 +0800
committerHung-ying Tyan <tyanh@google.com>2009-07-08 18:00:03 +0800
commit386668b79255917e2ddc17fd276f642be4d8089a (patch)
treefab747cad871c6a96fc86c5ff7d9bbca1bf78a6a /src/com/android/settings/vpn/VpnSettings.java
parent2368d0455ccae5e373fe79c66c1f6ce1ce0a3c72 (diff)
downloadpackages_apps_settings-386668b79255917e2ddc17fd276f642be4d8089a.zip
packages_apps_settings-386668b79255917e2ddc17fd276f642be4d8089a.tar.gz
packages_apps_settings-386668b79255917e2ddc17fd276f642be4d8089a.tar.bz2
Fix saving secrets to keystore from vpn settings.
Diffstat (limited to 'src/com/android/settings/vpn/VpnSettings.java')
-rw-r--r--src/com/android/settings/vpn/VpnSettings.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/com/android/settings/vpn/VpnSettings.java b/src/com/android/settings/vpn/VpnSettings.java
index e429f9f..d38b664 100644
--- a/src/com/android/settings/vpn/VpnSettings.java
+++ b/src/com/android/settings/vpn/VpnSettings.java
@@ -458,7 +458,9 @@ public class VpnSettings extends PreferenceActivity implements
private void addProfile(VpnProfile p) throws IOException {
setProfileId(p);
+ processSecrets(p);
saveProfileToStorage(p);
+
mVpnProfileList.add(p);
addPreferenceFor(p);
disableProfilePreferencesIfOneActive();
@@ -801,22 +803,27 @@ public class VpnSettings extends PreferenceActivity implements
case L2TP_IPSEC_PSK:
L2tpIpsecPskProfile pskProfile = (L2tpIpsecPskProfile) p;
String keyName = KEY_PREFIX_IPSEC_PSK + p.getId();
+ String keyNameForDaemon = NAMESPACE_VPN + "_" + keyName;
String presharedKey = pskProfile.getPresharedKey();
- if (!presharedKey.equals(keyName)) {
- ks.put(NAMESPACE_VPN, keyName, presharedKey);
- pskProfile.setPresharedKey(NAMESPACE_VPN + "_" + keyName);
+ if (!presharedKey.equals(keyNameForDaemon)) {
+ int ret = ks.put(NAMESPACE_VPN, keyName, presharedKey);
+ if (ret < 0) Log.e(TAG, "keystore write failed: key=" + keyName);
+ pskProfile.setPresharedKey(keyNameForDaemon);
}
// pass through
case L2TP:
L2tpProfile l2tpProfile = (L2tpProfile) p;
keyName = KEY_PREFIX_L2TP_SECRET + p.getId();
- String secret = l2tpProfile.getSecretString();
if (l2tpProfile.isSecretEnabled()) {
- if (!secret.equals(keyName)) {
- ks.put(NAMESPACE_VPN, keyName, secret);
- l2tpProfile.setSecretString(
- NAMESPACE_VPN + "_" + keyName);
+ keyNameForDaemon = NAMESPACE_VPN + "_" + keyName;
+ String secret = l2tpProfile.getSecretString();
+ if (!secret.equals(keyNameForDaemon)) {
+ int ret = ks.put(NAMESPACE_VPN, keyName, secret);
+ if (ret < 0) {
+ Log.e(TAG, "keystore write failed: key=" + keyName);
+ }
+ l2tpProfile.setSecretString(keyNameForDaemon);
}
} else {
ks.remove(NAMESPACE_VPN, keyName);