}
// Init variable
- StringBuilder password = new StringBuilder(length);
+ final StringBuilder password = new StringBuilder(length);
// Start creating it
for (int i = 0; i < length; i++) {
// Take random part
- String alphabet = PASSWORD_ALPHABET_PARTS[RANDOM_NUMBER_GENERATOR.nextInt(PASSWORD_ALPHABET_PARTS.length)];
+ final String alphabet = PASSWORD_ALPHABET_PARTS[RANDOM_NUMBER_GENERATOR.nextInt(PASSWORD_ALPHABET_PARTS.length)];
// Generate random number
- int pos = RANDOM_NUMBER_GENERATOR.nextInt(alphabet.length());
+ final int pos = RANDOM_NUMBER_GENERATOR.nextInt(alphabet.length());
// Get char at this position and add it to the final password
password.append(String.valueOf(alphabet.charAt(pos)));
}
// Generate large number
- String number = Long.toString(RANDOM_NUMBER_GENERATOR.nextLong() * 10_000_000_000L);
+ final String number = Long.toString(RANDOM_NUMBER_GENERATOR.nextLong() * 10_000_000_000L);
// Generate salt
- String salt = Crypt.crypt(number);
+ final String salt = Crypt.crypt(number);
// First encrypt password
- String encryptedPassword = Crypt.crypt(userPassword, salt);
+ final String encryptedPassword = Crypt.crypt(userPassword, salt);
// Return it
return encryptedPassword;
* Generates random string by creating a random, encrypted password
* which gives nice entropy to start with.
*/
- StringBuilder key = new StringBuilder(encryptPassword(Users.generateRandomUserName()));
+ final StringBuilder key = new StringBuilder(encryptPassword(Users.generateRandomUserName()));
// Is user set?
if (user instanceof User) {
}
// Get contact instance
- Contact contact = user.getUserContact();
+ final Contact contact = user.getUserContact();
// Is contact set?
if (contact instanceof Contact) {
}
// Hash key
- String hash = DigestUtils.sha256Hex(key.toString());
+ final String hash = DigestUtils.sha256Hex(key.toString());
// Return it
return hash;
}
// First encrypt password
- String encryptedPassword = Crypt.crypt(clearTextPassword, updatedUser.getUserEncryptedPassword());
+ final String encryptedPassword = Crypt.crypt(clearTextPassword, updatedUser.getUserEncryptedPassword());
// Is it matching?
return encryptedPassword.equals(updatedUser.getUserEncryptedPassword());