diff options
Diffstat (limited to 'plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java')
-rw-r--r-- | plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java index 14f6c981777b..1d41cdc688f9 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java @@ -35,7 +35,7 @@ import org.zmlx.hg4idea.HgVcsMessages; class HgCommandAuthenticator { private static final Logger LOG = Logger.getInstance(HgCommandAuthenticator.class.getName()); - + private GetPasswordRunnable myGetPassword; private final Project myProject; private boolean myForceAuthorization; @@ -71,7 +71,7 @@ class HgCommandAuthenticator { } public boolean promptForAuthentication(Project project, String proposedLogin, String uri, String path, @Nullable ModalityState state) { - GetPasswordRunnable runnable = new GetPasswordRunnable(project, proposedLogin, uri, path, myForceAuthorization); + GetPasswordRunnable runnable = new GetPasswordRunnable(project, proposedLogin, uri, path, myForceAuthorization, state); ApplicationManager.getApplication().invokeAndWait(runnable, state == null ? ModalityState.defaultModalityState() : state); myGetPassword = runnable; return runnable.isOk(); @@ -96,14 +96,21 @@ class HgCommandAuthenticator { @Nullable private String myURL; private boolean myRememberPassword; private boolean myForceAuthorization; - - public GetPasswordRunnable(Project project, String proposedLogin, String uri, String path, boolean forceAuthorization) { + @Nullable private ModalityState myState; + + public GetPasswordRunnable(Project project, + String proposedLogin, + String uri, + String path, + boolean forceAuthorization, + @Nullable ModalityState state) { this.myProject = project; this.myProposedLogin = proposedLogin; this.myURL = uri + path; this.myForceAuthorization = forceAuthorization; + myState = state; } - + public void run() { // find if we've already been here @@ -128,11 +135,9 @@ class HgCommandAuthenticator { final String key = keyForUrlAndLogin(myURL, login); try { final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance(); - password = passwordSafe.getMemoryProvider().getPassword(myProject, HgCommandAuthenticator.class, key); - if (password == null) { - password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key); - } - } catch (PasswordSafeException e) { + password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key, myState); + } + catch (PasswordSafeException e) { LOG.info("Couldn't get password for key [" + key + "]", e); } } |