From b6b0bf1f6ad5da7b3ce8d3a380abec2b7a504b91 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 18 Nov 2016 13:03:16 +0100 Subject: [PATCH] SLI-129 Login/password authentication fails --- .../intellij/config/global/SonarQubeServer.java | 12 ++++++++++-- .../org/sonarlint/intellij/util/SonarLintUtils.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/sonarlint/intellij/config/global/SonarQubeServer.java b/src/main/java/org/sonarlint/intellij/config/global/SonarQubeServer.java index 62c8cc963a..28448ef999 100644 --- a/src/main/java/org/sonarlint/intellij/config/global/SonarQubeServer.java +++ b/src/main/java/org/sonarlint/intellij/config/global/SonarQubeServer.java @@ -170,12 +170,20 @@ public Builder setEnableProxy(boolean enableProxy) { } public Builder setToken(@Nullable String token) { - this.token = PasswordUtil.encodePassword(token); + if (token == null) { + this.token = null; + } else { + this.token = PasswordUtil.encodePassword(token); + } return this; } public Builder setPassword(@Nullable String password) { - this.password = PasswordUtil.encodePassword(password); + if (password == null) { + this.password = null; + } else { + this.password = PasswordUtil.encodePassword(password); + } return this; } diff --git a/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java b/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java index ea68ae53c8..4886ab163c 100644 --- a/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java +++ b/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java @@ -256,7 +256,7 @@ public static ServerConfiguration getServerConfiguration(SonarQubeServer server) .connectTimeoutMilliseconds(CONNECTION_TIMEOUT_MS) .readTimeoutMilliseconds(CONNECTION_TIMEOUT_MS) .url(server.getHostUrl()); - if (server.getToken() != null) { + if (StringUtil.isNotEmpty(server.getToken())) { serverConfigBuilder.token(server.getToken()); } else { serverConfigBuilder.credentials(server.getLogin(), server.getPassword());