Stuff from the common floobits workspace

Author:    AuthMe-Team <AuthMeTeam@123NoEmail.com>
This commit is contained in:
AuthMe-Team
2015-11-23 20:20:42 +01:00
committed by Gabriele C
parent 69a09aec17
commit 9ec2d6d059
169 changed files with 5161 additions and 4806 deletions
@@ -1,33 +1,32 @@
package fr.xephi.authme.security;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.HashMap;
import org.bukkit.Bukkit;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.events.PasswordEncryptionEvent;
import fr.xephi.authme.security.crypts.BCRYPT;
import fr.xephi.authme.security.crypts.EncryptionMethod;
import fr.xephi.authme.settings.Settings;
import org.bukkit.Bukkit;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.HashMap;
/**
*/
public class PasswordSecurity {
private static SecureRandom rnd = new SecureRandom();
public static HashMap<String, String> userSalt = new HashMap<>();
private static SecureRandom rnd = new SecureRandom();
/**
* Method createSalt.
*
* @param length int
* @return String * @throws NoSuchAlgorithmException */
* @return String * @throws NoSuchAlgorithmException
*/
public static String createSalt(int length)
throws NoSuchAlgorithmException {
byte[] msg = new byte[40];
@@ -40,12 +39,12 @@ public class PasswordSecurity {
/**
* Method getHash.
* @param alg HashAlgorithm
* @param password String
*
* @param alg HashAlgorithm
* @param password String
* @param playerName String
* @return String * @throws NoSuchAlgorithmException */
* @return String * @throws NoSuchAlgorithmException
*/
public static String getHash(HashAlgorithm alg, String password,
String playerName) throws NoSuchAlgorithmException {
EncryptionMethod method;
@@ -143,12 +142,12 @@ public class PasswordSecurity {
/**
* Method comparePasswordWithHash.
* @param password String
* @param hash String
*
* @param password String
* @param hash String
* @param playerName String
* @return boolean * @throws NoSuchAlgorithmException */
* @return boolean * @throws NoSuchAlgorithmException
*/
public static boolean comparePasswordWithHash(String password, String hash,
String playerName) throws NoSuchAlgorithmException {
HashAlgorithm algo = Settings.getPasswordHash;
@@ -181,12 +180,12 @@ public class PasswordSecurity {
/**
* Method compareWithAllEncryptionMethod.
* @param password String
* @param hash String
*
* @param password String
* @param hash String
* @param playerName String
* @return boolean * @throws NoSuchAlgorithmException */
* @return boolean * @throws NoSuchAlgorithmException
*/
private static boolean compareWithAllEncryptionMethod(String password,
String hash, String playerName) throws NoSuchAlgorithmException {
for (HashAlgorithm algo : HashAlgorithm.values()) {