Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15993881
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +205,76 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed
web-console password")
+ public static class GeneratePasswordCommand extends
BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Option(name = { "--stdin" }, title = "read password from stdin,
instead of console",
+ description = "Before using stdin, read
http://stackoverflow.com/a/715681/1393883 for discussion of security!")
+ public boolean useStdin;
+
+ @Override
+ public Void call() throws Exception {
+ checkCanReadPassword();
+
+ System.out.print("Enter password: ");
+ System.out.flush();
+ String password = readPassword();
+ if (Strings.isBlank(password)) {
+ throw new UserFacingException("Password must not be blank;
aborting");
+ }
+
+ System.out.print("Re-enter password: ");
+ System.out.flush();
+ String password2 = readPassword();
+ if (!password.equals(password2)) {
+ throw new UserFacingException("Passwords did not match;
aborting");
+ }
+
+ String salt = Identifiers.makeRandomId(4);
+ String sha256password = PasswordHasher.sha256(salt, new
String(password));
+
+ System.out.println();
+ System.out.println("Please add the following to your
brooklyn.properies:");
--- End diff --
Typo: properies
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---