mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 15:17:56 +01:00
Merge master into commands-refactor
This commit is contained in:
commit
3cc35baa5e
57
pom.xml
57
pom.xml
@ -447,10 +447,15 @@
|
|||||||
<!-- bPermissions plugin -->
|
<!-- bPermissions plugin -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.bananaco</groupId>
|
<groupId>de.bananaco</groupId>
|
||||||
<artifactId>bpermissions</artifactId>
|
<artifactId>bPermissions</artifactId>
|
||||||
<version>1.12-DEV</version>
|
<version>2.12-DEV</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${basedir}/lib/bPermissions-2.12-DEV.jar</systemPath>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- zPermissions plugin -->
|
<!-- zPermissions plugin -->
|
||||||
@ -458,17 +463,33 @@
|
|||||||
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||||
<artifactId>zPermissions</artifactId>
|
<artifactId>zPermissions</artifactId>
|
||||||
<version>1.3-SNAPSHOT</version>
|
<version>1.3-SNAPSHOT</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${basedir}/lib/zPermissions-1.3beta1.jar</systemPath>
|
<exclusions>
|
||||||
</dependency>
|
<exclusion>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
<!-- Permissions plugin (obsolete) -->
|
<artifactId>bukkit</artifactId>
|
||||||
<dependency>
|
</exclusion>
|
||||||
<groupId>com.nijiko</groupId>
|
<exclusion>
|
||||||
<artifactId>permissions</artifactId>
|
<groupId>com.sk89q</groupId>
|
||||||
<version>3.1.6</version>
|
<artifactId>worldguard</artifactId>
|
||||||
<scope>system</scope>
|
</exclusion>
|
||||||
<systemPath>${basedir}/lib/Permission-3.1.6.jar</systemPath>
|
<exclusion>
|
||||||
|
<groupId>com.sk89q</groupId>
|
||||||
|
<artifactId>worldedit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>uuidprovider</artifactId>
|
||||||
|
<groupId>net.kaikk.mc</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>ToHPluginUtils</artifactId>
|
||||||
|
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Vault, http://dev.bukkit.org/bukkit-plugins/vault/ -->
|
<!-- Vault, http://dev.bukkit.org/bukkit-plugins/vault/ -->
|
||||||
@ -700,6 +721,12 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<version>2.0.5-beta</version>
|
<version>2.0.5-beta</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>hamcrest-core</artifactId>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- String comparison library. Used for dynamic help system. -->
|
<!-- String comparison library. Used for dynamic help system. -->
|
||||||
|
@ -11,7 +11,6 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
@ -6,7 +6,6 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.CacheDataSource;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package fr.xephi.authme.permission;
|
package fr.xephi.authme.permission;
|
||||||
|
|
||||||
import com.nijiko.permissions.Group;
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
|
||||||
import de.bananaco.bpermissions.api.ApiLayer;
|
import de.bananaco.bpermissions.api.ApiLayer;
|
||||||
import de.bananaco.bpermissions.api.CalculableType;
|
import de.bananaco.bpermissions.api.CalculableType;
|
||||||
import fr.xephi.authme.command.CommandDescription;
|
import fr.xephi.authme.command.CommandDescription;
|
||||||
@ -67,10 +64,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
* Essentials group manager instance.
|
* Essentials group manager instance.
|
||||||
*/
|
*/
|
||||||
private GroupManager groupManagerPerms;
|
private GroupManager groupManagerPerms;
|
||||||
/**
|
|
||||||
* Permissions manager instance for the legacy permissions system.
|
|
||||||
*/
|
|
||||||
private PermissionHandler defaultPerms;
|
|
||||||
/**
|
/**
|
||||||
* zPermissions service instance.
|
* zPermissions service instance.
|
||||||
*/
|
*/
|
||||||
@ -213,20 +206,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
System.out.println("[" + plugin.getName() + "] Error while hooking into Vault Permissions!");
|
System.out.println("[" + plugin.getName() + "] Error while hooking into Vault Permissions!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permissions, check if it's available
|
|
||||||
try {
|
|
||||||
Plugin testPerms = pm.getPlugin("Permissions");
|
|
||||||
if (testPerms != null) {
|
|
||||||
permsType = PermissionsSystemType.PERMISSIONS;
|
|
||||||
this.defaultPerms = ((Permissions) testPerms).getHandler();
|
|
||||||
System.out.println("[" + plugin.getName() + "] Hooked into Permissions!");
|
|
||||||
return PermissionsSystemType.PERMISSIONS;
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// An error occurred, show a warning message
|
|
||||||
System.out.println("[" + plugin.getName() + "] Error while hooking into Permissions!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// No recognized permissions system found
|
// No recognized permissions system found
|
||||||
permsType = PermissionsSystemType.NONE;
|
permsType = PermissionsSystemType.NONE;
|
||||||
System.out.println("[" + plugin.getName() + "] No supported permissions system found! Permissions disabled!");
|
System.out.println("[" + plugin.getName() + "] No supported permissions system found! Permissions disabled!");
|
||||||
@ -405,10 +384,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
// Vault
|
// Vault
|
||||||
return vaultPerms.has(player, permsNode);
|
return vaultPerms.has(player, permsNode);
|
||||||
|
|
||||||
case PERMISSIONS:
|
|
||||||
// Permissions
|
|
||||||
return this.defaultPerms.has(player, permsNode);
|
|
||||||
|
|
||||||
case NONE:
|
case NONE:
|
||||||
// Not hooked into any permissions system, return default
|
// Not hooked into any permissions system, return default
|
||||||
return def;
|
return def;
|
||||||
@ -500,18 +475,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
// Vault
|
// Vault
|
||||||
return Arrays.asList(vaultPerms.getPlayerGroups(player));
|
return Arrays.asList(vaultPerms.getPlayerGroups(player));
|
||||||
|
|
||||||
case PERMISSIONS:
|
|
||||||
// Permissions
|
|
||||||
// Create a list to put the groups in
|
|
||||||
List<String> groups = new ArrayList<>();
|
|
||||||
|
|
||||||
// Get the groups and add each to the list
|
|
||||||
for (Group group : this.defaultPerms.getGroups(player.getName()))
|
|
||||||
groups.add(group.getName());
|
|
||||||
|
|
||||||
// Return the groups
|
|
||||||
return groups;
|
|
||||||
|
|
||||||
case NONE:
|
case NONE:
|
||||||
// Not hooked into any permissions system, return an empty list
|
// Not hooked into any permissions system, return an empty list
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -619,10 +582,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
// Vault
|
// Vault
|
||||||
return vaultPerms.playerInGroup(player, groupName);
|
return vaultPerms.playerInGroup(player, groupName);
|
||||||
|
|
||||||
case PERMISSIONS:
|
|
||||||
// Permissions
|
|
||||||
return this.defaultPerms.inGroup(player.getWorld().getName(), player.getName(), groupName);
|
|
||||||
|
|
||||||
case NONE:
|
case NONE:
|
||||||
// Not hooked into any permissions system, return an empty list
|
// Not hooked into any permissions system, return an empty list
|
||||||
return false;
|
return false;
|
||||||
|
@ -98,6 +98,13 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void restoreSpeedEffects() {
|
||||||
|
if (Settings.isRemoveSpeedEnabled) {
|
||||||
|
player.setWalkSpeed(0.2F);
|
||||||
|
player.setFlySpeed(0.1F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void restoreInventory() {
|
protected void restoreInventory() {
|
||||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
||||||
pm.callEvent(event);
|
pm.callEvent(event);
|
||||||
@ -133,7 +140,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
// Limbo contains the State of the Player before /login
|
// Limbo contains the State of the Player before /login
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
|
|
||||||
// Restore Op state and Permission Group
|
// Restore Op state and Permission Group
|
||||||
restoreOpState();
|
restoreOpState();
|
||||||
Utils.setGroup(player, GroupType.LOGGEDIN);
|
Utils.setGroup(player, GroupType.LOGGEDIN);
|
||||||
@ -161,7 +167,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
restoreFlyghtState();
|
restoreFlyghtState();
|
||||||
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||||
restoreInventory();
|
restoreInventory();
|
||||||
}
|
}
|
||||||
@ -185,6 +190,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
AuthMePlayerListener.joinMessage.remove(name);
|
AuthMePlayerListener.joinMessage.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restoreSpeedEffects();
|
||||||
if (Settings.applyBlindEffect) {
|
if (Settings.applyBlindEffect) {
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||||
}
|
}
|
||||||
|
@ -40,17 +40,12 @@ public enum HashAlgorithm {
|
|||||||
/**
|
/**
|
||||||
* Constructor for HashAlgorithm.
|
* Constructor for HashAlgorithm.
|
||||||
*
|
*
|
||||||
* @param classe Class<?>
|
* @param classe The class of the hash implementation.
|
||||||
*/
|
*/
|
||||||
HashAlgorithm(Class<?> classe) {
|
HashAlgorithm(Class<?> classe) {
|
||||||
this.classe = classe;
|
this.classe = classe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getclasse.
|
|
||||||
*
|
|
||||||
* @return Class<?>
|
|
||||||
*/
|
|
||||||
public Class<?> getclasse() {
|
public Class<?> getclasse() {
|
||||||
return classe;
|
return classe;
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,6 @@ public class PasswordSecurity {
|
|||||||
public static final HashMap<String, String> userSalt = new HashMap<>();
|
public static final HashMap<String, String> userSalt = new HashMap<>();
|
||||||
private static final SecureRandom rnd = new SecureRandom();
|
private static final SecureRandom rnd = new SecureRandom();
|
||||||
|
|
||||||
/**
|
|
||||||
* Method createSalt.
|
|
||||||
*
|
|
||||||
* @param length int
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
public static String createSalt(int length)
|
public static String createSalt(int length)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
byte[] msg = new byte[40];
|
byte[] msg = new byte[40];
|
||||||
@ -38,15 +31,6 @@ public class PasswordSecurity {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)).substring(0, length);
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)).substring(0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param alg HashAlgorithm
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
public static String getHash(HashAlgorithm alg, String password,
|
public static String getHash(HashAlgorithm alg, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
EncryptionMethod method;
|
EncryptionMethod method;
|
||||||
@ -55,7 +39,7 @@ public class PasswordSecurity {
|
|||||||
method = (EncryptionMethod) alg.getclasse().newInstance();
|
method = (EncryptionMethod) alg.getclasse().newInstance();
|
||||||
else method = null;
|
else method = null;
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
throw new NoSuchAlgorithmException("Problem with hash algorithm '" + alg + "'", e);
|
||||||
}
|
}
|
||||||
String salt = "";
|
String salt = "";
|
||||||
switch (alg) {
|
switch (alg) {
|
||||||
@ -142,15 +126,6 @@ public class PasswordSecurity {
|
|||||||
return method.getHash(password, salt, playerName);
|
return method.getHash(password, salt, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePasswordWithHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param hash String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
public static boolean comparePasswordWithHash(String password, String hash,
|
public static boolean comparePasswordWithHash(String password, String hash,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
HashAlgorithm algorithm = Settings.getPasswordHash;
|
HashAlgorithm algorithm = Settings.getPasswordHash;
|
||||||
@ -181,15 +156,6 @@ public class PasswordSecurity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method compareWithAllEncryptionMethod.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param hash String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static boolean compareWithAllEncryptionMethod(String password,
|
private static boolean compareWithAllEncryptionMethod(String password,
|
||||||
String hash, String playerName) {
|
String hash, String playerName) {
|
||||||
for (HashAlgorithm algo : HashAlgorithm.values()) {
|
for (HashAlgorithm algo : HashAlgorithm.values()) {
|
||||||
|
@ -5,7 +5,6 @@ import java.util.Random;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Xephi59
|
* @author Xephi59
|
||||||
* @version $Revision: 1.0 $
|
|
||||||
*/
|
*/
|
||||||
public class RandomString {
|
public class RandomString {
|
||||||
|
|
||||||
@ -22,11 +21,6 @@ public class RandomString {
|
|||||||
|
|
||||||
private final char[] buf;
|
private final char[] buf;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for RandomString.
|
|
||||||
*
|
|
||||||
* @param length int
|
|
||||||
*/
|
|
||||||
public RandomString(int length) {
|
public RandomString(int length) {
|
||||||
if (length < 1)
|
if (length < 1)
|
||||||
throw new IllegalArgumentException("length < 1: " + length);
|
throw new IllegalArgumentException("length < 1: " + length);
|
||||||
@ -34,11 +28,6 @@ public class RandomString {
|
|||||||
random.setSeed(Calendar.getInstance().getTimeInMillis());
|
random.setSeed(Calendar.getInstance().getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method nextString.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String nextString() {
|
public String nextString() {
|
||||||
for (int idx = 0; idx < buf.length; ++idx)
|
for (int idx = 0; idx < buf.length; ++idx)
|
||||||
buf[idx] = chars[random.nextInt(chars.length)];
|
buf[idx] = chars[random.nextInt(chars.length)];
|
||||||
|
@ -359,14 +359,6 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getDoubleHash.
|
|
||||||
*
|
|
||||||
* @param text String
|
|
||||||
* @param salt String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public static String getDoubleHash(String text, String salt) {
|
public static String getDoubleHash(String text, String salt) {
|
||||||
String hash = hashpw(text, salt);
|
String hash = hashpw(text, salt);
|
||||||
return hashpw(text, hash);
|
return hashpw(text, hash);
|
||||||
@ -514,30 +506,12 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return hashpw(password, salt);
|
return hashpw(password, salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -6,15 +6,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class BCRYPT2Y implements EncryptionMethod {
|
public class BCRYPT2Y implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -23,15 +14,6 @@ public class BCRYPT2Y implements EncryptionMethod {
|
|||||||
return (BCRYPT.hashpw(password, salt));
|
return (BCRYPT.hashpw(password, salt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -11,11 +11,6 @@ public class CRAZYCRYPT1 implements EncryptionMethod {
|
|||||||
private static final char[] CRYPTCHARS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
private static final char[] CRYPTCHARS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
protected final Charset charset = Charset.forName("UTF-8");
|
protected final Charset charset = Charset.forName("UTF-8");
|
||||||
|
|
||||||
/**
|
|
||||||
* Method byteArrayToHexString.
|
|
||||||
*
|
|
||||||
* @param args byte[]String * @return String
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String byteArrayToHexString(final byte... args) {
|
public static String byteArrayToHexString(final byte... args) {
|
||||||
final char[] chars = new char[args.length * 2];
|
final char[] chars = new char[args.length * 2];
|
||||||
@ -26,15 +21,6 @@ public class CRAZYCRYPT1 implements EncryptionMethod {
|
|||||||
return new String(chars);
|
return new String(chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -48,14 +34,6 @@ public class CRAZYCRYPT1 implements EncryptionMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName Stringooleaneptiontring) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -10,15 +10,6 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
public class CryptPBKDF2 implements EncryptionMethod {
|
public class CryptPBKDF2 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -29,15 +20,6 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
|||||||
return result + Arrays.toString(engine.deriveKey(password, 64));
|
return result + Arrays.toString(engine.deriveKey(password, 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -10,15 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class CryptPBKDF2Django implements EncryptionMethod {
|
public class CryptPBKDF2Django implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -29,15 +20,6 @@ public class CryptPBKDF2Django implements EncryptionMethod {
|
|||||||
return result + String.valueOf(DatatypeConverter.printBase64Binary(engine.deriveKey(password, 32)));
|
return result + String.valueOf(DatatypeConverter.printBase64Binary(engine.deriveKey(password, 32)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class DOUBLEMD5 implements EncryptionMethod {
|
public class DOUBLEMD5 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -24,30 +17,12 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(password));
|
return getMD5(getMD5(password));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -13,9 +13,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
* <p>
|
* <p>
|
||||||
* The comparePassword is called when we need to match password (/login usually)
|
* The comparePassword is called when we need to match password (/login usually)
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* @author Gabriele
|
|
||||||
* @version $Revision: 1.0 $
|
|
||||||
*/
|
*/
|
||||||
public interface EncryptionMethod {
|
public interface EncryptionMethod {
|
||||||
|
|
||||||
@ -25,7 +22,7 @@ public interface EncryptionMethod {
|
|||||||
* etc... for customs methods)
|
* etc... for customs methods)
|
||||||
* @param name String
|
* @param name String
|
||||||
*
|
*
|
||||||
* @return Hashing password * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
* @return Hashing password
|
||||||
*/
|
*/
|
||||||
String getHash(String password, String salt, String name)
|
String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException;
|
throws NoSuchAlgorithmException;
|
||||||
@ -35,7 +32,7 @@ public interface EncryptionMethod {
|
|||||||
* @param password
|
* @param password
|
||||||
* @param playerName
|
* @param playerName
|
||||||
*
|
*
|
||||||
* @return true if password match, false else * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
* @return true if password match, false else
|
||||||
*/
|
*/
|
||||||
boolean comparePassword(String hash, String password, String playerName)
|
boolean comparePassword(String hash, String password, String playerName)
|
||||||
throws NoSuchAlgorithmException;
|
throws NoSuchAlgorithmException;
|
||||||
|
@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class IPB3 implements EncryptionMethod {
|
public class IPB3 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -26,30 +19,12 @@ public class IPB3 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(salt) + getMD5(password));
|
return getMD5(getMD5(salt) + getMD5(password));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class JOOMLA implements EncryptionMethod {
|
public class JOOMLA implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -24,30 +17,12 @@ public class JOOMLA implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(password + salt) + ":" + salt;
|
return getMD5(password + salt) + ":" + salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class MD5 implements EncryptionMethod {
|
public class MD5 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -24,30 +17,12 @@ public class MD5 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(password);
|
return getMD5(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class MD5VB implements EncryptionMethod {
|
public class MD5VB implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -24,30 +17,12 @@ public class MD5VB implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
|
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class MYBB implements EncryptionMethod {
|
public class MYBB implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -26,30 +19,12 @@ public class MYBB implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(salt) + getMD5(password));
|
return getMD5(getMD5(salt) + getMD5(password));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -11,19 +11,11 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author stefano
|
* @author stefano
|
||||||
* @version $Revision: 1.0 $
|
|
||||||
*/
|
*/
|
||||||
public class PHPBB implements EncryptionMethod {
|
public class PHPBB implements EncryptionMethod {
|
||||||
|
|
||||||
private final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
/**
|
|
||||||
* Method md5.
|
|
||||||
*
|
|
||||||
* @param data String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public static String md5(String data) {
|
public static String md5(String data) {
|
||||||
try {
|
try {
|
||||||
byte[] bytes = data.getBytes("ISO-8859-1");
|
byte[] bytes = data.getBytes("ISO-8859-1");
|
||||||
@ -35,14 +27,7 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static int hexToInt(char ch) {
|
||||||
* Method hexToInt.
|
|
||||||
*
|
|
||||||
* @param ch char
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
static int hexToInt(char ch) {
|
|
||||||
if (ch >= '0' && ch <= '9')
|
if (ch >= '0' && ch <= '9')
|
||||||
return ch - '0';
|
return ch - '0';
|
||||||
ch = Character.toUpperCase(ch);
|
ch = Character.toUpperCase(ch);
|
||||||
@ -51,13 +36,6 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
throw new IllegalArgumentException("Not a hex character: " + ch);
|
throw new IllegalArgumentException("Not a hex character: " + ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method bytes2hex.
|
|
||||||
*
|
|
||||||
* @param bytes byte[]
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private static String bytes2hex(byte[] bytes) {
|
private static String bytes2hex(byte[] bytes) {
|
||||||
StringBuilder r = new StringBuilder(32);
|
StringBuilder r = new StringBuilder(32);
|
||||||
for (byte b : bytes) {
|
for (byte b : bytes) {
|
||||||
@ -69,14 +47,7 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
return r.toString();
|
return r.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static String pack(String hex) {
|
||||||
* Method pack.
|
|
||||||
*
|
|
||||||
* @param hex String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
static String pack(String hex) {
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
for (int i = 0; i < hex.length(); i += 2) {
|
for (int i = 0; i < hex.length(); i += 2) {
|
||||||
char c1 = hex.charAt(i);
|
char c1 = hex.charAt(i);
|
||||||
@ -87,14 +58,6 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method phpbb_hash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String phpbb_hash(String password, String salt) {
|
public String phpbb_hash(String password, String salt) {
|
||||||
String random_state = salt;
|
String random_state = salt;
|
||||||
StringBuilder random = new StringBuilder();
|
StringBuilder random = new StringBuilder();
|
||||||
@ -110,27 +73,10 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
return md5(password);
|
return md5(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method _hash_gensalt_private.
|
|
||||||
*
|
|
||||||
* @param input String
|
|
||||||
* @param itoa64 String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String _hash_gensalt_private(String input, String itoa64) {
|
private String _hash_gensalt_private(String input, String itoa64) {
|
||||||
return _hash_gensalt_private(input, itoa64, 6);
|
return _hash_gensalt_private(input, itoa64, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method _hash_gensalt_private.
|
|
||||||
*
|
|
||||||
* @param input String
|
|
||||||
* @param itoa64 String
|
|
||||||
* @param iteration_count_log2 int
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String _hash_gensalt_private(String input, String itoa64,
|
private String _hash_gensalt_private(String input, String itoa64,
|
||||||
int iteration_count_log2) {
|
int iteration_count_log2) {
|
||||||
if (iteration_count_log2 < 4 || iteration_count_log2 > 31) {
|
if (iteration_count_log2 < 4 || iteration_count_log2 > 31) {
|
||||||
@ -142,14 +88,6 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Encode hash
|
|
||||||
*
|
|
||||||
* @param input String
|
|
||||||
* @param count int
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String _hash_encode64(String input, int count) {
|
private String _hash_encode64(String input, int count) {
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -171,14 +109,6 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method _hash_crypt_private.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param setting String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
String _hash_crypt_private(String password, String setting) {
|
String _hash_crypt_private(String password, String setting) {
|
||||||
String output = "*";
|
String output = "*";
|
||||||
if (!setting.substring(0, 3).equals("$H$"))
|
if (!setting.substring(0, 3).equals("$H$"))
|
||||||
@ -200,44 +130,18 @@ public class PHPBB implements EncryptionMethod {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method phpbb_check_hash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param hash String
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean phpbb_check_hash(String password, String hash) {
|
public boolean phpbb_check_hash(String password, String hash) {
|
||||||
if (hash.length() == 34)
|
if (hash.length() == 34)
|
||||||
return _hash_crypt_private(password, hash).equals(hash);
|
return _hash_crypt_private(password, hash).equals(hash);
|
||||||
else return md5(password).equals(hash);
|
else return md5(password).equals(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return phpbb_hash(password, salt);
|
return phpbb_hash(password, salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -14,13 +14,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class PHPFUSION implements EncryptionMethod {
|
public class PHPFUSION implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA1.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA1(String message)
|
private static String getSHA1(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||||
@ -30,15 +23,6 @@ public class PHPFUSION implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -66,15 +50,6 @@ public class PHPFUSION implements EncryptionMethod {
|
|||||||
return digest;
|
return digest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -6,30 +6,12 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class PLAINTEXT implements EncryptionMethod {
|
public class PLAINTEXT implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -7,15 +7,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class ROYALAUTH implements EncryptionMethod {
|
public class ROYALAUTH implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -24,14 +15,6 @@ public class ROYALAUTH implements EncryptionMethod {
|
|||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method hash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
public String hash(String password, String salt)
|
public String hash(String password, String salt)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
@ -43,15 +26,6 @@ public class ROYALAUTH implements EncryptionMethod {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class SALTED2MD5 implements EncryptionMethod {
|
public class SALTED2MD5 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getMD5.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getMD5(String message)
|
private static String getMD5(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||||
@ -26,30 +19,12 @@ public class SALTED2MD5 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(password) + salt);
|
return getMD5(getMD5(password) + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class SALTEDSHA512 implements EncryptionMethod {
|
public class SALTEDSHA512 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA512.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA512(String message)
|
private static String getSHA512(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||||
@ -26,30 +19,12 @@ public class SALTEDSHA512 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA512(password + salt);
|
return getSHA512(password + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class SHA1 implements EncryptionMethod {
|
public class SHA1 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA1.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA1(String message)
|
private static String getSHA1(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||||
@ -24,30 +17,12 @@ public class SHA1 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA1(password);
|
return getSHA1(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class SHA256 implements EncryptionMethod {
|
public class SHA256 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA256.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA256(String message)
|
private static String getSHA256(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
||||||
@ -24,30 +17,12 @@ public class SHA256 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return "$SHA$" + salt + "$" + getSHA256(getSHA256(password) + salt);
|
return "$SHA$" + salt + "$" + getSHA256(getSHA256(password) + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class SHA512 implements EncryptionMethod {
|
public class SHA512 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA512.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA512(String message)
|
private static String getSHA512(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||||
@ -24,30 +17,12 @@ public class SHA512 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA512(password);
|
return getSHA512(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class SMF implements EncryptionMethod {
|
public class SMF implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA1.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA1(String message)
|
private static String getSHA1(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||||
@ -24,30 +17,12 @@ public class SMF implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA1(name.toLowerCase() + password);
|
return getSHA1(name.toLowerCase() + password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class WBB3 implements EncryptionMethod {
|
public class WBB3 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSHA1.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
private static String getSHA1(String message)
|
private static String getSHA1(String message)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||||
@ -26,30 +19,12 @@ public class WBB3 implements EncryptionMethod {
|
|||||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password)))));
|
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -6,30 +6,12 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class WBB4 implements EncryptionMethod {
|
public class WBB4 implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return BCRYPT.getDoubleHash(password, salt);
|
return BCRYPT.getDoubleHash(password, salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -164,13 +164,6 @@ public class WHIRLPOOL implements EncryptionMethod {
|
|||||||
public WHIRLPOOL() {
|
public WHIRLPOOL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method display.
|
|
||||||
*
|
|
||||||
* @param array byte[]
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
protected static String display(byte[] array) {
|
protected static String display(byte[] array) {
|
||||||
char[] val = new char[2 * array.length];
|
char[] val = new char[2 * array.length];
|
||||||
String hex = "0123456789ABCDEF";
|
String hex = "0123456789ABCDEF";
|
||||||
@ -377,7 +370,6 @@ public class WHIRLPOOL implements EncryptionMethod {
|
|||||||
* Delivers string input data to the hashing algorithm.
|
* Delivers string input data to the hashing algorithm.
|
||||||
*
|
*
|
||||||
* @param source plaintext data to hash (ASCII text string).
|
* @param source plaintext data to hash (ASCII text string).
|
||||||
* <p/>
|
|
||||||
* This method maintains the invariant: bufferBits < 512
|
* This method maintains the invariant: bufferBits < 512
|
||||||
*/
|
*/
|
||||||
public void NESSIEadd(String source) {
|
public void NESSIEadd(String source) {
|
||||||
@ -409,15 +401,6 @@ public class WHIRLPOOL implements EncryptionMethod {
|
|||||||
return display(digest);
|
return display(digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -13,14 +13,6 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
private final SecureRandom randomGen = new SecureRandom();
|
private final SecureRandom randomGen = new SecureRandom();
|
||||||
|
|
||||||
/**
|
|
||||||
* Method encode64.
|
|
||||||
*
|
|
||||||
* @param src byte[]
|
|
||||||
* @param count int
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String encode64(byte[] src, int count) {
|
private String encode64(byte[] src, int count) {
|
||||||
int i, value;
|
int i, value;
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
@ -55,14 +47,6 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method crypt.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param setting String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String crypt(String password, String setting) {
|
private String crypt(String password, String setting) {
|
||||||
String output = "*0";
|
String output = "*0";
|
||||||
if (((setting.length() < 2) ? setting : setting.substring(0, 2)).equalsIgnoreCase(output)) {
|
if (((setting.length() < 2) ? setting : setting.substring(0, 2)).equalsIgnoreCase(output)) {
|
||||||
@ -101,13 +85,6 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method gensaltPrivate.
|
|
||||||
*
|
|
||||||
* @param input byte[]
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String gensaltPrivate(byte[] input) {
|
private String gensaltPrivate(byte[] input) {
|
||||||
String output = "$P$";
|
String output = "$P$";
|
||||||
int iterationCountLog2 = 8;
|
int iterationCountLog2 = 8;
|
||||||
@ -116,13 +93,6 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method stringToUtf8.
|
|
||||||
*
|
|
||||||
* @param string String
|
|
||||||
*
|
|
||||||
* @return byte[]
|
|
||||||
*/
|
|
||||||
private byte[] stringToUtf8(String string) {
|
private byte[] stringToUtf8(String string) {
|
||||||
try {
|
try {
|
||||||
return string.getBytes("UTF-8");
|
return string.getBytes("UTF-8");
|
||||||
@ -131,15 +101,6 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -148,15 +109,6 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));
|
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -6,13 +6,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class XAUTH implements EncryptionMethod {
|
public class XAUTH implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getWhirlpool.
|
|
||||||
*
|
|
||||||
* @param message String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public static String getWhirlpool(String message) {
|
public static String getWhirlpool(String message) {
|
||||||
WHIRLPOOL w = new WHIRLPOOL();
|
WHIRLPOOL w = new WHIRLPOOL();
|
||||||
byte[] digest = new byte[WHIRLPOOL.DIGESTBYTES];
|
byte[] digest = new byte[WHIRLPOOL.DIGESTBYTES];
|
||||||
@ -22,15 +15,6 @@ public class XAUTH implements EncryptionMethod {
|
|||||||
return WHIRLPOOL.display(digest);
|
return WHIRLPOOL.display(digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
@ -39,15 +23,6 @@ public class XAUTH implements EncryptionMethod {
|
|||||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
|
@ -13,30 +13,12 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class XF implements EncryptionMethod {
|
public class XF implements EncryptionMethod {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHash.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
* @param salt String
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt, String name)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
return getSha256(getSha256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method comparePassword.
|
|
||||||
*
|
|
||||||
* @param hash String
|
|
||||||
* @param password String
|
|
||||||
* @param playerName String
|
|
||||||
*
|
|
||||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
@ -44,14 +26,7 @@ public class XF implements EncryptionMethod {
|
|||||||
return hash.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
|
return hash.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private String getSha256(String password) throws NoSuchAlgorithmException {
|
||||||
* Method getSHA256.
|
|
||||||
*
|
|
||||||
* @param password String
|
|
||||||
*
|
|
||||||
* @return String * @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
public String getSHA256(String password) throws NoSuchAlgorithmException {
|
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||||
md.update(password.getBytes());
|
md.update(password.getBytes());
|
||||||
byte byteData[] = md.digest();
|
byte byteData[] = md.digest();
|
||||||
@ -70,15 +45,7 @@ public class XF implements EncryptionMethod {
|
|||||||
return hexString.toString();
|
return hexString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private String regmatch(String pattern, String line) {
|
||||||
* Method regmatch.
|
|
||||||
*
|
|
||||||
* @param pattern String
|
|
||||||
* @param line String
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String regmatch(String pattern, String line) {
|
|
||||||
List<String> allMatches = new ArrayList<>();
|
List<String> allMatches = new ArrayList<>();
|
||||||
Matcher m = Pattern.compile(pattern).matcher(line);
|
Matcher m = Pattern.compile(pattern).matcher(line);
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
|
@ -32,7 +32,10 @@ package fr.xephi.authme.security.pbkdf2;
|
|||||||
*/
|
*/
|
||||||
public class BinTools {
|
public class BinTools {
|
||||||
|
|
||||||
public static final String hex = "0123456789ABCDEF";
|
private static final String HEX_CHARS = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
private BinTools() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple binary-to-hexadecimal conversion.
|
* Simple binary-to-hexadecimal conversion.
|
||||||
@ -49,8 +52,8 @@ public class BinTools {
|
|||||||
StringBuffer stringBuffer = new StringBuffer(2 * b.length);
|
StringBuffer stringBuffer = new StringBuffer(2 * b.length);
|
||||||
for (byte aB : b) {
|
for (byte aB : b) {
|
||||||
int v = (256 + aB) % 256;
|
int v = (256 + aB) % 256;
|
||||||
stringBuffer.append(hex.charAt((v / 16) & 15));
|
stringBuffer.append(HEX_CHARS.charAt((v / 16) & 15));
|
||||||
stringBuffer.append(hex.charAt((v % 16) & 15));
|
stringBuffer.append(HEX_CHARS.charAt((v % 16) & 15));
|
||||||
}
|
}
|
||||||
return stringBuffer.toString();
|
return stringBuffer.toString();
|
||||||
}
|
}
|
||||||
@ -58,11 +61,11 @@ public class BinTools {
|
|||||||
/**
|
/**
|
||||||
* Convert hex string to array of bytes.
|
* Convert hex string to array of bytes.
|
||||||
*
|
*
|
||||||
* @param s String containing hexadecimal digits. May be <code>null</code>
|
* @param s String containing hexadecimal digits. May be <code>null</code>.
|
||||||
* . On odd length leading zero will be assumed.
|
* On odd length leading zero will be assumed.
|
||||||
*
|
*
|
||||||
* @return Array on bytes, non-<code>null</code>. * @throws IllegalArgumentException
|
* @return Array on bytes, non-<code>null</code>.
|
||||||
* when string contains non-hex character
|
* @throws IllegalArgumentException when string contains non-hex character
|
||||||
*/
|
*/
|
||||||
public static byte[] hex2bin(final String s) {
|
public static byte[] hex2bin(final String s) {
|
||||||
String m = s;
|
String m = s;
|
||||||
@ -85,10 +88,10 @@ public class BinTools {
|
|||||||
/**
|
/**
|
||||||
* Convert hex digit to numerical value.
|
* Convert hex digit to numerical value.
|
||||||
*
|
*
|
||||||
* @param c 0-9, a-f, A-F allowd.
|
* @param c 0-9, a-f, A-F allowed.
|
||||||
*
|
*
|
||||||
* @return 0-15 * @throws IllegalArgumentException
|
* @return 0-15
|
||||||
* on non-hex character
|
* @throws IllegalArgumentException on non-hex character
|
||||||
*/
|
*/
|
||||||
public static int hex2bin(char c) {
|
public static int hex2bin(char c) {
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
@ -103,12 +106,8 @@ public class BinTools {
|
|||||||
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
|
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// TODO ljacqu 20151219: Move to a BinToolsTest class
|
||||||
* Method main.
|
private static void testUtils(String[] args) {
|
||||||
*
|
|
||||||
* @param args String[]
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
byte b[] = new byte[256];
|
byte b[] = new byte[256];
|
||||||
byte bb = 0;
|
byte bb = 0;
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
|
@ -63,12 +63,6 @@ public class MacBasedPRF implements PRF {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for MacBasedPRF.
|
|
||||||
*
|
|
||||||
* @param macAlgorithm String
|
|
||||||
* @param provider String
|
|
||||||
*/
|
|
||||||
public MacBasedPRF(String macAlgorithm, String provider) {
|
public MacBasedPRF(String macAlgorithm, String provider) {
|
||||||
this.macAlgorithm = macAlgorithm;
|
this.macAlgorithm = macAlgorithm;
|
||||||
try {
|
try {
|
||||||
@ -79,34 +73,18 @@ public class MacBasedPRF implements PRF {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method doFinal.
|
|
||||||
*
|
|
||||||
* @param M byte[]
|
|
||||||
*
|
|
||||||
* @return byte[] * @see fr.xephi.authme.security.pbkdf2.PRF#doFinal(byte[])
|
|
||||||
*/
|
|
||||||
public byte[] doFinal(byte[] M) {
|
public byte[] doFinal(byte[] M) {
|
||||||
byte[] r = mac.doFinal(M);
|
byte[] r = mac.doFinal(M);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method getHLen.
|
|
||||||
*
|
|
||||||
* @return int * @see fr.xephi.authme.security.pbkdf2.PRF#getHLen()
|
|
||||||
*/
|
|
||||||
public int getHLen() {
|
public int getHLen() {
|
||||||
return hLen;
|
return hLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method init.
|
|
||||||
*
|
|
||||||
* @param P byte[]
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.security.pbkdf2.PRF#init(byte[])
|
|
||||||
*/
|
|
||||||
public void init(byte[] P) {
|
public void init(byte[] P) {
|
||||||
try {
|
try {
|
||||||
mac.init(new SecretKeySpec(P, macAlgorithm));
|
mac.init(new SecretKeySpec(P, macAlgorithm));
|
||||||
|
@ -159,28 +159,15 @@ public class PBKDF2Engine implements PBKDF2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method deriveKey.
|
|
||||||
*
|
|
||||||
* @param inputPassword String
|
|
||||||
*
|
|
||||||
* @return byte[] * @see fr.xephi.authme.security.pbkdf2.PBKDF2#deriveKey(String)
|
|
||||||
*/
|
|
||||||
public byte[] deriveKey(String inputPassword) {
|
public byte[] deriveKey(String inputPassword) {
|
||||||
return deriveKey(inputPassword, 0);
|
return deriveKey(inputPassword, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method deriveKey.
|
|
||||||
*
|
|
||||||
* @param inputPassword String
|
|
||||||
* @param dkLen int
|
|
||||||
*
|
|
||||||
* @return byte[] * @see fr.xephi.authme.security.pbkdf2.PBKDF2#deriveKey(String, int)
|
|
||||||
*/
|
|
||||||
public byte[] deriveKey(String inputPassword, int dkLen) {
|
public byte[] deriveKey(String inputPassword, int dkLen) {
|
||||||
byte[] r = null;
|
byte[] r = null;
|
||||||
byte P[] = null;
|
byte[] P = null;
|
||||||
String charset = parameters.getHashCharset();
|
String charset = parameters.getHashCharset();
|
||||||
if (inputPassword == null) {
|
if (inputPassword == null) {
|
||||||
inputPassword = "";
|
inputPassword = "";
|
||||||
@ -202,13 +189,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method verifyKey.
|
|
||||||
*
|
|
||||||
* @param inputPassword String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.security.pbkdf2.PBKDF2#verifyKey(String)
|
|
||||||
*/
|
|
||||||
public boolean verifyKey(String inputPassword) {
|
public boolean verifyKey(String inputPassword) {
|
||||||
byte[] referenceKey = getParameters().getDerivedKey();
|
byte[] referenceKey = getParameters().getDerivedKey();
|
||||||
if (referenceKey == null || referenceKey.length == 0) {
|
if (referenceKey == null || referenceKey.length == 0) {
|
||||||
@ -240,22 +221,12 @@ public class PBKDF2Engine implements PBKDF2 {
|
|||||||
prf.init(P);
|
prf.init(P);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method getPseudoRandomFunction.
|
|
||||||
*
|
|
||||||
* @return PRF * @see fr.xephi.authme.security.pbkdf2.PBKDF2#getPseudoRandomFunction()
|
|
||||||
*/
|
|
||||||
public PRF getPseudoRandomFunction() {
|
public PRF getPseudoRandomFunction() {
|
||||||
return prf;
|
return prf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method setPseudoRandomFunction.
|
|
||||||
*
|
|
||||||
* @param prf PRF
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.security.pbkdf2.PBKDF2#setPseudoRandomFunction(PRF)
|
|
||||||
*/
|
|
||||||
public void setPseudoRandomFunction(PRF prf) {
|
public void setPseudoRandomFunction(PRF prf) {
|
||||||
this.prf = prf;
|
this.prf = prf;
|
||||||
}
|
}
|
||||||
@ -369,22 +340,12 @@ public class PBKDF2Engine implements PBKDF2 {
|
|||||||
dest[offset + 3] = (byte) (i);
|
dest[offset + 3] = (byte) (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method getParameters.
|
|
||||||
*
|
|
||||||
* @return PBKDF2Parameters * @see fr.xephi.authme.security.pbkdf2.PBKDF2#getParameters()
|
|
||||||
*/
|
|
||||||
public PBKDF2Parameters getParameters() {
|
public PBKDF2Parameters getParameters() {
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method setParameters.
|
|
||||||
*
|
|
||||||
* @param parameters PBKDF2Parameters
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.security.pbkdf2.PBKDF2#setParameters(PBKDF2Parameters)
|
|
||||||
*/
|
|
||||||
public void setParameters(PBKDF2Parameters parameters) {
|
public void setParameters(PBKDF2Parameters parameters) {
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,7 @@ package fr.xephi.authme.security.pbkdf2;
|
|||||||
*/
|
*/
|
||||||
public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method fromString.
|
|
||||||
*
|
|
||||||
* @param p PBKDF2Parameters
|
|
||||||
* @param s String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.security.pbkdf2.PBKDF2Formatter#fromString(PBKDF2Parameters, String)
|
|
||||||
*/
|
|
||||||
public boolean fromString(PBKDF2Parameters p, String s) {
|
public boolean fromString(PBKDF2Parameters p, String s) {
|
||||||
if (p == null || s == null) {
|
if (p == null || s == null) {
|
||||||
return true;
|
return true;
|
||||||
@ -61,13 +54,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Method toString.
|
|
||||||
*
|
|
||||||
* @param p PBKDF2Parameters
|
|
||||||
*
|
|
||||||
* @return String * @see fr.xephi.authme.security.pbkdf2.PBKDF2Formatter#toString(PBKDF2Parameters)
|
|
||||||
*/
|
|
||||||
public String toString(PBKDF2Parameters p) {
|
public String toString(PBKDF2Parameters p) {
|
||||||
String s = BinTools.bin2hex(p.getSalt()) + ":" + String.valueOf(p.getIterationCount()) + ":" + BinTools.bin2hex(p.getDerivedKey());
|
String s = BinTools.bin2hex(p.getSalt()) + ":" + String.valueOf(p.getIterationCount()) + ":" + BinTools.bin2hex(p.getDerivedKey());
|
||||||
return s;
|
return s;
|
||||||
|
@ -99,92 +99,42 @@ public class PBKDF2Parameters {
|
|||||||
this.derivedKey = derivedKey;
|
this.derivedKey = derivedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getIterationCount.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public int getIterationCount() {
|
public int getIterationCount() {
|
||||||
return iterationCount;
|
return iterationCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setIterationCount.
|
|
||||||
*
|
|
||||||
* @param iterationCount int
|
|
||||||
*/
|
|
||||||
public void setIterationCount(int iterationCount) {
|
public void setIterationCount(int iterationCount) {
|
||||||
this.iterationCount = iterationCount;
|
this.iterationCount = iterationCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getSalt.
|
|
||||||
*
|
|
||||||
* @return byte[]
|
|
||||||
*/
|
|
||||||
public byte[] getSalt() {
|
public byte[] getSalt() {
|
||||||
return salt;
|
return salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setSalt.
|
|
||||||
*
|
|
||||||
* @param salt byte[]
|
|
||||||
*/
|
|
||||||
public void setSalt(byte[] salt) {
|
public void setSalt(byte[] salt) {
|
||||||
this.salt = salt;
|
this.salt = salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getDerivedKey.
|
|
||||||
*
|
|
||||||
* @return byte[]
|
|
||||||
*/
|
|
||||||
public byte[] getDerivedKey() {
|
public byte[] getDerivedKey() {
|
||||||
return derivedKey;
|
return derivedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setDerivedKey.
|
|
||||||
*
|
|
||||||
* @param derivedKey byte[]
|
|
||||||
*/
|
|
||||||
public void setDerivedKey(byte[] derivedKey) {
|
public void setDerivedKey(byte[] derivedKey) {
|
||||||
this.derivedKey = derivedKey;
|
this.derivedKey = derivedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHashAlgorithm.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getHashAlgorithm() {
|
public String getHashAlgorithm() {
|
||||||
return hashAlgorithm;
|
return hashAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setHashAlgorithm.
|
|
||||||
*
|
|
||||||
* @param hashAlgorithm String
|
|
||||||
*/
|
|
||||||
public void setHashAlgorithm(String hashAlgorithm) {
|
public void setHashAlgorithm(String hashAlgorithm) {
|
||||||
this.hashAlgorithm = hashAlgorithm;
|
this.hashAlgorithm = hashAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getHashCharset.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getHashCharset() {
|
public String getHashCharset() {
|
||||||
return hashCharset;
|
return hashCharset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setHashCharset.
|
|
||||||
*
|
|
||||||
* @param hashCharset String
|
|
||||||
*/
|
|
||||||
public void setHashCharset(String hashCharset) {
|
public void setHashCharset(String hashCharset) {
|
||||||
this.hashCharset = hashCharset;
|
this.hashCharset = hashCharset;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
SET batdir=C:\your\path\AUTHME_DEV\bathelpers\
|
SET batdir=C:\your\path\AUTHME_DEV\bathelpers\
|
||||||
|
|
||||||
: The location of the generated JAR file
|
: The location of the generated JAR file
|
||||||
SET jarfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\target\AuthMe-5.1-SNAPSHOT.jar
|
SET jarfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\target\AuthMe-5.2-SNAPSHOT.jar
|
||||||
|
|
||||||
: The location of the pom.xml file of the project
|
: The location of the pom.xml file of the project
|
||||||
SET pomfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\pom.xml
|
SET pomfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\pom.xml
|
||||||
|
Loading…
Reference in New Issue
Block a user