Use spaces, finish working on #423, import cleanup
This commit is contained in:
parent
26531e93ef
commit
e12ae2cf96
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
|
|||||||
@ -131,7 +131,7 @@ public class SendMailSSL {
|
|||||||
.replace("<generatedpass />", newPass);
|
.replace("<generatedpass />", newPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setPropertiesForPort(HtmlEmail email, int port, NewSetting settings)
|
private static void setPropertiesForPort(HtmlEmail email, int port, NewSetting settings)
|
||||||
throws EmailException {
|
throws EmailException {
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case 587:
|
case 587:
|
||||||
|
|||||||
@ -29,9 +29,12 @@ import fr.xephi.authme.util.BukkitService;
|
|||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,11 +153,18 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
|
|
||||||
public void login(final Player player, String password, boolean forceLogin) {
|
public void login(final Player player, String password, boolean forceLogin) {
|
||||||
PlayerAuth pAuth = preAuth(player);
|
PlayerAuth pAuth = preAuth(player);
|
||||||
if (pAuth == null || needsCaptcha(player)) {
|
if (pAuth == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String name = player.getName().toLowerCase();
|
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);
|
final String ip = Utils.getPlayerIp(player);
|
||||||
|
|
||||||
// Increase the counts here before knowing the result of the login.
|
// Increase the counts here before knowing the result of the login.
|
||||||
@ -232,7 +242,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
} else {
|
} else {
|
||||||
service.send(player, MessageKey.WRONG_PASSWORD);
|
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)) {
|
if (needsCaptcha(player)) {
|
||||||
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(name));
|
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(name));
|
||||||
}
|
}
|
||||||
@ -249,14 +259,27 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> auths = database.getAllAuthsByIp(auth.getIp());
|
List<String> auths = database.getAllAuthsByIp(auth.getIp());
|
||||||
if (auths.size() < 2) {
|
if (auths.size() <= 1) {
|
||||||
return;
|
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:");
|
List<String> tmp = new ArrayList<String>();
|
||||||
ConsoleLogger.info(message);
|
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()) {
|
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
|
||||||
if (onlinePlayer.getName().equalsIgnoreCase(player.getName())
|
if (onlinePlayer.getName().equalsIgnoreCase(player.getName())
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import fr.xephi.authme.process.SynchronousProcess;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.process.unregister;
|
package fr.xephi.authme.process.unregister;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
@ -15,7 +14,6 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|||||||
@ -380,9 +380,9 @@ public class BCryptService {
|
|||||||
* encoding scheme. Note that this is *not* compatible with
|
* encoding scheme. Note that this is *not* compatible with
|
||||||
* the standard MIME-base64 encoding.
|
* the standard MIME-base64 encoding.
|
||||||
*
|
*
|
||||||
* @param d the byte array to encode
|
* @param d the byte array to encode
|
||||||
* @param len the number of bytes to encode
|
* @param len the number of bytes to encode
|
||||||
* @return base64-encoded string
|
* @return base64-encoded string
|
||||||
* @exception IllegalArgumentException if the length is invalid
|
* @exception IllegalArgumentException if the length is invalid
|
||||||
*/
|
*/
|
||||||
private static String encode_base64(byte d[], int len)
|
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,
|
* Look up the 3 bits base64-encoded by the specified character,
|
||||||
* range-checking againt conversion table
|
* range-checking againt conversion table
|
||||||
* @param x the base64-encoded value
|
* @param x the base64-encoded value
|
||||||
* @return the decoded value of x
|
* @return the decoded value of x
|
||||||
*/
|
*/
|
||||||
private static byte char64(char x) {
|
private static byte char64(char x) {
|
||||||
if ((int)x < 0 || (int)x > index_64.length)
|
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
|
* Decode a string encoded using bcrypt's base64 scheme to a
|
||||||
* byte array. Note that this is *not* compatible with
|
* byte array. Note that this is *not* compatible with
|
||||||
* the standard MIME-base64 encoding.
|
* the standard MIME-base64 encoding.
|
||||||
* @param s the string to decode
|
* @param s the string to decode
|
||||||
* @param maxolen the maximum number of bytes to decode
|
* @param maxolen the maximum number of bytes to decode
|
||||||
* @return an array containing the decoded bytes
|
* @return an array containing the decoded bytes
|
||||||
* @throws IllegalArgumentException if maxolen is invalid
|
* @throws IllegalArgumentException if maxolen is invalid
|
||||||
*/
|
*/
|
||||||
private static byte[] decode_base64(String s, int maxolen)
|
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
|
* Blowfish encipher a single 64-bit block encoded as
|
||||||
* two 32-bit halves
|
* two 32-bit halves
|
||||||
* @param lr an array containing the two 32-bit half blocks
|
* @param lr an array containing the two 32-bit half blocks
|
||||||
* @param off the position in the array of the blocks
|
* @param off the position in the array of the blocks
|
||||||
*/
|
*/
|
||||||
private void encipher(int lr[], int off) {
|
private void encipher(int lr[], int off) {
|
||||||
int i, n, l = lr[off], r = lr[off + 1];
|
int i, n, l = lr[off], r = lr[off + 1];
|
||||||
@ -511,10 +511,10 @@ public class BCryptService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cycically extract a word of key material
|
* Cycically extract a word of key material
|
||||||
* @param data the string to extract the data from
|
* @param data the string to extract the data from
|
||||||
* @param offp a "pointer" (as a one-entry array) to the
|
* @param offp a "pointer" (as a one-entry array) to the
|
||||||
* current offset into data
|
* 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[]) {
|
private static int streamtoword(byte data[], int offp[]) {
|
||||||
int i;
|
int i;
|
||||||
@ -540,7 +540,7 @@ public class BCryptService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Key the Blowfish cipher
|
* Key the Blowfish cipher
|
||||||
* @param key an array containing the key
|
* @param key an array containing the key
|
||||||
*/
|
*/
|
||||||
private void key(byte key[]) {
|
private void key(byte key[]) {
|
||||||
int i;
|
int i;
|
||||||
@ -568,8 +568,8 @@ public class BCryptService {
|
|||||||
* Perform the "enhanced key schedule" step described by
|
* Perform the "enhanced key schedule" step described by
|
||||||
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
|
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
|
||||||
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
||||||
* @param data salt information
|
* @param data salt information
|
||||||
* @param key password information
|
* @param key password information
|
||||||
*/
|
*/
|
||||||
private void ekskey(byte data[], byte key[]) {
|
private void ekskey(byte data[], byte key[]) {
|
||||||
int i;
|
int i;
|
||||||
@ -600,12 +600,12 @@ public class BCryptService {
|
|||||||
/**
|
/**
|
||||||
* Perform the central password hashing step in the
|
* Perform the central password hashing step in the
|
||||||
* bcrypt scheme
|
* bcrypt scheme
|
||||||
* @param password the password to hash
|
* @param password the password to hash
|
||||||
* @param salt the binary salt to hash with the password
|
* @param salt the binary salt to hash with the password
|
||||||
* @param log_rounds the binary logarithm of the number
|
* @param log_rounds the binary logarithm of the number
|
||||||
* of rounds of hashing to apply
|
* of rounds of hashing to apply
|
||||||
* @param cdata the plaintext to encrypt
|
* @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,
|
public byte[] crypt_raw(byte password[], byte salt[], int log_rounds,
|
||||||
int cdata[]) {
|
int cdata[]) {
|
||||||
@ -643,10 +643,10 @@ public class BCryptService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash a password using the OpenBSD bcrypt scheme
|
* Hash a password using the OpenBSD bcrypt scheme
|
||||||
* @param password the password to hash
|
* @param password the password to hash
|
||||||
* @param salt the salt to hash with (perhaps generated
|
* @param salt the salt to hash with (perhaps generated
|
||||||
* using BCrypt.gensalt)
|
* using BCrypt.gensalt)
|
||||||
* @return the hashed password
|
* @return the hashed password
|
||||||
*/
|
*/
|
||||||
public static String hashpw(String password, String salt) {
|
public static String hashpw(String password, String salt) {
|
||||||
BCryptService B;
|
BCryptService B;
|
||||||
@ -706,11 +706,11 @@ public class BCryptService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* 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
|
* hashing to apply - the work factor therefore increases as
|
||||||
* 2**log_rounds.
|
* 2**log_rounds.
|
||||||
* @param random an instance of SecureRandom to use
|
* @param random an instance of SecureRandom to use
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
*/
|
*/
|
||||||
public static String gensalt(int log_rounds, SecureRandom random) {
|
public static String gensalt(int log_rounds, SecureRandom random) {
|
||||||
StringBuilder rs = new StringBuilder();
|
StringBuilder rs = new StringBuilder();
|
||||||
@ -733,10 +733,10 @@ public class BCryptService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* 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
|
* hashing to apply - the work factor therefore increases as
|
||||||
* 2**log_rounds.
|
* 2**log_rounds.
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
*/
|
*/
|
||||||
public static String gensalt(int log_rounds) {
|
public static String gensalt(int log_rounds) {
|
||||||
return gensalt(log_rounds, new SecureRandom());
|
return gensalt(log_rounds, new SecureRandom());
|
||||||
@ -746,7 +746,7 @@ public class BCryptService {
|
|||||||
* Generate a salt for use with the BCrypt.hashpw() method,
|
* Generate a salt for use with the BCrypt.hashpw() method,
|
||||||
* selecting a reasonable default for the number of hashing
|
* selecting a reasonable default for the number of hashing
|
||||||
* rounds to apply
|
* rounds to apply
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
*/
|
*/
|
||||||
public static String gensalt() {
|
public static String gensalt() {
|
||||||
return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS);
|
return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS);
|
||||||
@ -755,9 +755,9 @@ public class BCryptService {
|
|||||||
/**
|
/**
|
||||||
* Check that a plaintext password matches a previously hashed
|
* Check that a plaintext password matches a previously hashed
|
||||||
* one
|
* one
|
||||||
* @param plaintext the plaintext password to verify
|
* @param plaintext the plaintext password to verify
|
||||||
* @param hashed the previously-hashed password
|
* @param hashed the previously-hashed password
|
||||||
* @return true if the passwords match, false otherwise
|
* @return true if the passwords match, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean checkpw(String plaintext, String hashed) {
|
public static boolean checkpw(String plaintext, String hashed) {
|
||||||
byte hashed_bytes[];
|
byte hashed_bytes[];
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
|
|||||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.output.Messages;
|
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user