mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-17 22:28:13 +01:00
update base64
This commit is contained in:
parent
53fcfb5b43
commit
350ab53563
@ -1,7 +1,6 @@
|
||||
package fr.xephi.authme.cache.backup;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.*;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
@ -14,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -133,7 +133,7 @@ public class JsonCache {
|
||||
BukkitObjectOutputStream objectOut = new BukkitObjectOutputStream(baos);
|
||||
objectOut.writeObject(item);
|
||||
objectOut.close();
|
||||
val.addProperty("item", BaseEncoding.base64().encode(baos.toByteArray()));
|
||||
val.addProperty("item", Base64Coder.encodeLines(baos.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
@ -187,7 +187,7 @@ public class JsonCache {
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JsonObject item = arr.get(i).getAsJsonObject();
|
||||
String encoded = item.get("item").getAsString();
|
||||
byte[] decoded = BaseEncoding.base64().decode(encoded);
|
||||
byte[] decoded = Base64Coder.decode(encoded);
|
||||
try {
|
||||
ByteArrayInputStream baos = new ByteArrayInputStream(decoded);
|
||||
BukkitObjectInputStream objectIn = new BukkitObjectInputStream(baos);
|
||||
|
@ -172,7 +172,6 @@ public class AsyncronousJoin {
|
||||
|
||||
}
|
||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||
try {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
plugin.getServer().getPluginManager().callEvent(ev);
|
||||
@ -191,9 +190,6 @@ public class AsyncronousJoin {
|
||||
|
||||
});
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
String[] msg;
|
||||
if (Settings.emailRegistration) {
|
||||
|
@ -90,13 +90,10 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* 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
|
||||
* @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
|
||||
* @throws IllegalArgumentException if the length is invalid
|
||||
*/
|
||||
private static String encode_base64(byte d[], int len)
|
||||
throws IllegalArgumentException {
|
||||
@ -135,8 +132,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* Look up the 3 bits base64-encoded by the specified character,
|
||||
* range-checking againt conversion table
|
||||
*
|
||||
* @param x
|
||||
* the base64-encoded value
|
||||
* @param x the base64-encoded value
|
||||
* @return the decoded value of x
|
||||
*/
|
||||
private static byte char64(char x) {
|
||||
@ -150,13 +146,10 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* 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
|
||||
* @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
|
||||
* @throws IllegalArgumentException if maxolen is invalid
|
||||
*/
|
||||
private static byte[] decode_base64(String s, int maxolen)
|
||||
throws IllegalArgumentException {
|
||||
@ -202,10 +195,8 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* 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 final void encipher(int lr[], int off) {
|
||||
int i, n, l = lr[off], r = lr[off + 1];
|
||||
@ -233,10 +224,8 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* 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 current offset into
|
||||
* @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
|
||||
*/
|
||||
@ -265,8 +254,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* 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;
|
||||
@ -295,10 +283,8 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* 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;
|
||||
@ -329,12 +315,9 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* 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 of rounds of hashing to
|
||||
* @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
|
||||
* @return an array containing the binary hashed password
|
||||
*/
|
||||
@ -375,10 +358,8 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* Hash a password using the OpenBSD bcrypt scheme
|
||||
*
|
||||
* @param password
|
||||
* the password to hash
|
||||
* @param salt
|
||||
* the salt to hash with (perhaps generated using BCrypt.gensalt)
|
||||
* @param password the password to hash
|
||||
* @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
|
||||
* @return the hashed password
|
||||
*/
|
||||
public static String hashpw(String password, String salt) {
|
||||
@ -433,11 +414,9 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* Generate a salt for use with the BCrypt.hashpw() method
|
||||
*
|
||||
* @param log_rounds
|
||||
* the log2 of the number of rounds of hashing to apply - the
|
||||
* @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
|
||||
* @param random an instance of SecureRandom to use
|
||||
* @return an encoded salt value
|
||||
*/
|
||||
public static String gensalt(int log_rounds, SecureRandom random) {
|
||||
@ -458,8 +437,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* Generate a salt for use with the BCrypt.hashpw() method
|
||||
*
|
||||
* @param log_rounds
|
||||
* the log2 of the number of rounds of hashing to apply - the
|
||||
* @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
|
||||
*/
|
||||
@ -480,10 +458,8 @@ public class BCRYPT implements EncryptionMethod {
|
||||
/**
|
||||
* Check that a plaintext password matches a previously hashed one
|
||||
*
|
||||
* @param plaintext
|
||||
* the plaintext password to verify
|
||||
* @param hashed
|
||||
* the previously-hashed password
|
||||
* @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) {
|
||||
@ -494,12 +470,9 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* Check that a text password matches a previously hashed one with the
|
||||
* specified number of rounds using recursion
|
||||
*
|
||||
* @param text
|
||||
* plaintext or hashed text
|
||||
* @param hashed
|
||||
* the previously-hashed password
|
||||
* @param rounds
|
||||
* number of rounds to hash the password
|
||||
* @param text plaintext or hashed text
|
||||
* @param hashed the previously-hashed password
|
||||
* @param rounds number of rounds to hash the password
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkpw(String text, String hashed, int rounds) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
|
||||
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class CryptPBKDF2Django implements EncryptionMethod {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user