update base64

This commit is contained in:
DNx5 2015-09-20 08:40:02 +07:00
parent 53fcfb5b43
commit 350ab53563
4 changed files with 75 additions and 106 deletions

View File

@ -1,7 +1,6 @@
package fr.xephi.authme.cache.backup; package fr.xephi.authme.cache.backup;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.io.BaseEncoding;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.gson.*; import com.google.gson.*;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
@ -14,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.util.io.BukkitObjectInputStream; import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream; import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -133,7 +133,7 @@ public class JsonCache {
BukkitObjectOutputStream objectOut = new BukkitObjectOutputStream(baos); BukkitObjectOutputStream objectOut = new BukkitObjectOutputStream(baos);
objectOut.writeObject(item); objectOut.writeObject(item);
objectOut.close(); objectOut.close();
val.addProperty("item", BaseEncoding.base64().encode(baos.toByteArray())); val.addProperty("item", Base64Coder.encodeLines(baos.toByteArray()));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
continue; continue;
@ -187,7 +187,7 @@ public class JsonCache {
for (int i = 0; i < arr.size(); i++) { for (int i = 0; i < arr.size(); i++) {
JsonObject item = arr.get(i).getAsJsonObject(); JsonObject item = arr.get(i).getAsJsonObject();
String encoded = item.get("item").getAsString(); String encoded = item.get("item").getAsString();
byte[] decoded = BaseEncoding.base64().decode(encoded); byte[] decoded = Base64Coder.decode(encoded);
try { try {
ByteArrayInputStream baos = new ByteArrayInputStream(decoded); ByteArrayInputStream baos = new ByteArrayInputStream(decoded);
BukkitObjectInputStream objectIn = new BukkitObjectInputStream(baos); BukkitObjectInputStream objectIn = new BukkitObjectInputStream(baos);

View File

@ -172,27 +172,23 @@ public class AsyncronousJoin {
} }
if (Settings.protectInventoryBeforeLogInEnabled) { if (Settings.protectInventoryBeforeLogInEnabled) {
try { LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); plugin.getServer().getPluginManager().callEvent(ev);
plugin.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) {
if (ev.isCancelled()) { if (!Settings.noConsoleSpam)
if (!Settings.noConsoleSpam) ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); } else {
} else { final ItemStack[] inv = ev.getEmptyArmor();
final ItemStack[] inv = ev.getEmptyArmor(); final ItemStack[] armor = ev.getEmptyArmor();
final ItemStack[] armor = ev.getEmptyArmor(); sched.scheduleSyncDelayedTask(plugin, new Runnable() {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
plugin.api.setPlayerInventory(player, inv, armor); plugin.api.setPlayerInventory(player, inv, armor);
} }
}); });
}
} catch (Exception ex) {
ex.printStackTrace();
} }
} }
String[] msg; String[] msg;

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.security.crypts; package fr.xephi.authme.security.crypts;
import java.security.NoSuchAlgorithmException;
import fr.xephi.authme.security.pbkdf2.PBKDF2Engine; import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters; import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import java.security.NoSuchAlgorithmException;
public class CryptPBKDF2Django implements EncryptionMethod { public class CryptPBKDF2Django implements EncryptionMethod {
@ -20,7 +20,7 @@ public class CryptPBKDF2Django implements EncryptionMethod {
@Override @Override
public boolean comparePassword(String hash, String password, public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException { String playerName) throws NoSuchAlgorithmException {
String[] line = hash.split("\\$"); String[] line = hash.split("\\$");
String salt = line[2]; String salt = line[2];
byte[] derivedKey = DatatypeConverter.parseBase64Binary(line[3]); byte[] derivedKey = DatatypeConverter.parseBase64Binary(line[3]);