public static class PasswordMasker.StreamMasker
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
private boolean |
doMasking |
private java.io.PrintStream |
out |
private java.lang.String |
promptOverwrite |
private static java.lang.String |
TEN_BLANKS |
Constructor and Description |
---|
PasswordMasker.StreamMasker(java.io.PrintStream out,
java.lang.String prompt)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
repeatChars(char c,
int length)
Returns a String of the specified length which consists of entirely of the char c.
|
void |
run()
Repeatedly overwrites the current line of out with prompt followed by blanks.
|
void |
stop()
Signals any thread executing run to stop masking and exit run.
|
private static final java.lang.String TEN_BLANKS
private final java.io.PrintStream out
private final java.lang.String promptOverwrite
private volatile boolean doMasking
public PasswordMasker.StreamMasker(java.io.PrintStream out, java.lang.String prompt) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if out == null; prompt == null; prompt contains the char '\r' or '\n'public void run() throws java.lang.RuntimeException
To help ensure that masking occurs when system is in heavy use, the calling thread will have its priority boosted to the max for the duration of the call (with its original priority restored upon return). Interrupting the calling thread will eventually result in an exit from this method, and the interrupted status of the calling thread will be set to true.
run
in interface java.lang.Runnable
java.lang.RuntimeException
- if an error in the masking process is detectedpublic void stop()
public static final java.lang.String repeatChars(char c, int length) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if length < 0