From 058d224c56e8b88ea9fc8ef58624ea23af8dc4e0 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 17 May 2018 14:19:07 +0200 Subject: [PATCH] set isCheckExistingBeforeDialog to false by default for simplicity --- .../credentialStore/credentialPromt.kt | 13 ++++++---- .../ui/PasswordPromptComponent.java | 16 +------------ .../ui/PasswordSafePromptDialog.kt | 22 +++-------------- .../commands/GitHttpGuiAuthenticator.java | 24 ++++--------------- 4 files changed, 17 insertions(+), 58 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt b/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt index c0a6c9aeb46e..b56304427e62 100644 --- a/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt +++ b/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt @@ -31,7 +31,10 @@ fun askPassword(project: Project?, attributes: CredentialAttributes, resetPassword: Boolean = false, error: String? = null): String? { - return askCredentials(project, dialogTitle, passwordFieldLabel, attributes, resetPassword = resetPassword, error = error)?.credentials?.getPasswordAsString()?.nullize() + return askCredentials(project, dialogTitle, passwordFieldLabel, attributes, + isResetPassword = resetPassword, + error = error, + isCheckExistingBeforeDialog = true)?.credentials?.getPasswordAsString()?.nullize() } internal object RememberCheckBoxState { @@ -54,14 +57,14 @@ fun askCredentials(project: Project?, passwordFieldLabel: String, attributes: CredentialAttributes, isSaveOnOk: Boolean = true, - checkExistingBeforeDialog: Boolean = true, - resetPassword: Boolean = false, + isCheckExistingBeforeDialog: Boolean = false, + isResetPassword: Boolean = false, error: String? = null): CredentialRequestResult? { val store = PasswordSafe.getInstance() - if (resetPassword) { + if (isResetPassword) { store.set(attributes, null) } - else if (checkExistingBeforeDialog) { + else if (isCheckExistingBeforeDialog) { store.get(attributes)?.let { return CredentialRequestResult(it, false, true) } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java index 94145fbfa4f5..682dfd2fd647 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.passwordSafe.ui; import com.intellij.openapi.ui.Messages; diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt index 114113ddea44..cf8748ef4885 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.passwordSafe.ui import com.intellij.credentialStore.CredentialAttributes @@ -24,8 +10,7 @@ object PasswordSafePromptDialog { @Deprecated("Use {@link CredentialPromptDialog}", ReplaceWith("askPassword(project, title, message, CredentialAttributes(requestor, key), resetPassword, error)", "com.intellij.credentialStore.askPassword", "com.intellij.credentialStore.CredentialAttributes")) - fun askPassword(project: Project?, - title: String, + fun askPassword(project: Project?, title: String, message: String, requestor: Class<*>, key: String, @@ -33,5 +18,4 @@ object PasswordSafePromptDialog { error: String): String? { return askPassword(project, title, message, CredentialAttributes(requestor, key), resetPassword, error) } -} - +} \ No newline at end of file diff --git a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java index a538eefe4d35..e63f2f35c344 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java +++ b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package git4idea.commands; import com.intellij.credentialStore.CredentialAttributes; @@ -71,9 +57,9 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { @Nullable private String myPasswordKey; @Nullable private String myUnifiedUrl; @Nullable private String myLogin; - + private ThreeState myIsMemoryOnly = ThreeState.UNSURE; - + @Nullable private GitHttpAuthDataProvider myDataProvider; private boolean myWasCancelled; @@ -112,7 +98,7 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { myPasswordKey = getUnifiedUrl(url); CredentialRequestResult result = CredentialPromptDialog.askCredentials(myProject, myTitle, "Password for " + getDisplayableUrl(url), - credentialAttributes(myPasswordKey), false, false); + credentialAttributes(myPasswordKey), false); String password = result == null ? null : result.getCredentials().getPasswordAsString(); LOG.debug("askPassword. Password was asked and returned: " + (password == null ? "NULL" : password.isEmpty() ? "EMPTY" : "NOT EMPTY")); if (password == null) { @@ -274,7 +260,7 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { } return candidate; } - + @NotNull private List getProviders() { List providers = ContainerUtil.newArrayList();