edu.wpi.prc.util.password
Class PasswordReader
java.lang.Object
edu.wpi.prc.util.password.PasswordReader
public class PasswordReader
- extends java.lang.Object
This class reads a password from the command prompt, but does not display it in cleartext.
This is basically a hack that erases the characters after the user types them, but unfortunately
Java has no support for reading passwords. This class will be updated after JDK 6 is released,
which will have this functionality.
NOTE: This implementation inspired by http://java.sun.com/developer/technicalArticles/Security/pwordmask/.
- Author:
- James Baldassari
Method Summary |
java.lang.String |
getPassword()
|
java.lang.String |
readLine()
Reads the password from the console, replacing all characters with asterisks. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
br
private java.io.BufferedReader br
eraser
private PasswordEraserThread eraser
password
private java.lang.String password
PasswordReader
public PasswordReader()
- Default constructor.
readLine
public java.lang.String readLine()
throws java.io.IOException
- Reads the password from the console, replacing all characters with asterisks.
- Returns:
- Returns the password entered by the user.
- Throws:
java.io.IOException
getPassword
public java.lang.String getPassword()
- Returns:
- Returns the password entered by the user.