Use utility method to generate canonical CredentialAttributes service name

This commit is contained in:
Kirill Likhodedov
2017-08-25 17:55:56 +03:00
parent 7c5f069008
commit 8ace50de34
3 changed files with 5 additions and 3 deletions
@@ -28,6 +28,8 @@ import java.util.concurrent.atomic.AtomicReference
const val SERVICE_NAME_PREFIX = "IntelliJ Platform"
fun generateServiceName(subsystem: String, key: String) = "$SERVICE_NAME_PREFIX $subsystem — $key"
/**
* requestor is deprecated. Never use it in new code.
*/
@@ -156,6 +156,6 @@ class HgCommandAuthenticator {
@NotNull
private static CredentialAttributes createCredentialAttributes(@NotNull String url) {
return new CredentialAttributes(CredentialAttributesKt.SERVICE_NAME_PREFIX + " HG — " + url, null);
return new CredentialAttributes(CredentialAttributesKt.generateServiceName("HG", url), null);
}
}
@@ -17,7 +17,7 @@ package org.jetbrains.settingsRepository
import com.intellij.credentialStore.CredentialAttributes
import com.intellij.credentialStore.Credentials
import com.intellij.credentialStore.SERVICE_NAME_PREFIX
import com.intellij.credentialStore.generateServiceName
import com.intellij.ide.passwordSafe.PasswordSafe
/**
@@ -34,7 +34,7 @@ class IcsCredentialsStore() {
private fun CredentialAttributes(host: String?, sshKeyFile: String?, accountName: String?): CredentialAttributes? {
if (sshKeyFile == null) {
return CredentialAttributes("$SERVICE_NAME_PREFIX Settings Repository — $host", accountName)
return CredentialAttributes(generateServiceName("Settings Repository", host.toString()), accountName)
}
else {
return CredentialAttributes("SSH", sshKeyFile)