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