Skip to content

Commit

Permalink
Merge branch 'main' of github.com:datastax/astra-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Nov 25, 2024
2 parents a7179f7 + 85479f0 commit 0c4ec4a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
<version.maven.plugin.assembly>3.7.1</version.maven.plugin.assembly>
<version.maven.plugin.compiler>3.12.1</version.maven.plugin.compiler>
<version.maven.plugin.coveralls>4.3.0</version.maven.plugin.coveralls>
<version.maven.plugin.dependency>3.6.1</version.maven.plugin.dependency>
<version.maven.plugin.dependency>3.8.0</version.maven.plugin.dependency>
<version.maven.plugin.enforcer>3.5.0</version.maven.plugin.enforcer>
<version.maven.plugin.exec>3.3.0</version.maven.plugin.exec>
<version.maven.plugin.jacoco>0.8.12</version.maven.plugin.jacoco>
<version.maven.plugin.javadoc>3.6.0</version.maven.plugin.javadoc>
<version.maven.plugin.jar>3.4.1</version.maven.plugin.jar>
<version.maven.plugin.jar>3.4.2</version.maven.plugin.jar>
<version.maven.plugin.license>2.4.0</version.maven.plugin.license>
<version.maven.plugin.native>0.10.2</version.maven.plugin.native>
<version.maven.plugin.release>3.0.1</version.maven.plugin.release>
<version.maven.plugin.release>3.1.1</version.maven.plugin.release>
<version.maven.plugin.resources>3.3.1</version.maven.plugin.resources>
<version.maven.plugin.shade>3.5.3</version.maven.plugin.shade>
<version.maven.plugin.surefire>3.2.5</version.maven.plugin.surefire>
<version.maven.plugin.shade>3.6.0</version.maven.plugin.shade>
<version.maven.plugin.surefire>3.5.1</version.maven.plugin.surefire>
</properties>

<dependencies>
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/com/dtsx/astra/cli/config/SetupCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,34 @@ public void execute() {
AstraEnvironment targetEnv = AstraCliUtils.parseEnvironment(env);
// As not token is provided we ask for it in the console
if (token == null || token.isBlank()) {
verbose = true;
AstraCliConsole.banner();
boolean validToken = false;
Console cons;
char[] tokenFromConsole;
while (!validToken) {
try {
if ((cons = System.console()) != null &&
(tokenFromConsole = cons.readPassword("[%s]", "$ Enter an Astra token:")) != null) {
token = String.valueOf(tokenFromConsole);

// Clear the password from memory immediately when done
Arrays.fill(tokenFromConsole, ' ');
} else {
try (Scanner scanner = new Scanner(System.in)) {
AstraCliConsole.println("$ Enter an Astra token:", CYAN_400);
token = scanner.nextLine();
}
}
createDefaultSection();
validToken = true;
} catch(InvalidTokenException ite) {
LoggerShell.error("Your token in invalid please retry " + ite.getMessage());
}
}
} else {
createDefaultSection();
}
createDefaultSection();
}

/**
Expand Down

0 comments on commit 0c4ec4a

Please sign in to comment.