From: Roland Häder Date: Wed, 15 Apr 2020 22:50:59 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6938102a874e00c7436947156eb698a68d86bf2b;p=juser-login-core.git Continued: - these variables can be final as the reference shall never be changed in one invocation run. Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/juserlogincore/login/UserLoginUtils.java b/src/org/mxchange/juserlogincore/login/UserLoginUtils.java index 179e9a3..0660a27 100644 --- a/src/org/mxchange/juserlogincore/login/UserLoginUtils.java +++ b/src/org/mxchange/juserlogincore/login/UserLoginUtils.java @@ -195,15 +195,15 @@ public class UserLoginUtils implements Serializable { } // 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))); @@ -234,13 +234,13 @@ public class UserLoginUtils implements Serializable { } // 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; @@ -259,7 +259,7 @@ public class UserLoginUtils implements Serializable { * 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) { @@ -279,7 +279,7 @@ public class UserLoginUtils implements Serializable { } // Get contact instance - Contact contact = user.getUserContact(); + final Contact contact = user.getUserContact(); // Is contact set? if (contact instanceof Contact) { @@ -295,7 +295,7 @@ public class UserLoginUtils implements Serializable { } // Hash key - String hash = DigestUtils.sha256Hex(key.toString()); + final String hash = DigestUtils.sha256Hex(key.toString()); // Return it return hash; @@ -355,7 +355,7 @@ public class UserLoginUtils implements Serializable { } // 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());