Package org.hawaiiframework.logging.util
Class MaskedPasswordBuilder
java.lang.Object
org.hawaiiframework.logging.util.MaskedPasswordBuilder
A string visitor that builds the same string, but then with masked passwords.
- Since:
- 2.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the masked string.booleancurrentCharIs(Character character) Returnstrueif the current character ischaracter.booleancurrentCharIsOneOf(Character... choices) Returnstrueof the current character is one of thechoices.booleanReturnstrueif the current character is a whitespace.booleanFind the next password in the input.intReturns 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 Details
-
MaskedPasswordBuilder
The constructor.- Parameters:
stringToMask- The string to mask.pattern- The pattern to mask.
-
-
Method Details
-
hasNext
public boolean hasNext()Returnstrueif the string to mask has more characters.- Returns:
trueif the string to mask has more characters.
-
next
public void next()Advances the cursor to the next character. -
currentCharIsOneOf
Returnstrueof the current character is one of thechoices.- Parameters:
choices- Check whether the current char is one of the choices.- Returns:
trueof the current character is one of thechoices.
-
currentCharIs
Returnstrueif the current character ischaracter.- Parameters:
character- The character to check.- Returns:
trueif the current character ischaracter.
-
currentCharIsWhitespace
public boolean currentCharIsWhitespace()Returnstrueif the current character is a whitespace.- Returns:
trueif 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
Appends the password mask at theindex.- Parameters:
index- the index in the current buffer to append the masked password at.
-
getCurrentIndex
public int getCurrentIndex()Returns the current index.- Returns:
- the current index.
-
findNextPassword
public boolean findNextPassword()Find the next password in the input.- Returns:
trueif there is another password to be found in the string to mask.
-
build
Builds the masked string.- Returns:
- the masked string.
-