Class PasswordServices
java.lang.Object
uk.ac.manchester.spinnaker.alloc.security.PasswordServices
Misc services related to password handling.
- Author:
- Donal Fellows
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal StringencodePassword(String password) Encode a password with bcrypt.final StringGenerate a random password.final booleanmatchPassword(String password, String encodedPassword) Check using bcrypt if a password matches its encoded form retrieved from the database.
- 
Constructor Details- 
PasswordServicespublic PasswordServices()
 
- 
- 
Method Details- 
generatePasswordGenerate a random password.- Returns:
- A password consisting of 16 random ASCII printable characters.
 
- 
encodePasswordEncode a password with bcrypt. This is a slow operation! Do not hold a database transaction open when calling this.- Parameters:
- password- The password to encode. May be- null.
- Returns:
- The encoded password. Will be nullif the input isnull.
 
- 
matchPasswordCheck using bcrypt if a password matches its encoded form retrieved from the database. This is a slow operation! Do not hold a database transaction open when calling this.- Parameters:
- password- The password to check. If- null, the encoded form must also be- nullfor a match to be true.
- encodedPassword- The encoded form from the database.
- Returns:
- True if the password matches, false otherwise.
 
 
-