This is an automated email from the ASF dual-hosted git repository. jmark99 pushed a commit to branch elasticity in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push: new 064948ef2f Adjust shell to indicate how re-authentication occurs 064948ef2f is described below commit 064948ef2f9fd92419150516372e0ea2ca427766 Author: Mark Owens <jmar...@apache.org> AuthorDate: Mon Aug 28 12:51:49 2023 -0400 Adjust shell to indicate how re-authentication occurs This PR adds presents additional information to the shell when the re-authentication is automatically performed using the value from accumulo-client.properties. It additionally corrects a situation where an endless loop can be triggered when attempting re-authentication if the accumulo-client.properties file password is altered after initial setup. --- shell/src/main/java/org/apache/accumulo/shell/Shell.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java index 44197ad18e..0a9fac2f64 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java +++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java @@ -234,6 +234,8 @@ public class Shell extends ShellOptions implements KeywordExecutable { private long authTimeout; private long lastUserActivity = System.nanoTime(); private boolean logErrorsToConsole = false; + private boolean askAgain = false; + private boolean usedClientProps = false; static { // set the JLine output encoding to some reasonable default if it isn't already set @@ -251,7 +253,7 @@ public class Shell extends ShellOptions implements KeywordExecutable { } } - // no arg constructor should do minimal work since its used in Main ServiceLoader + // no arg constructor should do minimal work since it's used in Main ServiceLoader public Shell() {} public Shell(LineReader reader) { @@ -272,8 +274,10 @@ public class Shell extends ShellOptions implements KeywordExecutable { && clientProperties.containsKey(ClientProperty.AUTH_TOKEN.getKey()) && principal.equals(ClientProperty.AUTH_PRINCIPAL.getValue(clientProperties))) { token = ClientProperty.getAuthenticationToken(clientProperties); + usedClientProps = true; } - if (token == null) { + if (token == null || askAgain) { + usedClientProps = false; // Read password if the user explicitly asked for it, or didn't specify anything at all if (PasswordConverter.STDIN.equals(authenticationString) || authenticationString == null) { authenticationString = reader.readLine(passwordPrompt, '*'); @@ -584,7 +588,7 @@ public class Shell extends ShellOptions implements KeywordExecutable { writer.println(); String partialLine = uie.getPartialLine(); - if (partialLine == null || "".equals(uie.getPartialLine().trim())) { + if (partialLine == null || partialLine.trim().isEmpty()) { // No content, actually exit return exitCode; } @@ -726,6 +730,12 @@ public class Shell extends ShellOptions implements KeywordExecutable { if (authFailed) { writer.print("Invalid password. "); + askAgain = true; + } else { + if (usedClientProps) { + writer.println( + "User re-authenticated using value from accumulo-client.properties file"); + } } } while (authFailed); lastUserActivity = System.nanoTime();