From 6938102a874e00c7436947156eb698a68d86bf2b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 16 Apr 2020 00:50:59 +0200 Subject: [PATCH] Continued: - these variables can be final as the reference shall never be changed in one invocation run. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../juserlogincore/login/UserLoginUtils.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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()); -- 2.39.5