Package org.jgrapes.util
Class Password
java.lang.Object
org.jgrapes.util.Password
Stores a password in such a way that it can be cleared.
Automatically clears the storage if an object of this type becomes weakly reachable.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the stored password.boolean
compareTo
(char[] value) Compare to a given char array.boolean
Compare to a given string.boolean
int
hashCode()
Passwords shouldn’t be used in sets or as keys.char[]
password()
Returns the stored password.toString()
Return “(hidden)
”.
-
Constructor Details
-
Password
Instantiates a new password representation.- Parameters:
password
- the password
-
-
Method Details
-
clear
Clear the stored password. -
password
Returns the stored password.This is returns a reference to the internally used array.
- Returns:
- the char[]
-
compareTo
Compare to a given string.- Parameters:
value
- the value to compare to- Returns:
- true, if successful
-
compareTo
Compare to a given char array.- Parameters:
value
- the value to compare to- Returns:
- true, if successful
-
equals
-
hashCode
Passwords shouldn’t be used in sets or as keys.To avoid disclosing any information about the password, this method always returns 0.
-
toString
Return “(hidden)
”.Should prevent the password from appearing unintentionally in outputs.
-