registrationExecutorFactory;
AsyncRegister() {
}
@@ -38,12 +43,16 @@ public class AsyncRegister implements AsynchronousProcess {
/**
* Performs the registration process for the given player.
*
- * @param player the player to register
- * @param executor the registration executor to perform the registration with
+ * @param variant the registration method
+ * @param parameters the parameters
+ * @param parameters type
*/
- public void register(Player player, RegistrationExecutor executor) {
- if (preRegisterCheck(player) && executor.isRegistrationAdmitted()) {
- executeRegistration(player, executor);
+ public
void register(RegistrationMethod
variant, P parameters) {
+ if (preRegisterCheck(parameters.getPlayer())) {
+ RegistrationExecutor
executor = registrationExecutorFactory.getSingleton(variant.getExecutorClass());
+ if (executor.isRegistrationAdmitted(parameters)) {
+ executeRegistration(parameters, executor);
+ }
}
}
@@ -66,15 +75,17 @@ public class AsyncRegister implements AsynchronousProcess {
/**
* Executes the registration.
*
- * @param player the player to register
+ * @param parameters the registration parameters
* @param executor the executor to perform the registration process with
+ * @param
registration params type
*/
- private void executeRegistration(Player player, RegistrationExecutor executor) {
- PlayerAuth auth = executor.buildPlayerAuth();
+ private
+ void executeRegistration(P parameters, RegistrationExecutor
executor) {
+ PlayerAuth auth = executor.buildPlayerAuth(parameters);
if (database.saveAuth(auth)) {
- executor.executePostPersistAction();
+ executor.executePostPersistAction(parameters);
} else {
- service.send(player, MessageKey.ERROR);
+ service.send(parameters.getPlayer(), MessageKey.ERROR);
}
}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java b/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java
new file mode 100644
index 000000000..9f0ee7248
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java
@@ -0,0 +1,97 @@
+package fr.xephi.authme.process.register.executors;
+
+import fr.xephi.authme.data.auth.PlayerAuth;
+import fr.xephi.authme.process.SyncProcessManager;
+import fr.xephi.authme.process.login.AsynchronousLogin;
+import fr.xephi.authme.security.PasswordSecurity;
+import fr.xephi.authme.security.crypts.HashedPassword;
+import fr.xephi.authme.service.BukkitService;
+import fr.xephi.authme.service.CommonService;
+import fr.xephi.authme.service.ValidationService;
+import fr.xephi.authme.settings.properties.PluginSettings;
+import fr.xephi.authme.settings.properties.RegistrationSettings;
+import org.bukkit.entity.Player;
+
+import javax.inject.Inject;
+
+/**
+ * Registration executor for registration methods where the password
+ * is supplied by the user.
+ */
+abstract class AbstractPasswordRegisterExecutor
+ implements RegistrationExecutor
{
+
+ /**
+ * Number of ticks to wait before running the login action when it is run synchronously.
+ * A small delay is necessary or the database won't return the newly saved PlayerAuth object
+ * and the login process thinks the user is not registered.
+ */
+ private static final int SYNC_LOGIN_DELAY = 5;
+
+ @Inject
+ private ValidationService validationService;
+
+ @Inject
+ private CommonService commonService;
+
+ @Inject
+ private PasswordSecurity passwordSecurity;
+
+ @Inject
+ private BukkitService bukkitService;
+
+ @Inject
+ private SyncProcessManager syncProcessManager;
+
+ @Inject
+ private AsynchronousLogin asynchronousLogin;
+
+ @Override
+ public boolean isRegistrationAdmitted(P params) {
+ ValidationService.ValidationResult passwordValidation = validationService.validatePassword(
+ params.getPassword(), params.getPlayer().getName());
+ if (passwordValidation.hasError()) {
+ commonService.send(params.getPlayer(), passwordValidation.getMessageKey(), passwordValidation.getArgs());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public PlayerAuth buildPlayerAuth(P params) {
+ HashedPassword hashedPassword = passwordSecurity.computeHash(params.getPassword(), params.getPlayerName());
+ params.setHashedPassword(hashedPassword);
+ return createPlayerAuthObject(params);
+ }
+
+ /**
+ * Creates the PlayerAuth object to store into the database, based on the registration parameters.
+ *
+ * @param params the parameters
+ * @return the PlayerAuth representing the new account to register
+ */
+ protected abstract PlayerAuth createPlayerAuthObject(P params);
+
+ /**
+ * Returns whether the player should be automatically logged in after registration.
+ *
+ * @param params the registration parameters
+ * @return true if the player should be logged in, false otherwise
+ */
+ protected boolean performLoginAfterRegister(P params) {
+ return !commonService.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER);
+ }
+
+ @Override
+ public void executePostPersistAction(P params) {
+ final Player player = params.getPlayer();
+ if (performLoginAfterRegister(params)) {
+ if (commonService.getProperty(PluginSettings.USE_ASYNC_TASKS)) {
+ bukkitService.runTaskAsynchronously(() -> asynchronousLogin.forceLogin(player));
+ } else {
+ bukkitService.scheduleSyncDelayedTask(() -> asynchronousLogin.forceLogin(player), SYNC_LOGIN_DELAY);
+ }
+ }
+ syncProcessManager.processSyncPasswordRegister(player);
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterParams.java b/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterParams.java
new file mode 100644
index 000000000..0c7a1d515
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterParams.java
@@ -0,0 +1,48 @@
+package fr.xephi.authme.process.register.executors;
+
+import fr.xephi.authme.security.crypts.HashedPassword;
+import org.bukkit.entity.Player;
+
+/**
+ * Common params type for implementors of {@link AbstractPasswordRegisterExecutor}.
+ * Password must be supplied on creation and cannot be changed later on. The {@link HashedPassword}
+ * is stored on the params object for later use.
+ */
+public abstract class AbstractPasswordRegisterParams extends RegistrationParameters {
+
+ private final String password;
+ private HashedPassword hashedPassword;
+
+ /**
+ * Constructor.
+ *
+ * @param player the player to register
+ * @param password the password to use
+ */
+ public AbstractPasswordRegisterParams(Player player, String password) {
+ super(player);
+ this.password = password;
+ }
+
+ /**
+ * Constructor with no defined password. Use for registration methods which
+ * have no implicit password (like two factor authentication).
+ *
+ * @param player the player to register
+ */
+ public AbstractPasswordRegisterParams(Player player) {
+ this(player, null);
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ void setHashedPassword(HashedPassword hashedPassword) {
+ this.hashedPassword = hashedPassword;
+ }
+
+ HashedPassword getHashedPassword() {
+ return hashedPassword;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/ApiPasswordRegisterExecutor.java b/src/main/java/fr/xephi/authme/process/register/executors/ApiPasswordRegisterExecutor.java
new file mode 100644
index 000000000..6005c8e41
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/ApiPasswordRegisterExecutor.java
@@ -0,0 +1,20 @@
+package fr.xephi.authme.process.register.executors;
+
+import fr.xephi.authme.data.auth.PlayerAuth;
+
+/**
+ * Executor for password registration via API call.
+ */
+class ApiPasswordRegisterExecutor extends AbstractPasswordRegisterExecutor {
+
+ @Override
+ protected PlayerAuth createPlayerAuthObject(ApiPasswordRegisterParams params) {
+ return PlayerAuthBuilderHelper
+ .createPlayerAuth(params.getPlayer(), params.getHashedPassword(), null);
+ }
+
+ @Override
+ protected boolean performLoginAfterRegister(ApiPasswordRegisterParams params) {
+ return params.getLoginAfterRegister();
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/ApiPasswordRegisterParams.java b/src/main/java/fr/xephi/authme/process/register/executors/ApiPasswordRegisterParams.java
new file mode 100644
index 000000000..357d32c22
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/ApiPasswordRegisterParams.java
@@ -0,0 +1,35 @@
+package fr.xephi.authme.process.register.executors;
+
+import org.bukkit.entity.Player;
+
+/**
+ * Parameters for {@link ApiPasswordRegisterExecutor}.
+ */
+public class ApiPasswordRegisterParams extends PasswordRegisterParams {
+
+ private final boolean loginAfterRegister;
+
+ protected ApiPasswordRegisterParams(Player player, String password, boolean loginAfterRegister) {
+ super(player, password, null);
+ this.loginAfterRegister = loginAfterRegister;
+ }
+
+ /**
+ * Creates a parameters object.
+ *
+ * @param player the player to register
+ * @param password the password to register with
+ * @param loginAfterRegister whether the player should be logged in after registration
+ * @return params object with the given data
+ */
+ public static ApiPasswordRegisterParams of(Player player, String password, boolean loginAfterRegister) {
+ return new ApiPasswordRegisterParams(player, password, loginAfterRegister);
+ }
+
+ /**
+ * @return true if the player should be logged in after being registered, false otherwise
+ */
+ public boolean getLoginAfterRegister() {
+ return loginAfterRegister;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutor.java b/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutor.java
new file mode 100644
index 000000000..0f4153b18
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutor.java
@@ -0,0 +1,80 @@
+package fr.xephi.authme.process.register.executors;
+
+import fr.xephi.authme.data.auth.PlayerAuth;
+import fr.xephi.authme.datasource.DataSource;
+import fr.xephi.authme.mail.EmailService;
+import fr.xephi.authme.message.MessageKey;
+import fr.xephi.authme.permission.PermissionsManager;
+import fr.xephi.authme.process.SyncProcessManager;
+import fr.xephi.authme.security.PasswordSecurity;
+import fr.xephi.authme.security.crypts.HashedPassword;
+import fr.xephi.authme.service.CommonService;
+import fr.xephi.authme.settings.properties.EmailSettings;
+import fr.xephi.authme.util.RandomStringUtils;
+import org.bukkit.entity.Player;
+
+import javax.inject.Inject;
+
+import static fr.xephi.authme.permission.PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS;
+import static fr.xephi.authme.process.register.executors.PlayerAuthBuilderHelper.createPlayerAuth;
+import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWORD_LENGTH;
+
+/**
+ * Executor for email registration: the player only provides his email address,
+ * to which a generated password is sent.
+ */
+class EmailRegisterExecutor implements RegistrationExecutor {
+
+ @Inject
+ private PermissionsManager permissionsManager;
+
+ @Inject
+ private DataSource dataSource;
+
+ @Inject
+ private CommonService commonService;
+
+ @Inject
+ private EmailService emailService;
+
+ @Inject
+ private SyncProcessManager syncProcessManager;
+
+ @Inject
+ private PasswordSecurity passwordSecurity;
+
+ @Override
+ public boolean isRegistrationAdmitted(EmailRegisterParams params) {
+ final int maxRegPerEmail = commonService.getProperty(EmailSettings.MAX_REG_PER_EMAIL);
+ if (maxRegPerEmail > 0 && !permissionsManager.hasPermission(params.getPlayer(), ALLOW_MULTIPLE_ACCOUNTS)) {
+ int otherAccounts = dataSource.countAuthsByEmail(params.getEmail());
+ if (otherAccounts >= maxRegPerEmail) {
+ commonService.send(params.getPlayer(), MessageKey.MAX_REGISTER_EXCEEDED,
+ Integer.toString(maxRegPerEmail), Integer.toString(otherAccounts), "@");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public PlayerAuth buildPlayerAuth(EmailRegisterParams params) {
+ String password = RandomStringUtils.generate(commonService.getProperty(RECOVERY_PASSWORD_LENGTH));
+ HashedPassword hashedPassword = passwordSecurity.computeHash(password, params.getPlayer().getName());
+ params.setPassword(password);
+ return createPlayerAuth(params.getPlayer(), hashedPassword, params.getEmail());
+ }
+
+ @Override
+ public void executePostPersistAction(EmailRegisterParams params) {
+ Player player = params.getPlayer();
+ boolean couldSendMail = emailService.sendPasswordMail(
+ player.getName(), params.getEmail(), params.getPassword());
+ if (couldSendMail) {
+ syncProcessManager.processSyncEmailRegister(player);
+ } else {
+ commonService.send(player, MessageKey.EMAIL_SEND_FAILURE);
+ }
+ }
+
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProvider.java b/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProvider.java
deleted file mode 100644
index 7a6e702d3..000000000
--- a/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProvider.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package fr.xephi.authme.process.register.executors;
-
-import fr.xephi.authme.data.auth.PlayerAuth;
-import fr.xephi.authme.datasource.DataSource;
-import fr.xephi.authme.mail.EmailService;
-import fr.xephi.authme.message.MessageKey;
-import fr.xephi.authme.permission.PermissionsManager;
-import fr.xephi.authme.process.SyncProcessManager;
-import fr.xephi.authme.security.PasswordSecurity;
-import fr.xephi.authme.security.crypts.HashedPassword;
-import fr.xephi.authme.service.CommonService;
-import fr.xephi.authme.settings.properties.EmailSettings;
-import fr.xephi.authme.util.RandomStringUtils;
-import org.bukkit.entity.Player;
-
-import javax.inject.Inject;
-
-import static fr.xephi.authme.permission.PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS;
-import static fr.xephi.authme.process.register.executors.PlayerAuthBuilderHelper.createPlayerAuth;
-import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWORD_LENGTH;
-
-/**
- * Provides a registration executor for email registration.
- */
-class EmailRegisterExecutorProvider {
-
- @Inject
- private PermissionsManager permissionsManager;
-
- @Inject
- private DataSource dataSource;
-
- @Inject
- private CommonService commonService;
-
- @Inject
- private EmailService emailService;
-
- @Inject
- private SyncProcessManager syncProcessManager;
-
- @Inject
- private PasswordSecurity passwordSecurity;
-
- EmailRegisterExecutorProvider() {
- }
-
- /** Registration executor implementation for email registration. */
- class EmailRegisterExecutor implements RegistrationExecutor {
-
- private final Player player;
- private final String email;
- private String password;
-
- EmailRegisterExecutor(Player player, String email) {
- this.player = player;
- this.email = email;
- }
-
- @Override
- public boolean isRegistrationAdmitted() {
- final int maxRegPerEmail = commonService.getProperty(EmailSettings.MAX_REG_PER_EMAIL);
- if (maxRegPerEmail > 0 && !permissionsManager.hasPermission(player, ALLOW_MULTIPLE_ACCOUNTS)) {
- int otherAccounts = dataSource.countAuthsByEmail(email);
- if (otherAccounts >= maxRegPerEmail) {
- commonService.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxRegPerEmail),
- Integer.toString(otherAccounts), "@");
- return false;
- }
- }
- return true;
- }
-
- @Override
- public PlayerAuth buildPlayerAuth() {
- password = RandomStringUtils.generate(commonService.getProperty(RECOVERY_PASSWORD_LENGTH));
- HashedPassword hashedPassword = passwordSecurity.computeHash(password, player.getName());
- return createPlayerAuth(player, hashedPassword, email);
- }
-
- @Override
- public void executePostPersistAction() {
- boolean couldSendMail = emailService.sendPasswordMail(player.getName(), email, password);
- if (couldSendMail) {
- syncProcessManager.processSyncEmailRegister(player);
- } else {
- commonService.send(player, MessageKey.EMAIL_SEND_FAILURE);
- }
- }
- }
-}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterParams.java b/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterParams.java
new file mode 100644
index 000000000..94d03acc5
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/EmailRegisterParams.java
@@ -0,0 +1,43 @@
+package fr.xephi.authme.process.register.executors;
+
+import org.bukkit.entity.Player;
+
+/**
+ * Parameters for email registration.
+ */
+public class EmailRegisterParams extends RegistrationParameters {
+
+ private final String email;
+ private String password;
+
+ protected EmailRegisterParams(Player player, String email) {
+ super(player);
+ this.email = email;
+ }
+
+ /**
+ * Creates a params object for email registration.
+ *
+ * @param player the player to register
+ * @param email the player's email
+ * @return params object with the given data
+ */
+ public static EmailRegisterParams of(Player player, String email) {
+ return new EmailRegisterParams(player, email);
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the password generated for the player
+ */
+ String getPassword() {
+ return password;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutor.java b/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutor.java
new file mode 100644
index 000000000..167bee292
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutor.java
@@ -0,0 +1,17 @@
+package fr.xephi.authme.process.register.executors;
+
+import fr.xephi.authme.data.auth.PlayerAuth;
+
+import static fr.xephi.authme.process.register.executors.PlayerAuthBuilderHelper.createPlayerAuth;
+
+/**
+ * Registration executor for password registration.
+ */
+class PasswordRegisterExecutor extends AbstractPasswordRegisterExecutor {
+
+ @Override
+ public PlayerAuth createPlayerAuthObject(PasswordRegisterParams params) {
+ return createPlayerAuth(params.getPlayer(), params.getHashedPassword(), params.getEmail());
+ }
+
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorProvider.java b/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorProvider.java
deleted file mode 100644
index 9d40bcf82..000000000
--- a/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorProvider.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package fr.xephi.authme.process.register.executors;
-
-import fr.xephi.authme.data.auth.PlayerAuth;
-import fr.xephi.authme.message.MessageKey;
-import fr.xephi.authme.process.SyncProcessManager;
-import fr.xephi.authme.process.login.AsynchronousLogin;
-import fr.xephi.authme.security.PasswordSecurity;
-import fr.xephi.authme.security.crypts.HashedPassword;
-import fr.xephi.authme.security.crypts.TwoFactor;
-import fr.xephi.authme.service.BukkitService;
-import fr.xephi.authme.service.CommonService;
-import fr.xephi.authme.service.ValidationService;
-import fr.xephi.authme.service.ValidationService.ValidationResult;
-import fr.xephi.authme.settings.properties.PluginSettings;
-import fr.xephi.authme.settings.properties.RegistrationSettings;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import javax.inject.Inject;
-
-import static fr.xephi.authme.process.register.executors.PlayerAuthBuilderHelper.createPlayerAuth;
-
-/**
- * Provides registration executors for password-based registration variants.
- */
-class PasswordRegisterExecutorProvider {
-
- /**
- * Number of ticks to wait before running the login action when it is run synchronously.
- * A small delay is necessary or the database won't return the newly saved PlayerAuth object
- * and the login process thinks the user is not registered.
- */
- private static final int SYNC_LOGIN_DELAY = 5;
-
- @Inject
- private ValidationService validationService;
-
- @Inject
- private CommonService commonService;
-
- @Inject
- private PasswordSecurity passwordSecurity;
-
- @Inject
- private BukkitService bukkitService;
-
- @Inject
- private SyncProcessManager syncProcessManager;
-
- @Inject
- private AsynchronousLogin asynchronousLogin;
-
- PasswordRegisterExecutorProvider() {
- }
-
- /** Registration executor for password registration. */
- class PasswordRegisterExecutor implements RegistrationExecutor {
-
- private final Player player;
- private final String password;
- private final String email;
- private HashedPassword hashedPassword;
-
- /**
- * Constructor.
- *
- * @param player the player to register
- * @param password the password to register with
- * @param email the email of the player (may be null)
- */
- PasswordRegisterExecutor(Player player, String password, String email) {
- this.player = player;
- this.password = password;
- this.email = email;
- }
-
- @Override
- public boolean isRegistrationAdmitted() {
- ValidationResult passwordValidation = validationService.validatePassword(password, player.getName());
- if (passwordValidation.hasError()) {
- commonService.send(player, passwordValidation.getMessageKey(), passwordValidation.getArgs());
- return false;
- }
- return true;
- }
-
- @Override
- public PlayerAuth buildPlayerAuth() {
- hashedPassword = passwordSecurity.computeHash(password, player.getName().toLowerCase());
- return createPlayerAuth(player, hashedPassword, email);
- }
-
- protected boolean performLoginAfterRegister() {
- return !commonService.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER);
- }
-
- @Override
- public void executePostPersistAction() {
- if (performLoginAfterRegister()) {
- if (commonService.getProperty(PluginSettings.USE_ASYNC_TASKS)) {
- bukkitService.runTaskAsynchronously(() -> asynchronousLogin.forceLogin(player));
- } else {
- bukkitService.scheduleSyncDelayedTask(() -> asynchronousLogin.forceLogin(player), SYNC_LOGIN_DELAY);
- }
- }
- syncProcessManager.processSyncPasswordRegister(player);
- }
-
- protected Player getPlayer() {
- return player;
- }
-
- protected HashedPassword getHashedPassword() {
- return hashedPassword;
- }
- }
-
- /** Executor for password registration via API call. */
- class ApiPasswordRegisterExecutor extends PasswordRegisterExecutor {
-
- private final boolean loginAfterRegister;
-
- /**
- * Constructor.
- *
- * @param player the player to register
- * @param password the password to register with
- * @param loginAfterRegister whether the user should be automatically logged in after registration
- */
- ApiPasswordRegisterExecutor(Player player, String password, boolean loginAfterRegister) {
- super(player, password, null);
- this.loginAfterRegister = loginAfterRegister;
- }
-
- @Override
- protected boolean performLoginAfterRegister() {
- return loginAfterRegister;
- }
- }
-
- /** Executor for two factor registration. */
- class TwoFactorRegisterExecutor extends PasswordRegisterExecutor {
-
- TwoFactorRegisterExecutor(Player player) {
- super(player, "", null);
- }
-
- @Override
- public boolean isRegistrationAdmitted() {
- // nothing to check
- return true;
- }
-
- @Override
- public void executePostPersistAction() {
- super.executePostPersistAction();
-
- String hash = getHashedPassword().getHash();
- String qrCodeUrl = TwoFactor.getQRBarcodeURL(getPlayer().getName(), Bukkit.getIp(), hash);
- commonService.send(getPlayer(), MessageKey.TWO_FACTOR_CREATE, hash, qrCodeUrl);
- }
-
- }
-}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterParams.java b/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterParams.java
new file mode 100644
index 000000000..f21861bff
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/PasswordRegisterParams.java
@@ -0,0 +1,32 @@
+package fr.xephi.authme.process.register.executors;
+
+import org.bukkit.entity.Player;
+
+/**
+ * Parameters for registration with a given password, and optionally an email address.
+ */
+public class PasswordRegisterParams extends AbstractPasswordRegisterParams {
+
+ private final String email;
+
+ protected PasswordRegisterParams(Player player, String password, String email) {
+ super(player, password);
+ this.email = email;
+ }
+
+ /**
+ * Creates a params object.
+ *
+ * @param player the player to register
+ * @param password the password to register with
+ * @param email the email of the player (may be null)
+ * @return params object with the given data
+ */
+ public static PasswordRegisterParams of(Player player, String password, String email) {
+ return new PasswordRegisterParams(player, password, email);
+ }
+
+ public String getEmail() {
+ return email;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java b/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java
index 1943b5d54..5d9ab8657 100644
--- a/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java
+++ b/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java
@@ -13,6 +13,14 @@ final class PlayerAuthBuilderHelper {
private PlayerAuthBuilderHelper() {
}
+ /**
+ * Creates a {@link PlayerAuth} object with the given data.
+ *
+ * @param player the player to create a PlayerAuth for
+ * @param hashedPassword the hashed password
+ * @param email the email address (nullable)
+ * @return the generated PlayerAuth object
+ */
static PlayerAuth createPlayerAuth(Player player, HashedPassword hashedPassword, String email) {
return PlayerAuth.builder()
.name(player.getName().toLowerCase())
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutor.java b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutor.java
index cceb5c18e..ad18bf924 100644
--- a/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutor.java
+++ b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutor.java
@@ -5,7 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
/**
* Performs the registration action.
*/
-public interface RegistrationExecutor {
+public interface RegistrationExecutor {
/**
* Returns whether the registration may take place. Use this method to execute
@@ -14,20 +14,24 @@ public interface RegistrationExecutor {
* If this method returns {@code false}, it is expected that the executor inform
* the player about the error within this method call.
*
+ * @param params the parameters for the registration
* @return true if registration may be performed, false otherwise
*/
- boolean isRegistrationAdmitted();
+ boolean isRegistrationAdmitted(P params);
/**
* Constructs the PlayerAuth object to persist into the database.
*
+ * @param params the parameters for the registration
* @return the player auth to register in the data source
*/
- PlayerAuth buildPlayerAuth();
+ PlayerAuth buildPlayerAuth(P params);
/**
* Follow-up method called after the player auth could be added into the database.
+ *
+ * @param params the parameters for the registration
*/
- void executePostPersistAction();
+ void executePostPersistAction(P params);
}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutorProvider.java b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutorProvider.java
deleted file mode 100644
index 286a51634..000000000
--- a/src/main/java/fr/xephi/authme/process/register/executors/RegistrationExecutorProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package fr.xephi.authme.process.register.executors;
-
-import org.bukkit.entity.Player;
-
-import javax.inject.Inject;
-
-/**
- * Provides a {@link RegistrationExecutor} for various registration methods.
- */
-public class RegistrationExecutorProvider {
-
- @Inject
- private PasswordRegisterExecutorProvider passwordRegisterExecutorProvider;
-
- @Inject
- private EmailRegisterExecutorProvider emailRegisterExecutorProvider;
-
- RegistrationExecutorProvider() {
- }
-
- public RegistrationExecutor getPasswordRegisterExecutor(Player player, String password, String email) {
- return passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, password, email);
- }
-
- public RegistrationExecutor getPasswordRegisterExecutor(Player player, String password, boolean loginAfterRegister) {
- return passwordRegisterExecutorProvider.new ApiPasswordRegisterExecutor(player, password, loginAfterRegister);
- }
-
- public RegistrationExecutor getTwoFactorRegisterExecutor(Player player) {
- return passwordRegisterExecutorProvider.new TwoFactorRegisterExecutor(player);
- }
-
- public RegistrationExecutor getEmailRegisterExecutor(Player player, String email) {
- return emailRegisterExecutorProvider.new EmailRegisterExecutor(player, email);
- }
-}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/RegistrationMethod.java b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationMethod.java
new file mode 100644
index 000000000..9232332ef
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationMethod.java
@@ -0,0 +1,51 @@
+package fr.xephi.authme.process.register.executors;
+
+/**
+ * Methods with which a player can be registered.
+ *
+ * These constants each define a different way of registering a player and define the
+ * {@link RegistrationParameters parameters} and {@link RegistrationExecutor executor}
+ * classes which perform this registration method. This is essentially a typed enum
+ * as passing a constant of this class along with a parameters object to a method can
+ * be restricted to the correct parameters type.
+ */
+public final class RegistrationMethod
{
+
+ /**
+ * Password registration.
+ */
+ public static final RegistrationMethod PASSWORD_REGISTRATION =
+ new RegistrationMethod<>(PasswordRegisterExecutor.class);
+
+ /**
+ * Registration with two-factor authentication as login means.
+ */
+ public static final RegistrationMethod TWO_FACTOR_REGISTRATION =
+ new RegistrationMethod<>(TwoFactorRegisterExecutor.class);
+
+ /**
+ * Email registration: an email address is provided, to which a generated password is sent.
+ */
+ public static final RegistrationMethod EMAIL_REGISTRATION =
+ new RegistrationMethod<>(EmailRegisterExecutor.class);
+
+ /**
+ * API registration: player and password are provided via an API method.
+ */
+ public static final RegistrationMethod API_REGISTRATION =
+ new RegistrationMethod<>(ApiPasswordRegisterExecutor.class);
+
+
+ private final Class extends RegistrationExecutor> executorClass;
+
+ private RegistrationMethod(Class extends RegistrationExecutor
> executorClass) {
+ this.executorClass = executorClass;
+ }
+
+ /**
+ * @return the executor class to perform the registration method
+ */
+ public Class extends RegistrationExecutor
> getExecutorClass() {
+ return executorClass;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/RegistrationParameters.java b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationParameters.java
new file mode 100644
index 000000000..c92d57ffa
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/RegistrationParameters.java
@@ -0,0 +1,28 @@
+package fr.xephi.authme.process.register.executors;
+
+import org.bukkit.entity.Player;
+
+/**
+ * Parent of all registration parameters.
+ */
+public abstract class RegistrationParameters {
+
+ private final Player player;
+
+ /**
+ * Constructor.
+ *
+ * @param player the player to perform the registration for
+ */
+ public RegistrationParameters(Player player) {
+ this.player = player;
+ }
+
+ public Player getPlayer() {
+ return player;
+ }
+
+ public String getPlayerName() {
+ return player.getName();
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/TwoFactorRegisterExecutor.java b/src/main/java/fr/xephi/authme/process/register/executors/TwoFactorRegisterExecutor.java
new file mode 100644
index 000000000..027a5fa68
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/TwoFactorRegisterExecutor.java
@@ -0,0 +1,43 @@
+package fr.xephi.authme.process.register.executors;
+
+import fr.xephi.authme.data.auth.PlayerAuth;
+import fr.xephi.authme.message.MessageKey;
+import fr.xephi.authme.security.crypts.TwoFactor;
+import fr.xephi.authme.service.CommonService;
+import org.bukkit.Bukkit;
+
+import javax.inject.Inject;
+
+import static fr.xephi.authme.process.register.executors.PlayerAuthBuilderHelper.createPlayerAuth;
+
+/**
+ * Executor for two-factor registration.
+ */
+class TwoFactorRegisterExecutor extends AbstractPasswordRegisterExecutor {
+
+ @Inject
+ private CommonService commonService;
+
+ @Override
+ public boolean isRegistrationAdmitted(TwoFactorRegisterParams params) {
+ // nothing to check
+ return true;
+ }
+
+ @Override
+ protected PlayerAuth createPlayerAuthObject(TwoFactorRegisterParams params) {
+ return createPlayerAuth(params.getPlayer(), params.getHashedPassword(), null);
+ }
+
+ @Override
+ public void executePostPersistAction(TwoFactorRegisterParams params) {
+ super.executePostPersistAction(params);
+
+ // Note ljacqu 20170317: This two-factor registration type is only invoked when the password hash is configured
+ // to two-factor authentication. Therefore, the hashed password is the result of the TwoFactor EncryptionMethod
+ // implementation (contains the TOTP secret).
+ String hash = params.getHashedPassword().getHash();
+ String qrCodeUrl = TwoFactor.getQRBarcodeURL(params.getPlayerName(), Bukkit.getIp(), hash);
+ commonService.send(params.getPlayer(), MessageKey.TWO_FACTOR_CREATE, hash, qrCodeUrl);
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/process/register/executors/TwoFactorRegisterParams.java b/src/main/java/fr/xephi/authme/process/register/executors/TwoFactorRegisterParams.java
new file mode 100644
index 000000000..a7a758750
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/process/register/executors/TwoFactorRegisterParams.java
@@ -0,0 +1,23 @@
+package fr.xephi.authme.process.register.executors;
+
+import org.bukkit.entity.Player;
+
+/**
+ * Parameters for registration with two-factor authentication.
+ */
+public class TwoFactorRegisterParams extends AbstractPasswordRegisterParams {
+
+ protected TwoFactorRegisterParams(Player player) {
+ super(player);
+ }
+
+ /**
+ * Creates a parameters object.
+ *
+ * @param player the player to register
+ * @return params object with the given player
+ */
+ public static TwoFactorRegisterParams of(Player player) {
+ return new TwoFactorRegisterParams(player);
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java
index 732582e03..f12da678d 100644
--- a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java
+++ b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java
@@ -7,36 +7,36 @@ import fr.xephi.authme.security.crypts.EncryptionMethod;
*/
public enum HashAlgorithm {
- BCRYPT(fr.xephi.authme.security.crypts.BCRYPT.class),
- BCRYPT2Y(fr.xephi.authme.security.crypts.BCRYPT2Y.class),
- CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class),
- DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class),
- IPB3(fr.xephi.authme.security.crypts.IPB3.class),
- IPB4(fr.xephi.authme.security.crypts.IPB4.class),
- JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class),
- MD5(fr.xephi.authme.security.crypts.MD5.class),
- MD5VB(fr.xephi.authme.security.crypts.MD5VB.class),
- MYBB(fr.xephi.authme.security.crypts.MYBB.class),
+ BCRYPT(fr.xephi.authme.security.crypts.BCrypt.class),
+ BCRYPT2Y(fr.xephi.authme.security.crypts.BCrypt2y.class),
+ CRAZYCRYPT1(fr.xephi.authme.security.crypts.CrazyCrypt1.class),
+ DOUBLEMD5(fr.xephi.authme.security.crypts.DoubleMd5.class),
+ IPB3(fr.xephi.authme.security.crypts.Ipb3.class),
+ IPB4(fr.xephi.authme.security.crypts.Ipb4.class),
+ JOOMLA(fr.xephi.authme.security.crypts.Joomla.class),
+ MD5(fr.xephi.authme.security.crypts.Md5.class),
+ MD5VB(fr.xephi.authme.security.crypts.Md5vB.class),
+ MYBB(fr.xephi.authme.security.crypts.MyBB.class),
PBKDF2(fr.xephi.authme.security.crypts.Pbkdf2.class),
PBKDF2DJANGO(fr.xephi.authme.security.crypts.Pbkdf2Django.class),
- PHPBB(fr.xephi.authme.security.crypts.PHPBB.class),
- PHPFUSION(fr.xephi.authme.security.crypts.PHPFUSION.class),
+ PHPBB(fr.xephi.authme.security.crypts.PhpBB.class),
+ PHPFUSION(fr.xephi.authme.security.crypts.PhpFusion.class),
@Deprecated
- PLAINTEXT(fr.xephi.authme.security.crypts.PLAINTEXT.class),
- ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class),
- SALTED2MD5(fr.xephi.authme.security.crypts.SALTED2MD5.class),
- SALTEDSHA512(fr.xephi.authme.security.crypts.SALTEDSHA512.class),
- SHA1(fr.xephi.authme.security.crypts.SHA1.class),
- SHA256(fr.xephi.authme.security.crypts.SHA256.class),
- SHA512(fr.xephi.authme.security.crypts.SHA512.class),
- SMF(fr.xephi.authme.security.crypts.SMF.class),
+ PLAINTEXT(fr.xephi.authme.security.crypts.PlainText.class),
+ ROYALAUTH(fr.xephi.authme.security.crypts.RoyalAuth.class),
+ SALTED2MD5(fr.xephi.authme.security.crypts.Salted2Md5.class),
+ SALTEDSHA512(fr.xephi.authme.security.crypts.SaltedSha512.class),
+ SHA1(fr.xephi.authme.security.crypts.Sha1.class),
+ SHA256(fr.xephi.authme.security.crypts.Sha256.class),
+ SHA512(fr.xephi.authme.security.crypts.Sha512.class),
+ SMF(fr.xephi.authme.security.crypts.Smf.class),
TWO_FACTOR(fr.xephi.authme.security.crypts.TwoFactor.class),
- WBB3(fr.xephi.authme.security.crypts.WBB3.class),
- WBB4(fr.xephi.authme.security.crypts.WBB4.class),
- WHIRLPOOL(fr.xephi.authme.security.crypts.WHIRLPOOL.class),
- WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class),
- XAUTH(fr.xephi.authme.security.crypts.XAUTH.class),
- XFBCRYPT(fr.xephi.authme.security.crypts.XFBCRYPT.class),
+ WBB3(fr.xephi.authme.security.crypts.Wbb3.class),
+ WBB4(fr.xephi.authme.security.crypts.Wbb4.class),
+ WHIRLPOOL(fr.xephi.authme.security.crypts.Whirlpool.class),
+ WORDPRESS(fr.xephi.authme.security.crypts.Wordpress.class),
+ XAUTH(fr.xephi.authme.security.crypts.XAuth.class),
+ XFBCRYPT(fr.xephi.authme.security.crypts.XfBCrypt.class),
CUSTOM(null);
private final Class extends EncryptionMethod> clazz;
diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java b/src/main/java/fr/xephi/authme/security/crypts/BCrypt.java
similarity index 95%
rename from src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java
rename to src/main/java/fr/xephi/authme/security/crypts/BCrypt.java
index aae6b9109..02e12d459 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/BCrypt.java
@@ -14,12 +14,12 @@ import javax.inject.Inject;
@Recommendation(Usage.RECOMMENDED) // provided the salt length is >= 8
@HasSalt(value = SaltType.TEXT) // length depends on the bcryptLog2Rounds setting
-public class BCRYPT implements EncryptionMethod {
+public class BCrypt implements EncryptionMethod {
private final int bCryptLog2Rounds;
@Inject
- public BCRYPT(Settings settings) {
+ public BCrypt(Settings settings) {
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java b/src/main/java/fr/xephi/authme/security/crypts/BCrypt2y.java
similarity index 95%
rename from src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java
rename to src/main/java/fr/xephi/authme/security/crypts/BCrypt2y.java
index 49bd45f8a..cf4807abc 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/BCrypt2y.java
@@ -4,7 +4,7 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.RECOMMENDED)
-public class BCRYPT2Y extends HexSaltedMethod {
+public class BCrypt2y extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java b/src/main/java/fr/xephi/authme/security/crypts/CrazyCrypt1.java
similarity index 95%
rename from src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java
rename to src/main/java/fr/xephi/authme/security/crypts/CrazyCrypt1.java
index 595842314..6130c6a12 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/CrazyCrypt1.java
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.MessageDigestAlgorithm;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
-public class CRAZYCRYPT1 extends UsernameSaltMethod {
+public class CrazyCrypt1 extends UsernameSaltMethod {
private static final char[] CRYPTCHARS =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
diff --git a/src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java b/src/main/java/fr/xephi/authme/security/crypts/DoubleMd5.java
similarity index 81%
rename from src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
rename to src/main/java/fr/xephi/authme/security/crypts/DoubleMd5.java
index b7823a2b4..c28e0440a 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/DoubleMd5.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import static fr.xephi.authme.security.HashUtils.md5;
-public class DOUBLEMD5 extends UnsaltedMethod {
+public class DoubleMd5 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB3.java b/src/main/java/fr/xephi/authme/security/crypts/Ipb3.java
similarity index 93%
rename from src/main/java/fr/xephi/authme/security/crypts/IPB3.java
rename to src/main/java/fr/xephi/authme/security/crypts/Ipb3.java
index a4e62461c..15dcd189b 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/IPB3.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Ipb3.java
@@ -10,7 +10,7 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 5)
-public class IPB3 extends SeparateSaltMethod {
+public class Ipb3 extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/Ipb4.java
similarity index 91%
rename from src/main/java/fr/xephi/authme/security/crypts/IPB4.java
rename to src/main/java/fr/xephi/authme/security/crypts/Ipb4.java
index 40ea75166..762897955 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Ipb4.java
@@ -11,15 +11,15 @@ import fr.xephi.authme.util.StringUtils;
/**
- * Implementation for IPB4 (Invision Power Board 4).
+ * Implementation for Ipb4 (Invision Power Board 4).
*
* The hash uses standard BCrypt with 13 as log2 number of rounds. Additionally,
- * IPB4 requires that the salt be stored additionally in the column "members_pass_hash"
+ * Ipb4 requires that the salt be stored additionally in the column "members_pass_hash"
* (even though BCrypt hashes already have the salt in the result).
*/
@Recommendation(Usage.DOES_NOT_WORK)
@HasSalt(value = SaltType.TEXT, length = 22)
-public class IPB4 implements EncryptionMethod {
+public class Ipb4 implements EncryptionMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java b/src/main/java/fr/xephi/authme/security/crypts/Joomla.java
similarity index 94%
rename from src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
rename to src/main/java/fr/xephi/authme/security/crypts/Joomla.java
index ca72674b3..462f5cb28 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Joomla.java
@@ -5,7 +5,7 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.ACCEPTABLE)
-public class JOOMLA extends HexSaltedMethod {
+public class Joomla extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/MD5.java b/src/main/java/fr/xephi/authme/security/crypts/Md5.java
similarity index 82%
rename from src/main/java/fr/xephi/authme/security/crypts/MD5.java
rename to src/main/java/fr/xephi/authme/security/crypts/Md5.java
index 50bb7d97e..c2a2ba04a 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/MD5.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Md5.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
-public class MD5 extends UnsaltedMethod {
+public class Md5 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java b/src/main/java/fr/xephi/authme/security/crypts/Md5vB.java
similarity index 93%
rename from src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
rename to src/main/java/fr/xephi/authme/security/crypts/Md5vB.java
index f9c21ae7e..c244ec49d 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Md5vB.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import static fr.xephi.authme.security.HashUtils.md5;
-public class MD5VB extends HexSaltedMethod {
+public class Md5vB extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/MYBB.java b/src/main/java/fr/xephi/authme/security/crypts/MyBB.java
similarity index 93%
rename from src/main/java/fr/xephi/authme/security/crypts/MYBB.java
rename to src/main/java/fr/xephi/authme/security/crypts/MyBB.java
index b25f47695..3f0a477ab 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/MYBB.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/MyBB.java
@@ -10,7 +10,7 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 8)
-public class MYBB extends SeparateSaltMethod {
+public class MyBB extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java b/src/main/java/fr/xephi/authme/security/crypts/PhpBB.java
similarity index 99%
rename from src/main/java/fr/xephi/authme/security/crypts/PHPBB.java
rename to src/main/java/fr/xephi/authme/security/crypts/PhpBB.java
index 074143fd6..e5f7e54ca 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/PhpBB.java
@@ -9,7 +9,7 @@ import java.security.MessageDigest;
/**
* @author stefano
*/
-public class PHPBB extends HexSaltedMethod {
+public class PhpBB extends HexSaltedMethod {
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java b/src/main/java/fr/xephi/authme/security/crypts/PhpFusion.java
similarity index 96%
rename from src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
rename to src/main/java/fr/xephi/authme/security/crypts/PhpFusion.java
index 905798ec3..5a49ed4ce 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/PhpFusion.java
@@ -14,7 +14,7 @@ import java.security.NoSuchAlgorithmException;
@Recommendation(Usage.DO_NOT_USE)
@AsciiRestricted
-public class PHPFUSION extends SeparateSaltMethod {
+public class PhpFusion extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java b/src/main/java/fr/xephi/authme/security/crypts/PlainText.java
similarity index 85%
rename from src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java
rename to src/main/java/fr/xephi/authme/security/crypts/PlainText.java
index a294ca917..add333d69 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/PlainText.java
@@ -6,7 +6,7 @@ package fr.xephi.authme.security.crypts;
* @deprecated Using this is no longer supported. AuthMe will migrate to SHA256 on startup.
*/
@Deprecated
-public class PLAINTEXT extends UnsaltedMethod {
+public class PlainText extends UnsaltedMethod {
@Override
public String computeHash(String password) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java b/src/main/java/fr/xephi/authme/security/crypts/RoyalAuth.java
similarity index 88%
rename from src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java
rename to src/main/java/fr/xephi/authme/security/crypts/RoyalAuth.java
index db089e360..989ef8383 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/RoyalAuth.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
-public class ROYALAUTH extends UnsaltedMethod {
+public class RoyalAuth extends UnsaltedMethod {
@Override
public String computeHash(String password) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java b/src/main/java/fr/xephi/authme/security/crypts/Salted2Md5.java
similarity index 91%
rename from src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java
rename to src/main/java/fr/xephi/authme/security/crypts/Salted2Md5.java
index b2f22ab9b..6d708b3ce 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Salted2Md5.java
@@ -14,12 +14,12 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE) // presuming that length is something sensible (>= 8)
@HasSalt(value = SaltType.TEXT) // length defined by the doubleMd5SaltLength setting
-public class SALTED2MD5 extends SeparateSaltMethod {
+public class Salted2Md5 extends SeparateSaltMethod {
private final int saltLength;
@Inject
- public SALTED2MD5(Settings settings) {
+ public Salted2Md5(Settings settings) {
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java b/src/main/java/fr/xephi/authme/security/crypts/SaltedSha512.java
similarity index 90%
rename from src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java
rename to src/main/java/fr/xephi/authme/security/crypts/SaltedSha512.java
index f0f293439..b5660d658 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/SaltedSha512.java
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.RECOMMENDED)
-public class SALTEDSHA512 extends SeparateSaltMethod {
+public class SaltedSha512 extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA1.java b/src/main/java/fr/xephi/authme/security/crypts/Sha1.java
similarity index 82%
rename from src/main/java/fr/xephi/authme/security/crypts/SHA1.java
rename to src/main/java/fr/xephi/authme/security/crypts/Sha1.java
index 080910ec7..e3d078e7e 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SHA1.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Sha1.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
-public class SHA1 extends UnsaltedMethod {
+public class Sha1 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA256.java b/src/main/java/fr/xephi/authme/security/crypts/Sha256.java
similarity index 94%
rename from src/main/java/fr/xephi/authme/security/crypts/SHA256.java
rename to src/main/java/fr/xephi/authme/security/crypts/Sha256.java
index ee55d4512..1b77a2e44 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SHA256.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Sha256.java
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.crypts.description.Usage;
import static fr.xephi.authme.security.HashUtils.sha256;
@Recommendation(Usage.RECOMMENDED)
-public class SHA256 extends HexSaltedMethod {
+public class Sha256 extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA512.java b/src/main/java/fr/xephi/authme/security/crypts/Sha512.java
similarity index 81%
rename from src/main/java/fr/xephi/authme/security/crypts/SHA512.java
rename to src/main/java/fr/xephi/authme/security/crypts/Sha512.java
index 81f1e0263..12e51a315 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SHA512.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Sha512.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
-public class SHA512 extends UnsaltedMethod {
+public class Sha512 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SMF.java b/src/main/java/fr/xephi/authme/security/crypts/Smf.java
similarity index 85%
rename from src/main/java/fr/xephi/authme/security/crypts/SMF.java
rename to src/main/java/fr/xephi/authme/security/crypts/Smf.java
index 175efc3fa..46114d2e9 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SMF.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Smf.java
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
-public class SMF extends UsernameSaltMethod {
+public class Smf extends UsernameSaltMethod {
@Override
public HashedPassword computeHash(String password, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WBB3.java b/src/main/java/fr/xephi/authme/security/crypts/Wbb3.java
similarity index 94%
rename from src/main/java/fr/xephi/authme/security/crypts/WBB3.java
rename to src/main/java/fr/xephi/authme/security/crypts/Wbb3.java
index 546c2dc87..0a042b489 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WBB3.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Wbb3.java
@@ -10,7 +10,7 @@ import static fr.xephi.authme.security.HashUtils.sha1;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 40)
-public class WBB3 extends SeparateSaltMethod {
+public class Wbb3 extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WBB4.java b/src/main/java/fr/xephi/authme/security/crypts/Wbb4.java
similarity index 96%
rename from src/main/java/fr/xephi/authme/security/crypts/WBB4.java
rename to src/main/java/fr/xephi/authme/security/crypts/Wbb4.java
index a81503374..d1d4953d1 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WBB4.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Wbb4.java
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.crypts.description.Usage;
import static fr.xephi.authme.security.crypts.BCryptService.hashpw;
@Recommendation(Usage.RECOMMENDED)
-public class WBB4 extends HexSaltedMethod {
+public class Wbb4 extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java b/src/main/java/fr/xephi/authme/security/crypts/Whirlpool.java
similarity index 99%
rename from src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java
rename to src/main/java/fr/xephi/authme/security/crypts/Whirlpool.java
index 72d8e8fb6..84efae8e8 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Whirlpool.java
@@ -61,7 +61,7 @@ package fr.xephi.authme.security.crypts;
import java.util.Arrays;
-public class WHIRLPOOL extends UnsaltedMethod {
+public class Whirlpool extends UnsaltedMethod {
/**
* The message digest size (in bits)
@@ -158,7 +158,7 @@ public class WHIRLPOOL extends UnsaltedMethod {
protected final long[] block = new long[8];
protected final long[] state = new long[8];
- public WHIRLPOOL() {
+ public Whirlpool() {
}
protected static String display(byte[] array) {
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java b/src/main/java/fr/xephi/authme/security/crypts/Wordpress.java
similarity index 98%
rename from src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
rename to src/main/java/fr/xephi/authme/security/crypts/Wordpress.java
index f331d1fc6..768b92c5d 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/Wordpress.java
@@ -16,7 +16,7 @@ import java.util.Arrays;
@HasSalt(value = SaltType.TEXT, length = 9)
// Note ljacqu 20151228: Wordpress is actually a salted algorithm but salt generation is handled internally
// and isn't exposed to the outside, so we treat it as an unsalted implementation
-public class WORDPRESS extends UnsaltedMethod {
+public class Wordpress extends UnsaltedMethod {
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private final SecureRandom randomGen = new SecureRandom();
diff --git a/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java b/src/main/java/fr/xephi/authme/security/crypts/XAuth.java
similarity index 87%
rename from src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
rename to src/main/java/fr/xephi/authme/security/crypts/XAuth.java
index f2ebf1976..9f921b6ae 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/XAuth.java
@@ -4,15 +4,15 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.RECOMMENDED)
-public class XAUTH extends HexSaltedMethod {
+public class XAuth extends HexSaltedMethod {
private static String getWhirlpool(String message) {
- WHIRLPOOL w = new WHIRLPOOL();
- byte[] digest = new byte[WHIRLPOOL.DIGESTBYTES];
+ Whirlpool w = new Whirlpool();
+ byte[] digest = new byte[Whirlpool.DIGESTBYTES];
w.NESSIEinit();
w.NESSIEadd(message);
w.NESSIEfinalize(digest);
- return WHIRLPOOL.display(digest);
+ return Whirlpool.display(digest);
}
@Override
diff --git a/src/main/java/fr/xephi/authme/security/crypts/XFBCRYPT.java b/src/main/java/fr/xephi/authme/security/crypts/XfBCrypt.java
similarity index 97%
rename from src/main/java/fr/xephi/authme/security/crypts/XFBCRYPT.java
rename to src/main/java/fr/xephi/authme/security/crypts/XfBCrypt.java
index a20ee65aa..bf5545290 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/XFBCRYPT.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/XfBCrypt.java
@@ -7,7 +7,7 @@ import fr.xephi.authme.util.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-public class XFBCRYPT implements EncryptionMethod {
+public class XfBCrypt implements EncryptionMethod {
public static final String SCHEME_CLASS = "XenForo_Authentication_Core12";
private static final Pattern HASH_PATTERN = Pattern.compile("\"hash\";s.*\"(.*)?\"");
diff --git a/src/main/java/fr/xephi/authme/service/MigrationService.java b/src/main/java/fr/xephi/authme/service/MigrationService.java
index 043de8988..338ef51a1 100644
--- a/src/main/java/fr/xephi/authme/service/MigrationService.java
+++ b/src/main/java/fr/xephi/authme/service/MigrationService.java
@@ -5,7 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
-import fr.xephi.authme.security.crypts.SHA256;
+import fr.xephi.authme.security.crypts.Sha256;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@@ -20,14 +20,14 @@ public final class MigrationService {
}
/**
- * Hash all passwords to SHA256 and updated the setting if the password hash is set to the deprecated PLAINTEXT.
+ * Hash all passwords to Sha256 and updated the setting if the password hash is set to the deprecated PLAINTEXT.
*
* @param settings The settings instance
* @param dataSource The data source
- * @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
+ * @param authmeSha256 Instance to the AuthMe Sha256 encryption method implementation
*/
public static void changePlainTextToSha256(Settings settings, DataSource dataSource,
- SHA256 authmeSha256) {
+ Sha256 authmeSha256) {
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
ConsoleLogger.warning("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
+ " it will be changed and hashed now to the AuthMe default hashing method");
diff --git a/src/main/resources/messages/messages_zhcn.yml b/src/main/resources/messages/messages_zhcn.yml
index 63922334d..65f3fe161 100644
--- a/src/main/resources/messages/messages_zhcn.yml
+++ b/src/main/resources/messages/messages_zhcn.yml
@@ -87,7 +87,7 @@ email_send_failure: '邮件发送失败,请联系管理员'
show_no_email: '&2您当前并没有任何邮箱与该账号绑定'
add_email: '&8[&6玩家系统&8] &c请输入“/email add <你的邮箱> <再输入一次以确认>”以把你的邮箱添加到此帐号'
recovery_email: '&8[&6玩家系统&8] &c忘了你的密码?请输入:“/email recovery <你的邮箱>”'
-# TODO email_cooldown_error: '&cAn email was already sent recently. You must wait %time before you can send a new one.'
+email_cooldown_error: '&c邮件已在几分钟前发送,您需要等待 %time 后才能再次请求发送'
# Captcha
usage_captcha: '&8[&6玩家系统&8] &c正确用法:/captcha '
@@ -95,11 +95,11 @@ wrong_captcha: '&8[&6玩家系统&8] &c错误的验证码,请输入:“/capt
valid_captcha: '&8[&6玩家系统&8] &c你的验证码是有效的!'
# Time units
-# TODO second: 'second'
-# TODO seconds: 'seconds'
-# TODO minute: 'minute'
-# TODO minutes: 'minutes'
-# TODO hour: 'hour'
-# TODO hours: 'hours'
-# TODO day: 'day'
-# TODO days: 'days'
+second: '秒'
+seconds: '秒'
+minute: '分钟'
+minutes: '分钟'
+hour: '小时'
+hours: '小时'
+day: '天'
+days: '天'
diff --git a/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java b/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java
index 89132fcfa..f11d7311a 100644
--- a/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java
+++ b/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java
@@ -9,6 +9,7 @@ import fr.xephi.authme.command.CommandHandler;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.initialization.factory.FactoryDependencyHandler;
+import fr.xephi.authme.initialization.factory.SingletonStoreDependencyHandler;
import fr.xephi.authme.listener.BlockListener;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.process.Management;
@@ -93,7 +94,7 @@ public class AuthMeInitializationTest {
new Settings(dataFolder, mock(PropertyResource.class), null, buildConfigurationData());
Injector injector = new InjectorBuilder()
- .addHandlers(new FactoryDependencyHandler())
+ .addHandlers(new FactoryDependencyHandler(), new SingletonStoreDependencyHandler())
.addDefaultHandlers("fr.xephi.authme")
.create();
injector.provide(DataFolder.class, dataFolder);
diff --git a/src/test/java/fr/xephi/authme/ReflectionTestUtils.java b/src/test/java/fr/xephi/authme/ReflectionTestUtils.java
index bc0876669..bdae313ac 100644
--- a/src/test/java/fr/xephi/authme/ReflectionTestUtils.java
+++ b/src/test/java/fr/xephi/authme/ReflectionTestUtils.java
@@ -25,7 +25,7 @@ public final class ReflectionTestUtils {
*/
public static void setField(Class clazz, T instance, String fieldName, Object value) {
try {
- Field field = getField(clazz, instance, fieldName);
+ Field field = getField(clazz, fieldName);
field.set(instance, value);
} catch (IllegalAccessException e) {
throw new UnsupportedOperationException(
@@ -34,24 +34,30 @@ public final class ReflectionTestUtils {
}
}
- private static Field getField(Class clazz, T instance, String fieldName) {
+ private static Field getField(Class clazz, String fieldName) {
try {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field;
} catch (NoSuchFieldException e) {
- throw new UnsupportedOperationException(format("Could not get field '%s' for instance '%s' of class '%s'",
- fieldName, instance, clazz.getName()), e);
+ throw new UnsupportedOperationException(format("Could not get field '%s' from class '%s'",
+ fieldName, clazz.getName()), e);
}
}
@SuppressWarnings("unchecked")
public static V getFieldValue(Class clazz, T instance, String fieldName) {
- Field field = getField(clazz, instance, fieldName);
+ Field field = getField(clazz, fieldName);
+ return getFieldValue(field, instance);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static V getFieldValue(Field field, Object instance) {
+ field.setAccessible(true);
try {
return (V) field.get(instance);
} catch (IllegalAccessException e) {
- throw new UnsupportedOperationException("Could not get value of field '" + fieldName + "'", e);
+ throw new UnsupportedOperationException("Could not get value of field '" + field.getName() + "'", e);
}
}
diff --git a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java
index c87252e1c..6224a6065 100644
--- a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java
+++ b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java
@@ -1,13 +1,17 @@
package fr.xephi.authme.command.executable.register;
+import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.mail.EmailService;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.process.register.RegisterSecondaryArgument;
import fr.xephi.authme.process.register.RegistrationType;
-import fr.xephi.authme.process.register.executors.RegistrationExecutor;
-import fr.xephi.authme.process.register.executors.RegistrationExecutorProvider;
+import fr.xephi.authme.process.register.executors.EmailRegisterParams;
+import fr.xephi.authme.process.register.executors.PasswordRegisterParams;
+import fr.xephi.authme.process.register.executors.RegistrationMethod;
+import fr.xephi.authme.process.register.executors.RegistrationParameters;
+import fr.xephi.authme.process.register.executors.TwoFactorRegisterParams;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
@@ -16,6 +20,9 @@ import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -24,10 +31,16 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
@@ -57,9 +70,6 @@ public class RegisterCommandTest {
@Mock
private ValidationService validationService;
- @Mock
- private RegistrationExecutorProvider registrationExecutorProvider;
-
@BeforeClass
public static void setup() {
TestHelper.setupLogger();
@@ -90,14 +100,13 @@ public class RegisterCommandTest {
// given
given(commonService.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.TWO_FACTOR);
Player player = mock(Player.class);
- RegistrationExecutor executor = mock(RegistrationExecutor.class);
- given(registrationExecutorProvider.getTwoFactorRegisterExecutor(player)).willReturn(executor);
// when
command.executeCommand(player, Collections.emptyList());
// then
- verify(management).performRegister(player, executor);
+ verify(management).performRegister(eq(RegistrationMethod.TWO_FACTOR_REGISTRATION),
+ argThat(isEqualTo(TwoFactorRegisterParams.of(player))));
verifyZeroInteractions(emailService);
}
@@ -208,8 +217,6 @@ public class RegisterCommandTest {
given(commonService.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT)).willReturn(RegisterSecondaryArgument.CONFIRMATION);
given(emailService.hasAllInformation()).willReturn(true);
Player player = mock(Player.class);
- RegistrationExecutor executor = mock(RegistrationExecutor.class);
- given(registrationExecutorProvider.getEmailRegisterExecutor(player, playerMail)).willReturn(executor);
// when
command.executeCommand(player, Arrays.asList(playerMail, playerMail));
@@ -217,7 +224,8 @@ public class RegisterCommandTest {
// then
verify(validationService).validateEmail(playerMail);
verify(emailService).hasAllInformation();
- verify(management).performRegister(player, executor);
+ verify(management).performRegister(eq(RegistrationMethod.EMAIL_REGISTRATION),
+ argThat(isEqualTo(EmailRegisterParams.of(player, playerMail))));
}
@Test
@@ -239,14 +247,13 @@ public class RegisterCommandTest {
public void shouldPerformPasswordRegistration() {
// given
Player player = mock(Player.class);
- RegistrationExecutor executor = mock(RegistrationExecutor.class);
- given(registrationExecutorProvider.getPasswordRegisterExecutor(player, "myPass", null)).willReturn(executor);
// when
command.executeCommand(player, Collections.singletonList("myPass"));
// then
- verify(management).performRegister(player, executor);
+ verify(management).performRegister(eq(RegistrationMethod.PASSWORD_REGISTRATION),
+ argThat(isEqualTo(PasswordRegisterParams.of(player, "myPass", null))));
}
@Test
@@ -257,15 +264,14 @@ public class RegisterCommandTest {
String email = "email@example.org";
given(validationService.validateEmail(email)).willReturn(true);
Player player = mock(Player.class);
- RegistrationExecutor executor = mock(RegistrationExecutor.class);
- given(registrationExecutorProvider.getPasswordRegisterExecutor(player, "myPass", email)).willReturn(executor);
// when
command.executeCommand(player, Arrays.asList("myPass", email));
// then
verify(validationService).validateEmail(email);
- verify(management).performRegister(player, executor);
+ verify(management).performRegister(eq(RegistrationMethod.PASSWORD_REGISTRATION),
+ argThat(isEqualTo(PasswordRegisterParams.of(player, "myPass", email))));
}
@Test
@@ -292,14 +298,64 @@ public class RegisterCommandTest {
given(commonService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationType.PASSWORD);
given(commonService.getProperty(RegistrationSettings.REGISTER_SECOND_ARGUMENT)).willReturn(RegisterSecondaryArgument.EMAIL_OPTIONAL);
Player player = mock(Player.class);
- RegistrationExecutor executor = mock(RegistrationExecutor.class);
- given(registrationExecutorProvider.getPasswordRegisterExecutor(eq(player), anyString(), eq(null))).willReturn(executor);
// when
command.executeCommand(player, Collections.singletonList("myPass"));
// then
- verify(registrationExecutorProvider).getPasswordRegisterExecutor(player, "myPass", null);
- verify(management).performRegister(player, executor);
+ verify(management).performRegister(eq(RegistrationMethod.PASSWORD_REGISTRATION),
+ argThat(isEqualTo(PasswordRegisterParams.of(player, "myPass", null))));
+ }
+
+
+ // TODO ljacqu 20170317: Document and extract as util
+
+ private static Matcher
isEqualTo(P expected) {
+ return new TypeSafeMatcher
() {
+ @Override
+ protected boolean matchesSafely(RegistrationParameters item) {
+ assertAreParamsEqual(expected, item);
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("parameters " + expected);
+ }
+ };
+ }
+
+ private static void assertAreParamsEqual(RegistrationParameters lhs, RegistrationParameters rhs) {
+ if (lhs.getClass() != rhs.getClass()) {
+ fail("Params classes don't match, got " + lhs.getClass().getSimpleName()
+ + " and " + rhs.getClass().getSimpleName());
+ }
+
+ List fieldsToCheck = getFields(lhs);
+ for (Field field : fieldsToCheck) {
+ Object lhsValue = ReflectionTestUtils.getFieldValue(field, lhs);
+ Object rhsValue = ReflectionTestUtils.getFieldValue(field, rhs);
+ if (!Objects.equals(lhsValue, rhsValue)) {
+ fail("Field '" + field.getName() + "' does not have same value: '"
+ + lhsValue + "' vs. '" + rhsValue + "'");
+ }
+ }
+ }
+
+ private static List getFields(RegistrationParameters params) {
+ List fields = new ArrayList<>();
+ Class> currentClass = params.getClass();
+ while (currentClass != null) {
+ for (Field f : currentClass.getDeclaredFields()) {
+ if (!Modifier.isStatic(f.getModifiers())) {
+ fields.add(f);
+ }
+ }
+ if (currentClass == RegistrationParameters.class) {
+ break;
+ }
+ currentClass = currentClass.getSuperclass();
+ }
+ return fields;
}
}
diff --git a/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java b/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java
index b845b8d59..dee3dc646 100644
--- a/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java
+++ b/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java
@@ -3,9 +3,13 @@ package fr.xephi.authme.process.register;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
+import fr.xephi.authme.initialization.factory.SingletonStore;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
+import fr.xephi.authme.process.register.executors.PasswordRegisterParams;
import fr.xephi.authme.process.register.executors.RegistrationExecutor;
+import fr.xephi.authme.process.register.executors.RegistrationMethod;
+import fr.xephi.authme.process.register.executors.TwoFactorRegisterParams;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
@@ -16,6 +20,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.only;
@@ -39,6 +44,8 @@ public class AsyncRegisterTest {
private CommonService commonService;
@Mock
private DataSource dataSource;
+ @Mock
+ private SingletonStore registrationExecutorStore;
@Test
public void shouldDetectAlreadyLoggedInPlayer() {
@@ -47,9 +54,10 @@ public class AsyncRegisterTest {
Player player = mockPlayerWithName(name);
given(playerCache.isAuthenticated(name)).willReturn(true);
RegistrationExecutor executor = mock(RegistrationExecutor.class);
+ singletonStoreWillReturn(registrationExecutorStore, executor);
// when
- asyncRegister.register(player, executor);
+ asyncRegister.register(RegistrationMethod.PASSWORD_REGISTRATION, PasswordRegisterParams.of(player, "abc", null));
// then
verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
@@ -64,9 +72,10 @@ public class AsyncRegisterTest {
given(playerCache.isAuthenticated(name)).willReturn(false);
given(commonService.getProperty(RegistrationSettings.IS_ENABLED)).willReturn(false);
RegistrationExecutor executor = mock(RegistrationExecutor.class);
+ singletonStoreWillReturn(registrationExecutorStore, executor);
// when
- asyncRegister.register(player, executor);
+ asyncRegister.register(RegistrationMethod.TWO_FACTOR_REGISTRATION, TwoFactorRegisterParams.of(player));
// then
verify(commonService).send(player, MessageKey.REGISTRATION_DISABLED);
@@ -82,9 +91,10 @@ public class AsyncRegisterTest {
given(commonService.getProperty(RegistrationSettings.IS_ENABLED)).willReturn(true);
given(dataSource.isAuthAvailable(name)).willReturn(true);
RegistrationExecutor executor = mock(RegistrationExecutor.class);
+ singletonStoreWillReturn(registrationExecutorStore, executor);
// when
- asyncRegister.register(player, executor);
+ asyncRegister.register(RegistrationMethod.TWO_FACTOR_REGISTRATION, TwoFactorRegisterParams.of(player));
// then
verify(commonService).send(player, MessageKey.NAME_ALREADY_REGISTERED);
@@ -93,6 +103,7 @@ public class AsyncRegisterTest {
}
@Test
+ @SuppressWarnings("unchecked")
public void shouldStopForFailedExecutorCheck() {
// given
String name = "edbert";
@@ -103,14 +114,16 @@ public class AsyncRegisterTest {
given(commonService.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP)).willReturn(0);
given(dataSource.isAuthAvailable(name)).willReturn(false);
RegistrationExecutor executor = mock(RegistrationExecutor.class);
- given(executor.isRegistrationAdmitted()).willReturn(false);
+ TwoFactorRegisterParams params = TwoFactorRegisterParams.of(player);
+ given(executor.isRegistrationAdmitted(params)).willReturn(false);
+ singletonStoreWillReturn(registrationExecutorStore, executor);
// when
- asyncRegister.register(player, executor);
+ asyncRegister.register(RegistrationMethod.TWO_FACTOR_REGISTRATION, params);
// then
verify(dataSource, only()).isAuthAvailable(name);
- verify(executor, only()).isRegistrationAdmitted();
+ verify(executor, only()).isRegistrationAdmitted(params);
}
private static Player mockPlayerWithName(String name) {
@@ -118,4 +131,10 @@ public class AsyncRegisterTest {
given(player.getName()).willReturn(name);
return player;
}
+
+ @SuppressWarnings("unchecked")
+ private static void singletonStoreWillReturn(SingletonStore store,
+ RegistrationExecutor mock) {
+ given(store.getSingleton(any(Class.class))).willReturn(mock);
+ }
}
diff --git a/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProviderTest.java b/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProviderTest.java
index 9ca9c7aa8..6aa221611 100644
--- a/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProviderTest.java
+++ b/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorProviderTest.java
@@ -1,6 +1,5 @@
package fr.xephi.authme.process.register.executors;
-import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
@@ -34,13 +33,13 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
/**
- * Test for {@link EmailRegisterExecutorProvider}.
+ * Test for {@link EmailRegisterExecutor}.
*/
@RunWith(MockitoJUnitRunner.class)
public class EmailRegisterExecutorProviderTest {
@InjectMocks
- private EmailRegisterExecutorProvider emailRegisterExecutorProvider;
+ private EmailRegisterExecutor executor;
@Mock
private PermissionsManager permissionsManager;
@@ -62,10 +61,10 @@ public class EmailRegisterExecutorProviderTest {
String email = "test@example.com";
given(dataSource.countAuthsByEmail(email)).willReturn(4);
Player player = mock(Player.class);
- RegistrationExecutor executor = emailRegisterExecutorProvider.new EmailRegisterExecutor(player, email);
+ EmailRegisterParams params = EmailRegisterParams.of(player, email);
// when
- boolean result = executor.isRegistrationAdmitted();
+ boolean result = executor.isRegistrationAdmitted(params);
// then
assertThat(result, equalTo(false));
@@ -80,10 +79,10 @@ public class EmailRegisterExecutorProviderTest {
given(commonService.getProperty(EmailSettings.MAX_REG_PER_EMAIL)).willReturn(3);
Player player = mock(Player.class);
given(permissionsManager.hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)).willReturn(true);
- RegistrationExecutor executor = emailRegisterExecutorProvider.new EmailRegisterExecutor(player, "test@example.com");
+ EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com");
// when
- boolean result = executor.isRegistrationAdmitted();
+ boolean result = executor.isRegistrationAdmitted(params);
// then
assertThat(result, equalTo(true));
@@ -97,10 +96,10 @@ public class EmailRegisterExecutorProviderTest {
String email = "test@example.com";
given(dataSource.countAuthsByEmail(email)).willReturn(0);
Player player = mock(Player.class);
- RegistrationExecutor executor = emailRegisterExecutorProvider.new EmailRegisterExecutor(player, "test@example.com");
+ EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com");
// when
- boolean result = executor.isRegistrationAdmitted();
+ boolean result = executor.isRegistrationAdmitted(params);
// then
assertThat(result, equalTo(true));
@@ -120,10 +119,10 @@ public class EmailRegisterExecutorProviderTest {
World world = mock(World.class);
given(world.getName()).willReturn("someWorld");
given(player.getLocation()).willReturn(new Location(world, 48, 96, 144));
- RegistrationExecutor executor = emailRegisterExecutorProvider.new EmailRegisterExecutor(player, "test@example.com");
+ EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com");
// when
- PlayerAuth auth = executor.buildPlayerAuth();
+ PlayerAuth auth = executor.buildPlayerAuth(params);
// then
assertThat(auth, hasAuthBasicData("veronica", "Veronica", "test@example.com", "123.45.67.89"));
@@ -132,18 +131,17 @@ public class EmailRegisterExecutorProviderTest {
}
@Test
- @SuppressWarnings("unchecked")
public void shouldPerformActionAfterDataSourceSave() {
// given
given(emailService.sendPasswordMail(anyString(), anyString(), anyString())).willReturn(true);
Player player = mock(Player.class);
given(player.getName()).willReturn("Laleh");
- RegistrationExecutor executor = emailRegisterExecutorProvider.new EmailRegisterExecutor(player, "test@example.com");
+ EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com");
String password = "A892C#@";
- ReflectionTestUtils.setField((Class) executor.getClass(), executor, "password", password);
+ params.setPassword(password);
// when
- executor.executePostPersistAction();
+ executor.executePostPersistAction(params);
// then
verify(emailService).sendPasswordMail("Laleh", "test@example.com", password);
@@ -151,18 +149,17 @@ public class EmailRegisterExecutorProviderTest {
}
@Test
- @SuppressWarnings("unchecked")
public void shouldHandleEmailSendingFailure() {
// given
given(emailService.sendPasswordMail(anyString(), anyString(), anyString())).willReturn(false);
Player player = mock(Player.class);
given(player.getName()).willReturn("Laleh");
- RegistrationExecutor executor = emailRegisterExecutorProvider.new EmailRegisterExecutor(player, "test@example.com");
+ EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com");
String password = "A892C#@";
- ReflectionTestUtils.setField((Class) executor.getClass(), executor, "password", password);
+ params.setPassword(password);
// when
- executor.executePostPersistAction();
+ executor.executePostPersistAction(params);
// then
verify(emailService).sendPasswordMail("Laleh", "test@example.com", password);
diff --git a/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorProviderTest.java b/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java
similarity index 81%
rename from src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorProviderTest.java
rename to src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java
index a033975f6..6c103944b 100644
--- a/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorProviderTest.java
+++ b/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java
@@ -34,13 +34,13 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
/**
- * Test for {@link PasswordRegisterExecutorProvider}.
+ * Test for {@link PasswordRegisterExecutor}.
*/
@RunWith(MockitoJUnitRunner.class)
-public class PasswordRegisterExecutorProviderTest {
+public class PasswordRegisterExecutorTest {
@InjectMocks
- private PasswordRegisterExecutorProvider passwordRegisterExecutorProvider;
+ private PasswordRegisterExecutor executor;
@Mock
private ValidationService validationService;
@@ -62,10 +62,10 @@ public class PasswordRegisterExecutorProviderTest {
String name = "player040";
given(validationService.validatePassword(password, name)).willReturn(new ValidationResult());
Player player = mockPlayerWithName(name);
- RegistrationExecutor executor = passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, password, null);
+ PasswordRegisterParams params = PasswordRegisterParams.of(player, password, null);
// when
- boolean result = executor.isRegistrationAdmitted();
+ boolean result = executor.isRegistrationAdmitted(params);
// then
assertThat(result, equalTo(true));
@@ -80,10 +80,10 @@ public class PasswordRegisterExecutorProviderTest {
given(validationService.validatePassword(password, name)).willReturn(
new ValidationResult(MessageKey.PASSWORD_CHARACTERS_ERROR, "[a-z]"));
Player player = mockPlayerWithName(name);
- RegistrationExecutor executor = passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, password, null);
+ PasswordRegisterParams params = PasswordRegisterParams.of(player, password, null);
// when
- boolean result = executor.isRegistrationAdmitted();
+ boolean result = executor.isRegistrationAdmitted(params);
// then
assertThat(result, equalTo(false));
@@ -101,10 +101,10 @@ public class PasswordRegisterExecutorProviderTest {
World world = mock(World.class);
given(world.getName()).willReturn("someWorld");
given(player.getLocation()).willReturn(new Location(world, 48, 96, 144));
- RegistrationExecutor executor = passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, "pass", "mail@example.org");
+ PasswordRegisterParams params = PasswordRegisterParams.of(player, "pass", "mail@example.org");
// when
- PlayerAuth auth = executor.buildPlayerAuth();
+ PlayerAuth auth = executor.buildPlayerAuth(params);
// then
assertThat(auth, hasAuthBasicData("s1m0n", "S1m0N", "mail@example.org", "123.45.67.89"));
@@ -118,10 +118,10 @@ public class PasswordRegisterExecutorProviderTest {
given(commonService.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER)).willReturn(false);
given(commonService.getProperty(PluginSettings.USE_ASYNC_TASKS)).willReturn(false);
Player player = mock(Player.class);
- RegistrationExecutor executor = passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, "pass", "mail@example.org");
+ PasswordRegisterParams params = PasswordRegisterParams.of(player, "pass", "mail@example.org");
// when
- executor.executePostPersistAction();
+ executor.executePostPersistAction(params);
// then
TestHelper.runSyncDelayedTaskWithDelay(bukkitService);
@@ -134,10 +134,10 @@ public class PasswordRegisterExecutorProviderTest {
// given
given(commonService.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER)).willReturn(true);
Player player = mock(Player.class);
- RegistrationExecutor executor = passwordRegisterExecutorProvider.new PasswordRegisterExecutor(player, "pass", "mail@example.org");
+ PasswordRegisterParams params = PasswordRegisterParams.of(player, "pass", "mail@example.org");
// when
- executor.executePostPersistAction();
+ executor.executePostPersistAction(params);
// then
verifyZeroInteractions(bukkitService, asynchronousLogin);
diff --git a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java
index 04d2bc0bb..cebde5da6 100644
--- a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java
+++ b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java
@@ -9,7 +9,7 @@ import fr.xephi.authme.events.PasswordEncryptionEvent;
import fr.xephi.authme.initialization.factory.FactoryDependencyHandler;
import fr.xephi.authme.security.crypts.EncryptionMethod;
import fr.xephi.authme.security.crypts.HashedPassword;
-import fr.xephi.authme.security.crypts.JOOMLA;
+import fr.xephi.authme.security.crypts.Joomla;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@@ -231,7 +231,7 @@ public class PasswordSecurityTest {
ArgumentCaptor captor = ArgumentCaptor.forClass(PasswordEncryptionEvent.class);
verify(pluginManager).callEvent(captor.capture());
PasswordEncryptionEvent event = captor.getValue();
- assertThat(JOOMLA.class.equals(caughtClassInEvent), equalTo(true));
+ assertThat(Joomla.class.equals(caughtClassInEvent), equalTo(true));
assertThat(event.getPlayerName(), equalTo(usernameLowerCase));
}
diff --git a/src/test/java/fr/xephi/authme/security/crypts/BCRYPT2YTest.java b/src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java
similarity index 73%
rename from src/test/java/fr/xephi/authme/security/crypts/BCRYPT2YTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java
index ac34dea02..83308c9fc 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/BCRYPT2YTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link BCRYPT2Y}.
+ * Test for {@link BCrypt2y}.
*/
-public class BCRYPT2YTest extends AbstractEncryptionMethodTest {
+public class BCrypt2yTest extends AbstractEncryptionMethodTest {
- public BCRYPT2YTest() {
- super(new BCRYPT2Y(),
+ public BCrypt2yTest() {
+ super(new BCrypt2y(),
"$2y$10$da641e404b982edf1c7c0uTU9BcKzfA2vWKV05q6r.dCvm/93wqVK", // password
"$2y$10$e52c48a76f5b86f5da899uiK/HYocyPsfQXESNbP278rIz08LKEP2", // PassWord1
"$2y$10$be6f11548dc5fb4088410ONdC0dXnJ04y1RHcJh5fVF3XK5d.qgqK", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/BcryptTest.java b/src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java
similarity index 83%
rename from src/test/java/fr/xephi/authme/security/crypts/BcryptTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java
index 1fe9ed086..c2d9d6f5a 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/BcryptTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java
@@ -7,12 +7,12 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
- * Test for {@link BCRYPT}.
+ * Test for {@link BCrypt}.
*/
-public class BcryptTest extends AbstractEncryptionMethodTest {
+public class BCryptTest extends AbstractEncryptionMethodTest {
- public BcryptTest() {
- super(new BCRYPT(mockSettings()),
+ public BCryptTest() {
+ super(new BCrypt(mockSettings()),
"$2a$10$6iATmYgwJVc3YONhVcZFve3Cfb5GnwvKhJ20r.hMjmcNkIT9.Uh9K", // password
"$2a$10$LOhUxhEcS0vgDPv/jkXvCurNb7LjP9xUlEolJGk.Uhgikqc6FtIOi", // PassWord1
"$2a$10$j9da7SGiaakWhzIms9BtwemLUeIhSEphGUQ3XSlvYgpYsGnGCKRBa", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1Test.java b/src/test/java/fr/xephi/authme/security/crypts/CrazyCrypt1Test.java
similarity index 81%
rename from src/test/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/CrazyCrypt1Test.java
index fa27de3b1..f98ece5ab 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/CrazyCrypt1Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link CRAZYCRYPT1}.
+ * Test for {@link CrazyCrypt1}.
*/
-public class CRAZYCRYPT1Test extends AbstractEncryptionMethodTest {
+public class CrazyCrypt1Test extends AbstractEncryptionMethodTest {
- public CRAZYCRYPT1Test() {
- super(new CRAZYCRYPT1(),
+ public CrazyCrypt1Test() {
+ super(new CrazyCrypt1(),
"d5c76eb36417d4e97ec62609619e40a9e549a2598d0dab5a7194fd997a9305af78de2b93f958e150d19dd1e7f821043379ddf5f9c7f352bf27df91ae4913f3e8", // password
"49c63f827c88196871e344e589bd46cc4fa6db3c27801bbad5374c0d216381977627c1d76f2114667d5dd117e046f7493eb06e4f461f4f848aa08f6f40a3e934", // PassWord1
"6fefb0233bab6e6efb9c16f82cb0d8f569488905e2dae0e7c9dde700e7363da67213d37c44bc15f4a05854c9c21e5688389d416413c7309398aa96cb1f341d08", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/DOUBLEMD5Test.java b/src/test/java/fr/xephi/authme/security/crypts/DoubleMd5Test.java
similarity index 67%
rename from src/test/java/fr/xephi/authme/security/crypts/DOUBLEMD5Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/DoubleMd5Test.java
index 530399516..cc12df9e5 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/DOUBLEMD5Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/DoubleMd5Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link DOUBLEMD5}.
+ * Test for {@link DoubleMd5}.
*/
-public class DOUBLEMD5Test extends AbstractEncryptionMethodTest {
+public class DoubleMd5Test extends AbstractEncryptionMethodTest {
- public DOUBLEMD5Test() {
- super(new DOUBLEMD5(),
+ public DoubleMd5Test() {
+ super(new DoubleMd5(),
"696d29e0940a4957748fe3fc9efd22a3", // password
"c77aa2024d9fb7233a2872452d601aba", // PassWord1
"fbd5790af706ec19f8a7ef161878758b", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/IPB3Test.java b/src/test/java/fr/xephi/authme/security/crypts/Ipb3Test.java
similarity index 75%
rename from src/test/java/fr/xephi/authme/security/crypts/IPB3Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/Ipb3Test.java
index cf42567eb..984f3d217 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/IPB3Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Ipb3Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link IPB3}.
+ * Test for {@link Ipb3}.
*/
-public class IPB3Test extends AbstractEncryptionMethodTest {
+public class Ipb3Test extends AbstractEncryptionMethodTest {
- public IPB3Test() {
- super(new IPB3(),
+ public Ipb3Test() {
+ super(new Ipb3(),
new HashedPassword("f8ecea1ce42b5babef369ff7692dbe3f", "1715b"), //password
new HashedPassword("40a93731a931352e0619cdf09b975040", "ba91c"), //PassWord1
new HashedPassword("a77ca982373946d5800430bd2947ba11", "a7725"), //&^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java b/src/test/java/fr/xephi/authme/security/crypts/Ipb4Test.java
similarity index 81%
rename from src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/Ipb4Test.java
index 28c76a09f..5f71c23d7 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Ipb4Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link IPB4}.
+ * Test for {@link Ipb4}.
*/
-public class IPB4Test extends AbstractEncryptionMethodTest {
+public class Ipb4Test extends AbstractEncryptionMethodTest {
- public IPB4Test() {
- super(new IPB4(),
+ public Ipb4Test() {
+ super(new Ipb4(),
new HashedPassword("$2a$13$leEvXu77OIwPwNvtZIJvaeAx8EItGHuR3nIlq8416g0gXeJaQdrr2", "leEvXu77OIwPwNvtZIJval"), //password
new HashedPassword("$2a$13$xyTTP9zhQQtRRKIJPv5AuuOGJ6Ni9FLbDhcuIAcPjt3XzCxIWe3Uu", "xyTTP9zhQQtRRKIJPv5Au3"), //PassWord1
new HashedPassword("$2a$13$rGBrqErm9DZyzbxIGHlgf.xfA15/4d5Ay/TK.3y9lG3AljcoG9Lsi", "rGBrqErm9DZyzbxIGHlgfN"), //&^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/JoomlaTest.java b/src/test/java/fr/xephi/authme/security/crypts/JoomlaTest.java
index f46d51d83..d2673b34c 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/JoomlaTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/JoomlaTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link JOOMLA}.
+ * Test for {@link Joomla}.
*/
public class JoomlaTest extends AbstractEncryptionMethodTest {
public JoomlaTest() {
- super(new JOOMLA(),
+ super(new Joomla(),
"b18c99813cd96df3a706652f47177490:377c4aaf92c5ed57711306909e6065ca", // password
"c5af71da91a8841d95937ba24a5b7fdb:07068e5850930b794526a614438cafc7", // PassWord1
"f5fccd5166af7080833d7c7a6a531295:7cb6eeabcfac67ffe1341ec43375a9e6", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/Md5Test.java b/src/test/java/fr/xephi/authme/security/crypts/Md5Test.java
index 0c9d67cf1..c07918371 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/Md5Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Md5Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link MD5}.
+ * Test for {@link Md5}.
*/
public class Md5Test extends AbstractEncryptionMethodTest {
public Md5Test() {
- super(new MD5(),
+ super(new Md5(),
"5f4dcc3b5aa765d61d8327deb882cf99", // password
"f2126d405f46ed603ff5b2950f062c96", // PassWord1
"0833dcd2bc741f90c46bbac5498fd08f", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/MD5VBTest.java b/src/test/java/fr/xephi/authme/security/crypts/Md5vBTest.java
similarity index 74%
rename from src/test/java/fr/xephi/authme/security/crypts/MD5VBTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/Md5vBTest.java
index acb823e66..eac20fcd1 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/MD5VBTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Md5vBTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link MD5VB}.
+ * Test for {@link Md5vB}.
*/
-public class MD5VBTest extends AbstractEncryptionMethodTest {
+public class Md5vBTest extends AbstractEncryptionMethodTest {
- public MD5VBTest() {
- super(new MD5VB(),
+ public Md5vBTest() {
+ super(new Md5vB(),
"$MD5vb$bd9832fffa287321$5006d371fcb813f2347987f902a024ad", // password
"$MD5vb$5e492c1166b5a828$c954fa5ee561700a097826971653b57f", // PassWord1
"$MD5vb$3ec43cd46a61d70b$59687c0976f2e327b1245c8063f7008c", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/MYBBTest.java b/src/test/java/fr/xephi/authme/security/crypts/MyBBTest.java
similarity index 76%
rename from src/test/java/fr/xephi/authme/security/crypts/MYBBTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/MyBBTest.java
index 101f475ff..fabd9f35d 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/MYBBTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/MyBBTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link MYBB}.
+ * Test for {@link MyBB}.
*/
-public class MYBBTest extends AbstractEncryptionMethodTest {
+public class MyBBTest extends AbstractEncryptionMethodTest {
- public MYBBTest() {
- super(new MYBB(),
+ public MyBBTest() {
+ super(new MyBB(),
new HashedPassword("57c7a16d860833db5030738f5a465d2b", "acdc14e6"), //password
new HashedPassword("08fbdf721f2c42d9780b7d66df0ba830", "792fd7fb"), //PassWord1
new HashedPassword("d602f38fb59ad9e185d5604f5d4ddb36", "4b5534a4"), //&^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/PHPBBTest.java b/src/test/java/fr/xephi/authme/security/crypts/PhpBBTest.java
similarity index 69%
rename from src/test/java/fr/xephi/authme/security/crypts/PHPBBTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/PhpBBTest.java
index 61a423609..f495659ec 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/PHPBBTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/PhpBBTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link PHPBB}.
+ * Test for {@link PhpBB}.
*/
-public class PHPBBTest extends AbstractEncryptionMethodTest {
+public class PhpBBTest extends AbstractEncryptionMethodTest {
- public PHPBBTest() {
- super(new PHPBB(),
+ public PhpBBTest() {
+ super(new PhpBB(),
"$H$7MaSGQb0xe3Fp/a.Q.Ewpw.UKfCv.t0", // password
"$H$7ESfAVjzqajC7fJFcZKZIhyds41MuW.", // PassWord1
"$H$7G65SXRPbR69jLg.qZTjtqsw36Ciw7.", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/PHPFUSIONTest.java b/src/test/java/fr/xephi/authme/security/crypts/PhpFusionTest.java
similarity index 79%
rename from src/test/java/fr/xephi/authme/security/crypts/PHPFUSIONTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/PhpFusionTest.java
index 0b10c1c72..a08a6ad8c 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/PHPFUSIONTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/PhpFusionTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link PHPFUSION}.
+ * Test for {@link PhpFusion}.
*/
-public class PHPFUSIONTest extends AbstractEncryptionMethodTest {
+public class PhpFusionTest extends AbstractEncryptionMethodTest {
- public PHPFUSIONTest() {
- super(new PHPFUSION(),
+ public PhpFusionTest() {
+ super(new PhpFusion(),
new HashedPassword("f7a606c4eb3fcfbc382906476e05b06f21234a77d1a4eacc0f93f503deb69e70", "6cd1c97c55cb"), // password
new HashedPassword("8a9b7bb706a3347e5f684a7cb905bfb26b9a0d099358064139ab3ed1a66aeb2b", "d6012370b73f"), // PassWord1
new HashedPassword("43f2f23f44c8f89e2dbf06050bc8c77dbcdf71a7b5d28c87ec657d474e63d62d", "f75400a209a4"), // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/ROYALAUTHTest.java b/src/test/java/fr/xephi/authme/security/crypts/RoyalAuthTest.java
similarity index 81%
rename from src/test/java/fr/xephi/authme/security/crypts/ROYALAUTHTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/RoyalAuthTest.java
index 0de9c2f39..7734dc03a 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/ROYALAUTHTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/RoyalAuthTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link ROYALAUTH}.
+ * Test for {@link RoyalAuth}.
*/
-public class ROYALAUTHTest extends AbstractEncryptionMethodTest {
+public class RoyalAuthTest extends AbstractEncryptionMethodTest {
- public ROYALAUTHTest() {
- super(new ROYALAUTH(),
+ public RoyalAuthTest() {
+ super(new RoyalAuth(),
"5d21ef9236896bc4ac508e524e2da8a0def555dac1cdfc7259d62900d1d3f553826210c369870673ae2cf1c41abcf4f92670d76af1db044d33559324f5c2a339", // password
"ecc685f4328bc54093c086ced66c5c11855e117ea22940632d5c0f55fff84d94bfdcc74e05f5d95bbdd052823a7057910748bc1c7a07af96b3e86731a4f11794", // PassWord1
"2c0b4674f7c2c266db13ae4382cbeee3083167a774f6e73793a6268a0b8b2c3c6b324a99596f4a7958e58c5311c77e25975a3b517ce17adfc4eaece821e3dd19", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/SALTED2MD5Test.java b/src/test/java/fr/xephi/authme/security/crypts/Salted2Md5Test.java
similarity index 83%
rename from src/test/java/fr/xephi/authme/security/crypts/SALTED2MD5Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/Salted2Md5Test.java
index 20ec99fe8..fc34a13fc 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/SALTED2MD5Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Salted2Md5Test.java
@@ -7,12 +7,12 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
- * Test for {@link SALTED2MD5}.
+ * Test for {@link Salted2Md5}.
*/
-public class SALTED2MD5Test extends AbstractEncryptionMethodTest {
+public class Salted2Md5Test extends AbstractEncryptionMethodTest {
- public SALTED2MD5Test() {
- super(new SALTED2MD5(mockSettings()),
+ public Salted2Md5Test() {
+ super(new Salted2Md5(mockSettings()),
new HashedPassword("9f3d13dc01a6fe61fd669954174399f3", "9b5f5749"), // password
new HashedPassword("b28c32f624a4eb161d6adc9acb5bfc5b", "f750ba32"), // PassWord1
new HashedPassword("38dcb83cc68424afe3cda012700c2bb1", "eb2c3394"), // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/SALTEDSHA512Test.java b/src/test/java/fr/xephi/authme/security/crypts/SaltedSha512Test.java
similarity index 84%
rename from src/test/java/fr/xephi/authme/security/crypts/SALTEDSHA512Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/SaltedSha512Test.java
index 94cc78e82..98ab06153 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/SALTEDSHA512Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/SaltedSha512Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link SALTEDSHA512}.
+ * Test for {@link SaltedSha512}.
*/
-public class SALTEDSHA512Test extends AbstractEncryptionMethodTest {
+public class SaltedSha512Test extends AbstractEncryptionMethodTest {
- public SALTEDSHA512Test() {
- super(new SALTEDSHA512(),
+ public SaltedSha512Test() {
+ super(new SaltedSha512(),
new HashedPassword("dea7a37cecf5384ae8e347fd1411efb51364b6ba1b328695de3b354612c1d7010807e8b7051c40f740e498490e1f133e2c2408327d13fbdd68e1b1f6d548e624", "29f8a3c52147f987fee7ba3e0fb311bd"), // password
new HashedPassword("7c06225aac574d2dc7c81a2ed306637adf025715f52083e05bdab014faaa234e24a97d0e69ea0108dfa77cc9228e58be319ee677e679b5d1ad168d40e50a42f6", "8ea37b85d020b98f60c0fe9b8ec9296c"), // PassWord1
new HashedPassword("55711adbe03c9616f3505f0d57077fdd528c32243eb6f9840c1a6ff9e553940d6b89790750ebd52ebda63ca793fbe9980d54057af40836820c648750fe22d49c", "9f58079631ef21d32b4710694f1f461b"), // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/Sha1Test.java b/src/test/java/fr/xephi/authme/security/crypts/Sha1Test.java
index 620cef270..2bd5543f3 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/Sha1Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Sha1Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link SHA1}.
+ * Test for {@link Sha1}.
*/
public class Sha1Test extends AbstractEncryptionMethodTest {
public Sha1Test() {
- super(new SHA1(),
+ super(new Sha1(),
"5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", // password
"285d0c707f9644b75e1a87a62f25d0efb56800f0", // PassWord1
"a42ef8e61e890af80461ca5dcded25cbfcf407a4", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/Sha256Test.java b/src/test/java/fr/xephi/authme/security/crypts/Sha256Test.java
index 3257fe1f5..b9f751654 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/Sha256Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Sha256Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link SHA256}.
+ * Test for {@link Sha256}.
*/
public class Sha256Test extends AbstractEncryptionMethodTest {
public Sha256Test() {
- super(new SHA256(),
+ super(new Sha256(),
"$SHA$11aa0706173d7272$dbba96681c2ae4e0bfdf226d70fbbc5e4ee3d8071faa613bc533fe8a64817d10", // password
"$SHA$3c72a18a29b08d40$8e50a7a4f69a80f4893dc921eac84bd74b3f9ebfa22908302c9965eac3aa45e5", // PassWord1
"$SHA$584cea1cfab90030$adc006330e73d81e463fe02a4fe9b17bdbbcc05955bff72fb27cf2089f0b3859", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/Sha512Test.java b/src/test/java/fr/xephi/authme/security/crypts/Sha512Test.java
index 17ba989c6..2871cd3a2 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/Sha512Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Sha512Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link SHA512}.
+ * Test for {@link Sha512}.
*/
public class Sha512Test extends AbstractEncryptionMethodTest {
public Sha512Test() {
- super(new SHA512(),
+ super(new Sha512(),
"b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86", // password
"ae9942149995a8171391625b36da134d5e288c721650d7c8d2d464fb49a49f3f551e4916ab1e097d9dd1201b01d69b1dccdefa3d2524a66092fb61b3df6e7e71", // PassWord1
"8c4f3df78db191142d819a72c16058b9e1ea41ae9b1649e1184eb89e30344c51c9c71039c483cf2f1b76b51480d8459d7eb3cfbaa24b07f2041d1551af4ead75", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/SMFTest.java b/src/test/java/fr/xephi/authme/security/crypts/SmfTest.java
similarity index 72%
rename from src/test/java/fr/xephi/authme/security/crypts/SMFTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/SmfTest.java
index 8ba3b1973..53803334a 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/SMFTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/SmfTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link SMF}.
+ * Test for {@link Smf}.
*/
-public class SMFTest extends AbstractEncryptionMethodTest {
+public class SmfTest extends AbstractEncryptionMethodTest {
- public SMFTest() {
- super(new SMF(),
+ public SmfTest() {
+ super(new Smf(),
"9b361c66977bb059d460a20d3c21fb3394772df5", // password
"31a560bdd095a837945d46add1605108ba87b268", // PassWord1
"8d4b84544e0891be8c183fe9b1003cfac18c51a1", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/WBB3Test.java b/src/test/java/fr/xephi/authme/security/crypts/Wbb3Test.java
similarity index 81%
rename from src/test/java/fr/xephi/authme/security/crypts/WBB3Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/Wbb3Test.java
index d838c14fc..7443253fe 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/WBB3Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Wbb3Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link WBB3}.
+ * Test for {@link Wbb3}.
*/
-public class WBB3Test extends AbstractEncryptionMethodTest {
+public class Wbb3Test extends AbstractEncryptionMethodTest {
- public WBB3Test() {
- super(new WBB3(),
+ public Wbb3Test() {
+ super(new Wbb3(),
new HashedPassword("8df818ef7d56075ab2744f74b98ad68a375ccac4", "b7415b355492ea60314f259a35733a3092c03e3f"), // password
new HashedPassword("106da5cf5df92cb845e12cf62cbdb5235b6dc693", "6110f19b2b52910dccf592a19c59126873f42e69"), // PassWord1
new HashedPassword("940a9fb7acec0178c6691e8b3c14bd7d789078b1", "f9dd501ff3d1bf74904f9e89649e378429af56e7"), // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/WBB4Test.java b/src/test/java/fr/xephi/authme/security/crypts/Wbb4Test.java
similarity index 75%
rename from src/test/java/fr/xephi/authme/security/crypts/WBB4Test.java
rename to src/test/java/fr/xephi/authme/security/crypts/Wbb4Test.java
index 5b714cab3..6c5459f60 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/WBB4Test.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/Wbb4Test.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link WBB4}.
+ * Test for {@link Wbb4}.
*/
-public class WBB4Test extends AbstractEncryptionMethodTest {
+public class Wbb4Test extends AbstractEncryptionMethodTest {
- public WBB4Test() {
- super(new WBB4(),
+ public Wbb4Test() {
+ super(new Wbb4(),
"$2a$08$7DGr.wROqEPe0Z3XJS7n5.k.QWehovLHbpI.UkdfRb4ns268WsR6C", // password
"$2a$08$yWWVUA4PB4mqW.0wyIvV3OdoH492HuLk5L3iaqUrpRK2.2zn08d/K", // PassWord1
"$2a$08$EHXUFt7bTT9Fnsu22KWvF.QDssiosV8YzH8CyWqulB/ckOA7qioJG", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/WHIRLPOOLTest.java b/src/test/java/fr/xephi/authme/security/crypts/WhirlpoolTest.java
similarity index 81%
rename from src/test/java/fr/xephi/authme/security/crypts/WHIRLPOOLTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/WhirlpoolTest.java
index 1fbc94fd8..76cef4b05 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/WHIRLPOOLTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/WhirlpoolTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link WHIRLPOOL}.
+ * Test for {@link Whirlpool}.
*/
-public class WHIRLPOOLTest extends AbstractEncryptionMethodTest {
+public class WhirlpoolTest extends AbstractEncryptionMethodTest {
- public WHIRLPOOLTest() {
- super(new WHIRLPOOL(),
+ public WhirlpoolTest() {
+ super(new Whirlpool(),
"74DFC2B27ACFA364DA55F93A5CAEE29CCAD3557247EDA238831B3E9BD931B01D77FE994E4F12B9D4CFA92A124461D2065197D8CF7F33FC88566DA2DB2A4D6EAE", // password
"819B4CBD26508E39EA76BFE102DCF2ACC87A446747CAB0BD88522B0822A724583E81B6A4BD2CE255DB694E530B659F47D434EEB50344A02F50B64414C9671583", // PassWord1
"71ECB0E5AEAB006F5336348076AA6A8E46075AEC9E010C7055BA1334B57746F2A9D8A8799BDD9B7EB4AB7544A59D25F469C8BCA2067508ACBA62A929260A1E17", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/WORDPRESSTest.java b/src/test/java/fr/xephi/authme/security/crypts/WordpressTest.java
similarity index 77%
rename from src/test/java/fr/xephi/authme/security/crypts/WORDPRESSTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/WordpressTest.java
index 49a16d65b..0c444c2f8 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/WORDPRESSTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/WordpressTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link WORDPRESS}.
+ * Test for {@link Wordpress}.
*/
-public class WORDPRESSTest extends AbstractEncryptionMethodTest {
+public class WordpressTest extends AbstractEncryptionMethodTest {
- public WORDPRESSTest() {
- super(new WORDPRESS(),
+ public WordpressTest() {
+ super(new Wordpress(),
"$P$B9wyjxuU4yrfjnnHNGSzH9ti9CC0Os1", // password
"$P$BjzPjjzPjjkRzvGGRTyYu0sNqcz6Ci0", // PassWord1
"$P$BjzPjjzPjrAOyB1V0WFdpisgCTFx.N/", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/XAUTHTest.java b/src/test/java/fr/xephi/authme/security/crypts/XAuthTest.java
similarity index 84%
rename from src/test/java/fr/xephi/authme/security/crypts/XAUTHTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/XAuthTest.java
index 4fcd8039b..877a81ee1 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/XAUTHTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/XAuthTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link XAUTH}.
+ * Test for {@link XAuth}.
*/
-public class XAUTHTest extends AbstractEncryptionMethodTest {
+public class XAuthTest extends AbstractEncryptionMethodTest {
- public XAUTHTest() {
- super(new XAUTH(),
+ public XAuthTest() {
+ super(new XAuth(),
"e54d4916577410d26d2f6e9362445463dab9ffdff9a67ed3b74d3f2312bc8fab84f653fcb88ad8338793ef8a6d0a1162105e46ec24f0dcb52355c634e3e6439f45444b09c715", // password
"d54489a4fd4732ee03d56810ab92944096e3d49335266adeecfbc12567abb3ff744761b33a1fcc4d04739e377775c788e4baace3caf35c7b9176b82b1fe3472e4cbdc5a43214", // PassWord1
"ce6404c1092fb5abf0a72f9c4327bfe8f4cdc4b8dc90ee6ca35c42b8ae9481b89c2559bb60b99ff2b57a102cfced40b8e2f5ef481400c9e6f79445017fc763b1cc27f4c2df36", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/security/crypts/XFBCRYPTTest.java b/src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java
similarity index 73%
rename from src/test/java/fr/xephi/authme/security/crypts/XFBCRYPTTest.java
rename to src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java
index 4edafbdd0..af1f4589b 100644
--- a/src/test/java/fr/xephi/authme/security/crypts/XFBCRYPTTest.java
+++ b/src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java
@@ -1,12 +1,12 @@
package fr.xephi.authme.security.crypts;
/**
- * Test for {@link XFBCRYPT}.
+ * Test for {@link XfBCrypt}.
*/
-public class XFBCRYPTTest extends AbstractEncryptionMethodTest {
+public class XfBCryptTest extends AbstractEncryptionMethodTest {
- public XFBCRYPTTest() {
- super(new XFBCRYPT(),
+ public XfBCryptTest() {
+ super(new XfBCrypt(),
"$2a$10$UtuON/ZG.x8EWG/zQbryB.BHfQVrfxk3H7qykzP.UJQ8YiLjZyfqq", // password
"$2a$10$Q.ocUo.YtHTdI4nu3pcpKun6BILcmWHm541ANULucmuU/ps1QKY4K", // PassWord1
"$2a$10$yHjm02.K4HP5iFU1F..yLeTeo7PWZVbKAr/QGex5jU4.J3mdq/uuO", // &^%te$t?Pw@_
diff --git a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java
index fa82b97ae..11a0f253f 100644
--- a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java
+++ b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java
@@ -5,7 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
-import fr.xephi.authme.security.crypts.SHA256;
+import fr.xephi.authme.security.crypts.Sha256;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.junit.BeforeClass;
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+import static fr.xephi.authme.AuthMeMatchers.equalToHash;
/**
* Test for {@link MigrationService}.
@@ -42,7 +43,7 @@ public class MigrationServiceTest {
private DataSource dataSource;
@Mock
- private SHA256 sha256;
+ private Sha256 sha256;
@BeforeClass
public static void setUpLogger() {
@@ -122,7 +123,7 @@ public class MigrationServiceTest {
.build();
}
- private static void setSha256MockToUppercase(SHA256 sha256) {
+ private static void setSha256MockToUppercase(Sha256 sha256) {
given(sha256.computeHash(anyString(), anyString())).willAnswer(new Answer() {
@Override
public HashedPassword answer(InvocationOnMock invocation) {