diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java
index fe67da7a..064ea536 100644
--- a/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java
+++ b/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java
@@ -1,6 +1,5 @@
package fr.xephi.authme.command.executable.authme;
-import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
diff --git a/src/main/java/fr/xephi/authme/mail/SendMailSSL.java b/src/main/java/fr/xephi/authme/mail/SendMailSSL.java
index 88d57d9a..58b64d6b 100644
--- a/src/main/java/fr/xephi/authme/mail/SendMailSSL.java
+++ b/src/main/java/fr/xephi/authme/mail/SendMailSSL.java
@@ -131,7 +131,7 @@ public class SendMailSSL {
.replace("", newPass);
}
- private static void setPropertiesForPort(HtmlEmail email, int port, NewSetting settings)
+ private static void setPropertiesForPort(HtmlEmail email, int port, NewSetting settings)
throws EmailException {
switch (port) {
case 587:
diff --git a/src/main/java/fr/xephi/authme/output/Log4JFilter.java b/src/main/java/fr/xephi/authme/output/Log4JFilter.java
index 336af779..8bc52452 100644
--- a/src/main/java/fr/xephi/authme/output/Log4JFilter.java
+++ b/src/main/java/fr/xephi/authme/output/Log4JFilter.java
@@ -59,16 +59,16 @@ public class Log4JFilter implements Filter {
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, String message, Object... arg4) {
- if (message == null) {
- return Result.NEUTRAL;
+ if (message == null) {
+ return Result.NEUTRAL;
}
return validateMessage(message);
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message, Throwable arg4) {
- if (message == null) {
- return Result.NEUTRAL;
+ if (message == null) {
+ return Result.NEUTRAL;
}
return validateMessage(message.toString());
}
diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java
index 7f2fd8f5..2ea6fd07 100644
--- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java
+++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java
@@ -29,9 +29,12 @@ import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import javax.inject.Inject;
+
+import java.util.ArrayList;
import java.util.List;
/**
@@ -150,11 +153,18 @@ public class AsynchronousLogin implements AsynchronousProcess {
public void login(final Player player, String password, boolean forceLogin) {
PlayerAuth pAuth = preAuth(player);
- if (pAuth == null || needsCaptcha(player)) {
+ if (pAuth == null) {
return;
}
final String name = player.getName().toLowerCase();
+
+ // If Captcha is required send a message to the player and deny to login
+ if (needsCaptcha(player)) {
+ service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(name));
+ return;
+ }
+
final String ip = Utils.getPlayerIp(player);
// Increase the counts here before knowing the result of the login.
@@ -232,7 +242,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
} else {
service.send(player, MessageKey.WRONG_PASSWORD);
- // Check again if a captcha is required to log in
+ // If the authentication fails check if Captcha is required and send a message to the player
if (needsCaptcha(player)) {
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(name));
}
@@ -249,14 +259,27 @@ public class AsynchronousLogin implements AsynchronousProcess {
}
List auths = database.getAllAuthsByIp(auth.getIp());
- if (auths.size() < 2) {
+ if (auths.size() <= 1) {
return;
}
- // TODO #423: color player names with green if the account is online
- String message = StringUtils.join(", ", auths) + ".";
- ConsoleLogger.info("The user " + player.getName() + " has " + auths.size() + " accounts:");
- ConsoleLogger.info(message);
+ List tmp = new ArrayList();
+ for(String currentName : auths) {
+ Player currentPlayer = bukkitService.getPlayerExact(currentName);
+ if(currentPlayer != null && currentPlayer.isOnline()) {
+ tmp.add(ChatColor.GREEN + currentName);
+ } else {
+ tmp.add(currentName);
+ }
+ }
+ auths = tmp;
+
+ String message = StringUtils.join(ChatColor.GRAY + ", ", auths) + ".";
+
+ if(!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
+ ConsoleLogger.info("The user " + player.getName() + " has " + auths.size() + " accounts:");
+ ConsoleLogger.info(message);
+ }
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
if (onlinePlayer.getName().equalsIgnoreCase(player.getName())
diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java
index ede9e9ff..15901606 100644
--- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java
@@ -8,7 +8,6 @@ import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.task.LimboPlayerTaskManager;
-import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
diff --git a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java
index 9d96d24c..87cb4808 100644
--- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java
+++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java
@@ -1,6 +1,5 @@
package fr.xephi.authme.process.unregister;
-import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
@@ -15,7 +14,6 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.LimboPlayerTaskManager;
-import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java b/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java
index 194ea7b6..6b82305c 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java
@@ -380,9 +380,9 @@ public class BCryptService {
* encoding scheme. Note that this is *not* compatible with
* the standard MIME-base64 encoding.
*
- * @param d the byte array to encode
- * @param len the number of bytes to encode
- * @return base64-encoded string
+ * @param d the byte array to encode
+ * @param len the number of bytes to encode
+ * @return base64-encoded string
* @exception IllegalArgumentException if the length is invalid
*/
private static String encode_base64(byte d[], int len)
@@ -421,8 +421,8 @@ public class BCryptService {
/**
* Look up the 3 bits base64-encoded by the specified character,
* range-checking againt conversion table
- * @param x the base64-encoded value
- * @return the decoded value of x
+ * @param x the base64-encoded value
+ * @return the decoded value of x
*/
private static byte char64(char x) {
if ((int)x < 0 || (int)x > index_64.length)
@@ -434,9 +434,9 @@ public class BCryptService {
* Decode a string encoded using bcrypt's base64 scheme to a
* byte array. Note that this is *not* compatible with
* the standard MIME-base64 encoding.
- * @param s the string to decode
- * @param maxolen the maximum number of bytes to decode
- * @return an array containing the decoded bytes
+ * @param s the string to decode
+ * @param maxolen the maximum number of bytes to decode
+ * @return an array containing the decoded bytes
* @throws IllegalArgumentException if maxolen is invalid
*/
private static byte[] decode_base64(String s, int maxolen)
@@ -483,8 +483,8 @@ public class BCryptService {
/**
* Blowfish encipher a single 64-bit block encoded as
* two 32-bit halves
- * @param lr an array containing the two 32-bit half blocks
- * @param off the position in the array of the blocks
+ * @param lr an array containing the two 32-bit half blocks
+ * @param off the position in the array of the blocks
*/
private void encipher(int lr[], int off) {
int i, n, l = lr[off], r = lr[off + 1];
@@ -511,10 +511,10 @@ public class BCryptService {
/**
* Cycically extract a word of key material
- * @param data the string to extract the data from
- * @param offp a "pointer" (as a one-entry array) to the
+ * @param data the string to extract the data from
+ * @param offp a "pointer" (as a one-entry array) to the
* current offset into data
- * @return the next word of material from data
+ * @return the next word of material from data
*/
private static int streamtoword(byte data[], int offp[]) {
int i;
@@ -540,7 +540,7 @@ public class BCryptService {
/**
* Key the Blowfish cipher
- * @param key an array containing the key
+ * @param key an array containing the key
*/
private void key(byte key[]) {
int i;
@@ -568,8 +568,8 @@ public class BCryptService {
* Perform the "enhanced key schedule" step described by
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
* http://www.openbsd.org/papers/bcrypt-paper.ps
- * @param data salt information
- * @param key password information
+ * @param data salt information
+ * @param key password information
*/
private void ekskey(byte data[], byte key[]) {
int i;
@@ -600,12 +600,12 @@ public class BCryptService {
/**
* Perform the central password hashing step in the
* bcrypt scheme
- * @param password the password to hash
- * @param salt the binary salt to hash with the password
- * @param log_rounds the binary logarithm of the number
+ * @param password the password to hash
+ * @param salt the binary salt to hash with the password
+ * @param log_rounds the binary logarithm of the number
* of rounds of hashing to apply
* @param cdata the plaintext to encrypt
- * @return an array containing the binary hashed password
+ * @return an array containing the binary hashed password
*/
public byte[] crypt_raw(byte password[], byte salt[], int log_rounds,
int cdata[]) {
@@ -643,10 +643,10 @@ public class BCryptService {
/**
* Hash a password using the OpenBSD bcrypt scheme
- * @param password the password to hash
- * @param salt the salt to hash with (perhaps generated
+ * @param password the password to hash
+ * @param salt the salt to hash with (perhaps generated
* using BCrypt.gensalt)
- * @return the hashed password
+ * @return the hashed password
*/
public static String hashpw(String password, String salt) {
BCryptService B;
@@ -706,11 +706,11 @@ public class BCryptService {
/**
* Generate a salt for use with the BCrypt.hashpw() method
- * @param log_rounds the log2 of the number of rounds of
+ * @param log_rounds the log2 of the number of rounds of
* hashing to apply - the work factor therefore increases as
* 2**log_rounds.
- * @param random an instance of SecureRandom to use
- * @return an encoded salt value
+ * @param random an instance of SecureRandom to use
+ * @return an encoded salt value
*/
public static String gensalt(int log_rounds, SecureRandom random) {
StringBuilder rs = new StringBuilder();
@@ -733,10 +733,10 @@ public class BCryptService {
/**
* Generate a salt for use with the BCrypt.hashpw() method
- * @param log_rounds the log2 of the number of rounds of
+ * @param log_rounds the log2 of the number of rounds of
* hashing to apply - the work factor therefore increases as
* 2**log_rounds.
- * @return an encoded salt value
+ * @return an encoded salt value
*/
public static String gensalt(int log_rounds) {
return gensalt(log_rounds, new SecureRandom());
@@ -746,7 +746,7 @@ public class BCryptService {
* Generate a salt for use with the BCrypt.hashpw() method,
* selecting a reasonable default for the number of hashing
* rounds to apply
- * @return an encoded salt value
+ * @return an encoded salt value
*/
public static String gensalt() {
return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS);
@@ -755,9 +755,9 @@ public class BCryptService {
/**
* Check that a plaintext password matches a previously hashed
* one
- * @param plaintext the plaintext password to verify
- * @param hashed the previously-hashed password
- * @return true if the passwords match, false otherwise
+ * @param plaintext the plaintext password to verify
+ * @param hashed the previously-hashed password
+ * @return true if the passwords match, false otherwise
*/
public static boolean checkpw(String plaintext, String hashed) {
byte hashed_bytes[];
diff --git a/src/main/java/fr/xephi/authme/util/TeleportationService.java b/src/main/java/fr/xephi/authme/util/TeleportationService.java
index e757d4e8..06c7558d 100644
--- a/src/main/java/fr/xephi/authme/util/TeleportationService.java
+++ b/src/main/java/fr/xephi/authme/util/TeleportationService.java
@@ -8,7 +8,6 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.initialization.Reloadable;
-import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;