Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9556 - Better prompt for input on Password #9557

Merged
merged 7 commits into from Apr 5, 2023

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Mar 31, 2023

Fixes how we prompt user for inputs on the org.eclipse.jetty.util.security.Password command line tool.

This PR (initially) shows the following results ...

Usage text

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password 
Usage - java org.eclipse.jetty.util.security.Password [<user>] <password> --prompt
Argument options:
  org.eclipse.jetty.util.security.Password
     No arguments, will show this help
  org.eclipse.jetty.util.security.Password myusername
     username only, will prompt for entries
  org.eclipse.jetty.util.security.Password myusername ?
     username with question mark password, will prompt for entries
  org.eclipse.jetty.util.security.Password myusername secretpassword
     username with password, will produce obfuscation results
  org.eclipse.jetty.util.security.Password --prompt
     will prompt for entries

Specifically asking for input prompts

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password --prompt
Username: user⏎ 
Password: pass⏎ 
OBF:1y0s1v1p1v2p1y0y
MD5:1a1dC91c907325C69271DdF0C944Bc72
CRYPT:usGhvISzyaLuU

Username provided, no password, prompt user

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password ?
Username[?]: user⏎ 
Password: pass⏎ 
OBF:1y0s1v1p1v2p1y0y
MD5:1a1dC91c907325C69271DdF0C944Bc72
CRYPT:usGhvISzyaLuU

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password myusername
Username[myusername]: ⏎ 
Password: mypassword⏎ 
OBF:1uh41zly1x8g1vu11ym71ym71vv91x8e1zlk1ugm
MD5:34819d7bEeAbB9260a5c854bC85b3e44
CRYPT:..slnl7JMUqP.

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password myusername ?
Username[myusername]: ⏎
Password: mypassword⏎
OBF:1uh41zly1x8g1vu11ym71ym71vv91x8e1zlk1ugm
MD5:34819d7bEeAbB9260a5c854bC85b3e44
CRYPT:..slnl7JMUqP.

Prompt for input, no username provided, output doesn't contain CRYPT

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password --prompt
Username: ⏎
Password: mypass⏎
OBF:1xfd1zt11uha1ugg1zsp1xfp
MD5:A029D0Df84Eb5549C641E04a9eF389E5

Username and password provided as arguments, no prompt for input

$ java -cp target/jetty-util-10.0.15-SNAPSHOT.jar org.eclipse.jetty.util.security.Password user pass
OBF:1y0s1v1p1v2p1y0y
MD5:1a1dC91c907325C69271DdF0C944Bc72
CRYPT:usGhvISzyaLuU

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime added the Bug For general bugs on Jetty side label Mar 31, 2023
@joakime joakime added this to the 10.0.x milestone Mar 31, 2023
@joakime joakime requested a review from sbordet March 31, 2023 13:38
@joakime joakime self-assigned this Mar 31, 2023
@joakime joakime linked an issue Mar 31, 2023 that may be closed by this pull request
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime marked this pull request as ready for review March 31, 2023 15:19
@joakime joakime requested a review from gregw April 4, 2023 16:57
gregw
gregw previously approved these changes Apr 5, 2023
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A niggle about the language used in the help page, but other than that it is OK

System.err.printf(" %s myusername%n", Password.class.getName());
System.err.printf(" username only, will prompt for entries%n");
System.err.printf(" %s myusername ?%n", Password.class.getName());
System.err.printf(" username with question mark password, will prompt for entries%n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
System.err.printf(" username with question mark password, will prompt for entries%n");
System.err.printf(" username with question mark password, will prompt for arguments%n");

System.err.printf(" %s myusername secretpassword%n", Password.class.getName());
System.err.printf(" username with password, will produce obfuscation results%n");
System.err.printf(" %s --prompt%n", Password.class.getName());
System.err.printf(" will prompt for entries%n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
System.err.printf(" will prompt for entries%n");
System.err.printf(" will prompt for arguments%n");

Copy link
Contributor

@janbartel janbartel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the help text should be consistent. If the first line is [<user>] <password> then those terms should be used throughout.

System.err.printf("Argument options:%n");
System.err.printf(" %s%n", Password.class.getName());
System.err.printf(" No arguments, will show this help%n");
System.err.printf(" %s myusername%n", Password.class.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
System.err.printf(" %s myusername%n", Password.class.getName());
System.err.printf(" %s user%n", Password.class.getName());

System.err.printf(" No arguments, will show this help%n");
System.err.printf(" %s myusername%n", Password.class.getName());
System.err.printf(" username only, will prompt for entries%n");
System.err.printf(" %s myusername ?%n", Password.class.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
System.err.printf(" %s myusername ?%n", Password.class.getName());
System.err.printf(" %s user ?%n", Password.class.getName());

System.err.printf(" username only, will prompt for entries%n");
System.err.printf(" %s myusername ?%n", Password.class.getName());
System.err.printf(" username with question mark password, will prompt for entries%n");
System.err.printf(" %s myusername secretpassword%n", Password.class.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
System.err.printf(" %s myusername secretpassword%n", Password.class.getName());
System.err.printf(" %s user password%n", Password.class.getName());

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime merged commit 3e42cbf into jetty-10.0.x Apr 5, 2023
3 checks passed
@joakime joakime deleted the fix/10.0.x/password-prompts branch April 5, 2023 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Password Util does not ask for password
4 participants