java.lang.Object
org.refcodes.textual.SecretHintBuilder
- All Implemented Interfaces:
Text<SecretHintBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<SecretHintBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
Dangerous builder for printing secret text such as passwords or pass-phrases
or keys without unveiling too much of the secret information with still being
able to say if the correct secret is being displayed. Useful in log-files, do
not use any production log level! USE WITH CAUTION!
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.textual.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Convenience method for directly invokingText.toString(String...)
without leaving any state.static String
Convenience method for directly invokingText.toString(String...)
without leaving any state.static String[]
Convenience method for directly invokingText.toString(String...)
without leaving any state.String[]
getText()
Retrieves the text from the text property.void
Sets the text for the text property.toString()
TheString
being build by the builder upon the settings of the attributes.protected static String
This method provides a password hint by keeping the first and the last characters of the password and exchanging the rest by an asterisk "*".Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
TheString
s being build by the builder upon the settings of the attributes.String[]
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.With text.withText
(Collection<String> aText) With text.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.textual.TextAccessor
getText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextBuilder
withText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextMutator
setText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProperty
letText, letText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProvider
toString
-
Constructor Details
-
SecretHintBuilder
public SecretHintBuilder()
-
-
Method Details
-
setText
Sets the text for the text property.- Specified by:
setText
in interfaceTextAccessor.TextMutator
- Parameters:
aText
- The text to be stored by the text property.
-
toStrings
TheString
s being build by the builder upon the settings of the attributes.- Specified by:
toStrings
in interfaceTextAccessor.TextProvider
- Returns:
- The according resulting
String
array
-
toStrings
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
(do not change the text property) as this would not be thread safe!- Specified by:
toStrings
in interfaceText<SecretHintBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
asString
Convenience method for directly invokingText.toString(String...)
without leaving any state.- Parameters:
aText
- The text to be obscured.- Returns:
- The now obscured text.
-
asString
Convenience method for directly invokingText.toString(String...)
without leaving any state.- Parameters:
aText
- The text to be obscured.- Returns:
- The now obscured text.
-
asStrings
Convenience method for directly invokingText.toString(String...)
without leaving any state.- Parameters:
aText
- array The text to be obscured.- Returns:
- The now obscured text array.
-
toString
This method provides a password hint by keeping the first and the last characters of the password and exchanging the rest by an asterisk "*". In case the password length is smaller than 10 characters, then the complete password is replaced by asterisk "*" characters. ------------------------------------------------------------------------- CAUTION: This method must only be used when being in development environments and a password hint is required in debug log methods to see whether the correct password is being configured.- Parameters:
aSecret
- The secret to be printed- Returns:
- The printable secret
-
getText
Retrieves the text from the text property.- Specified by:
getText
in interfaceTextAccessor
- Returns:
- The text stored by the text property.
-
withText
With text. -
withText
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
TheString
being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).- Specified by:
toString
in interfaceTextAccessor.TextProvider
- Overrides:
toString
in classObject
- Returns:
- The according resulting
String
-
toString
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
(do not change the text property) as this would not be thread safe!
-