mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Get password called with modality state; unnecessary get password from memory removed for hg auth
This commit is contained in:
@@ -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;
|
||||
@Nullable private ModalityState myState;
|
||||
|
||||
public GetPasswordRunnable(Project project, String proposedLogin, String uri, String path, boolean forceAuthorization) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user