mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reduce explicit usage of OneTimeString
This commit is contained in:
@@ -110,7 +110,7 @@ internal class KeePassCredentialStore(keyToValue: Map<CredentialAttributes, Cred
|
||||
val userName = attributes.userName
|
||||
val entry = db.rootGroup.getGroup(GROUP_NAME)?.getEntry(attributes.serviceName, attributes.userName)
|
||||
if (entry != null) {
|
||||
return Credentials(attributes.userName ?: entry.userName, entry.password?.let(::OneTimeString))
|
||||
return Credentials(attributes.userName ?: entry.userName, entry.password)
|
||||
}
|
||||
|
||||
if (requestor == null || userName == null) {
|
||||
@@ -120,7 +120,7 @@ internal class KeePassCredentialStore(keyToValue: Map<CredentialAttributes, Cred
|
||||
// try old key - as hash
|
||||
val oldAttributes = toOldKey(requestor, userName)
|
||||
db.rootGroup.getGroup(GROUP_NAME)?.removeEntry(oldAttributes.serviceName, oldAttributes.userName)?.let {
|
||||
fun createCredentials() = Credentials(userName, it.password?.let(::OneTimeString))
|
||||
fun createCredentials() = Credentials(userName, it.password)
|
||||
set(CredentialAttributes(requestor, userName), createCredentials())
|
||||
return createCredentials()
|
||||
}
|
||||
@@ -146,7 +146,7 @@ internal class KeePassCredentialStore(keyToValue: Map<CredentialAttributes, Cred
|
||||
for (entry in group.entries) {
|
||||
val title = entry.title
|
||||
if (title != null) {
|
||||
store.set(CredentialAttributes(title, entry.userName), Credentials(entry.userName, entry.password?.let(::OneTimeString)))
|
||||
store.set(CredentialAttributes(title, entry.userName), Credentials(entry.userName, entry.password))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ fun splitData(data: String?): Credentials? {
|
||||
}
|
||||
|
||||
val list = parseString(data!!, '@')
|
||||
return Credentials(list.getOrNull(0), list.getOrNull(1)?.let(::OneTimeString))
|
||||
return Credentials(list.getOrNull(0), list.getOrNull(1))
|
||||
}
|
||||
|
||||
private const val ESCAPING_CHAR = '\\'
|
||||
|
||||
@@ -43,7 +43,7 @@ class FileCredentialStoreTest {
|
||||
val random = Random()
|
||||
for (i in 0..9) {
|
||||
val accountName = BigInteger(8 * 16, random).toString()
|
||||
provider.set(CredentialAttributes(TEST_SERVICE_NAME, accountName), Credentials(accountName, OneTimeString(BigInteger(8 * 16, random).toString())))
|
||||
provider.set(CredentialAttributes(TEST_SERVICE_NAME, accountName), Credentials(accountName, BigInteger(8 * 16, random).toString()))
|
||||
}
|
||||
|
||||
provider.save()
|
||||
|
||||
@@ -89,7 +89,7 @@ internal class NativeKeychainTest {
|
||||
val attributes = CredentialAttributes("Test IJ — ${randomString()}", userName)
|
||||
try {
|
||||
store.set(attributes, Credentials(userName))
|
||||
assertThat(store.get(attributes)).isEqualTo(Credentials(userName, if (store is KeyChainCredentialStore) OneTimeString("") else null))
|
||||
assertThat(store.get(attributes)).isEqualTo(Credentials(userName, if (store is KeyChainCredentialStore) "" else null))
|
||||
}
|
||||
finally {
|
||||
store.set(attributes, null)
|
||||
|
||||
@@ -31,6 +31,6 @@ public interface CredentialStore {
|
||||
void set(@NotNull CredentialAttributes attributes, @Nullable Credentials credentials);
|
||||
|
||||
default void setPassword(@NotNull CredentialAttributes attributes, @Nullable String password) {
|
||||
set(attributes, password == null ? null : new Credentials(attributes.getUserName(), new OneTimeString(password)));
|
||||
set(attributes, password == null ? null : new Credentials(attributes.getUserName(), password));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.ide.passwordSafe;
|
||||
|
||||
import com.intellij.credentialStore.CredentialStore;
|
||||
import com.intellij.credentialStore.Credentials;
|
||||
import com.intellij.credentialStore.OneTimeString;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -33,7 +32,7 @@ public interface PasswordStorage extends CredentialStore {
|
||||
|
||||
@Deprecated
|
||||
default void setPassword(@NotNull Class<?> requestor, @NotNull String accountName, @Nullable String value) {
|
||||
set(CredentialAttributes(requestor, accountName), value == null ? null : new Credentials(accountName, new OneTimeString(value)));
|
||||
set(CredentialAttributes(requestor, accountName), value == null ? null : new Credentials(accountName, value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-7
@@ -163,13 +163,6 @@ public class EncryptionUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt text
|
||||
*
|
||||
* @param password the secret key to use
|
||||
* @param text the text to encrypt
|
||||
* @return encrypted text
|
||||
*/
|
||||
public static byte[] encryptText(byte[] password, @NotNull OneTimeString value) {
|
||||
byte[] data = value.toByteArray(false);
|
||||
return encryptData(password, data.length, data);
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package com.intellij.ide.passwordSafe.ui;
|
||||
|
||||
import com.intellij.credentialStore.Credentials;
|
||||
import com.intellij.credentialStore.OneTimeString;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -147,7 +146,7 @@ public class PasswordSafePromptDialog extends DialogWrapper {
|
||||
|
||||
d.setErrorText(error);
|
||||
if (d.showAndGet()) {
|
||||
Credentials credentials = new Credentials(component.getUserName(), new OneTimeString(component.getPassword()));
|
||||
Credentials credentials = new Credentials(component.getUserName(), component.getPassword());
|
||||
ref.set(credentials);
|
||||
ps.set(CredentialAttributes(requestor, accountName), credentials, !component.isRememberSelected());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package git4idea.commands;
|
||||
|
||||
import com.intellij.credentialStore.Credentials;
|
||||
import com.intellij.credentialStore.OneTimeString;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.ide.passwordSafe.ui.PasswordSafePromptDialog;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -172,7 +171,7 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator {
|
||||
|
||||
// save password
|
||||
if (myPasswordKey != null && myPassword != null) {
|
||||
Credentials credentials = new Credentials(myPasswordKey, new OneTimeString(myPassword));
|
||||
Credentials credentials = new Credentials(myPasswordKey, myPassword);
|
||||
PasswordSafe.getInstance().set(CredentialAttributes(PASS_REQUESTER, credentials.getUserName()), credentials, !mySaveOnDisk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class HgCommandAuthenticator {
|
||||
|
||||
// don't show dialog if we don't have to (both fields are known) except force authorization required
|
||||
if (!myForceAuthorization && !StringUtil.isEmptyOrSpaces(password) && !StringUtil.isEmptyOrSpaces(login)) {
|
||||
myCredentials = new Credentials(login, new OneTimeString(password));
|
||||
myCredentials = new Credentials(login, password);
|
||||
ok = true;
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class HgCommandAuthenticator {
|
||||
login, password, true);
|
||||
if (dialog.showAndGet()) {
|
||||
ok = true;
|
||||
Credentials credentials = new Credentials(dialog.getUsername(), new OneTimeString(dialog.getPassword()));
|
||||
Credentials credentials = new Credentials(dialog.getUsername(), dialog.getPassword());
|
||||
myCredentials = credentials;
|
||||
PasswordSafe.getInstance().set(CredentialAttributes(HgCommandAuthenticator.class, keyForUrlAndLogin(url, credentials.getUserName())), credentials, !dialog.isRememberPassword());
|
||||
hgGlobalSettings.addRememberedUrl(url, credentials.getUserName());
|
||||
@@ -141,8 +141,7 @@ class HgCommandAuthenticator {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
OneTimeString password = myCredentials == null ? null : myCredentials.getPassword();
|
||||
return password == null ? null : password.toString(false);
|
||||
return myCredentials == null ? null : myCredentials.getPasswordAsString(false);
|
||||
}
|
||||
|
||||
public boolean isOk() {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.settingsRepository.git
|
||||
import com.google.common.cache.CacheBuilder
|
||||
import com.google.common.cache.CacheLoader
|
||||
import com.intellij.credentialStore.Credentials
|
||||
import com.intellij.credentialStore.OneTimeString
|
||||
import com.intellij.credentialStore.isFulfilled
|
||||
import com.intellij.credentialStore.macOs.isMacOsCredentialStoreSupported
|
||||
import com.intellij.openapi.ui.MessageDialogBuilder
|
||||
@@ -96,7 +95,7 @@ class JGitCredentialsProvider(private val credentialsStore: Lazy<IcsCredentialsS
|
||||
val userFromUri: String? = if (sshKeyFile == null) uri.user.nullize() else null
|
||||
val passwordFromUri: String? = uri.pass.nullize()
|
||||
if (userFromUri != null && passwordFromUri != null) {
|
||||
credentials = Credentials(userFromUri, OneTimeString(passwordFromUri))
|
||||
credentials = Credentials(userFromUri, passwordFromUri)
|
||||
}
|
||||
else {
|
||||
catchAndLog {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.settingsRepository.git
|
||||
|
||||
import com.intellij.credentialStore.Credentials
|
||||
import com.intellij.credentialStore.OneTimeString
|
||||
import com.intellij.execution.configurations.GeneralCommandLine
|
||||
import com.intellij.execution.process.ProcessNotCreatedException
|
||||
import org.eclipse.jgit.lib.Repository
|
||||
@@ -71,5 +70,5 @@ internal fun getCredentialsUsingGit(uri: URIish, repository: Repository): Creden
|
||||
if (errorText.isNotEmpty()) {
|
||||
LOG.warn(errorText)
|
||||
}
|
||||
return if (username == null && password == null) null else Credentials(username, password?.let(::OneTimeString))
|
||||
return if (username == null && password == null) null else Credentials(username, password)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user