]> git.mxchange.org Git - juser-login-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 15 Apr 2020 22:50:59 +0000 (00:50 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 15 Apr 2020 22:50:59 +0000 (00:50 +0200)
- these variables can be final as the reference shall never be changed in
  one invocation run.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/juserlogincore/login/UserLoginUtils.java

index 179e9a378d420c0f31c98b53e82ea6306850f39f..0660a279b3a50c780f04df07dc356e20182fab54 100644 (file)
@@ -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());