Package org.hawaiiframework.logging.util
Class MaskedPasswordBuilder
- java.lang.Object
-
- org.hawaiiframework.logging.util.MaskedPasswordBuilder
-
public class MaskedPasswordBuilder extends Object
A string visitor that builds the same string, but then with masked passwords.- Since:
- 2.0.0
- Author:
- Rutger Lubbers
-
-
Constructor Summary
Constructors Constructor Description MaskedPasswordBuilder(String stringToMask)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringbuild()Builds the masked string.booleancurrentCharIs(Character character)Returnstrueif the current character ischaracter.booleancurrentCharIsOneOf(Character... choices)Returnstrueof the current character is one of thechoices.booleancurrentCharIsWhitespace()Returnstrueif the current character is a whitespace.booleanfindNextPassword()Returnstrueif there is another password to be found in the string to mask.intgetCurrentIndex()Returns the current index.booleanhasNext()Returnstrueif the string to mask has more characters.voidmark()Saves the current index, to be used byreset().voidmaskPasswordAt(Integer index)Appends the password mask at theindex.voidnext()Advances the cursor to the next character.voidreset()Resets the current character (or index) to the one set bymark().
-
-
-
Constructor Detail
-
MaskedPasswordBuilder
public MaskedPasswordBuilder(String stringToMask)
The constructor.
-
-
Method Detail
-
hasNext
public boolean hasNext()
Returnstrueif the string to mask has more characters.
-
next
public void next()
Advances the cursor to the next character.
-
currentCharIsOneOf
public boolean currentCharIsOneOf(Character... choices)
Returnstrueof the current character is one of thechoices.
-
currentCharIs
public boolean currentCharIs(Character character)
Returnstrueif the current character ischaracter.
-
currentCharIsWhitespace
public boolean currentCharIsWhitespace()
Returnstrueif the current character is a whitespace.
-
mark
public void mark()
Saves the current index, to be used byreset().
-
reset
public void reset()
Resets the current character (or index) to the one set bymark().
-
maskPasswordAt
public void maskPasswordAt(Integer index)
Appends the password mask at theindex.
-
getCurrentIndex
public int getCurrentIndex()
Returns the current index.
-
findNextPassword
public boolean findNextPassword()
Returnstrueif there is another password to be found in the string to mask.
-
build
public String build()
Builds the masked string.
-
-