From 3a9e5394b0a35eaaf93ab6e2b5383b3984e81d8a Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Fri, 30 May 2014 14:15:33 +0400 Subject: [PATCH] IDEA-124347 Master Password prompt strategy changed for mercurial authentication * store and get password according to settings-> passwords strategy; * if 'remember password' option is selected in hg authorization dialog, IDE remembers password in memory, too --- .../execution/HgCommandAuthenticator.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java index 399fa14d078c..9a94824e2dcf 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java @@ -15,8 +15,6 @@ package org.zmlx.hg4idea.execution; import com.intellij.ide.passwordSafe.PasswordSafe; import com.intellij.ide.passwordSafe.PasswordSafeException; import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl; -import com.intellij.ide.passwordSafe.impl.PasswordSafeProvider; -import com.intellij.ide.passwordSafe.impl.providers.masterKey.MasterKeyPasswordSafe; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; @@ -55,10 +53,13 @@ class HgCommandAuthenticator { final String url = VirtualFileManager.extractPath(myRunnable.getURL()); final String key = keyForUrlAndLogin(url, myRunnable.getUserName()); - final PasswordSafeProvider provider = - myRunnable.isRememberPassword() ? passwordSafe.getMasterKeyProvider() : passwordSafe.getMemoryProvider(); try { - provider.storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword()); + if (myRunnable.isRememberPassword()) { + //save password to memory, despite of settings-> passwords + //todo should be reworked + passwordSafe.getMemoryProvider().storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword()); + } + passwordSafe.storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword()); final HgVcs vcs = HgVcs.getInstance(myProject); if (vcs != null) { vcs.getGlobalSettings().addRememberedUrl(url, myRunnable.getUserName()); @@ -129,13 +130,7 @@ class HgCommandAuthenticator { final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance(); password = passwordSafe.getMemoryProvider().getPassword(myProject, HgCommandAuthenticator.class, key); if (password == null) { - final MasterKeyPasswordSafe masterKeyProvider = passwordSafe.getMasterKeyProvider(); - if (!masterKeyProvider.isEmpty()) { - // workaround for: don't ask for master password, if the requested password is not there. - // this should be fixed in PasswordSafe: don't ask master password to look for keys - // until then we assume that is PasswordSafe was used (there is anything there), then it makes sense to look there. - password = masterKeyProvider.getPassword(myProject, HgCommandAuthenticator.class, key); - } + password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key); } } catch (PasswordSafeException e) { LOG.info("Couldn't get password for key [" + key + "]", e);