update base64
This commit is contained in:
parent
53fcfb5b43
commit
350ab53563
@ -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);
|
||||||
|
|||||||
@ -172,7 +172,6 @@ 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);
|
||||||
@ -191,9 +190,6 @@ public class AsyncronousJoin {
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
String[] msg;
|
String[] msg;
|
||||||
if (Settings.emailRegistration) {
|
if (Settings.emailRegistration) {
|
||||||
|
|||||||
@ -90,13 +90,10 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
* scheme. Note that this is *not* compatible with the standard MIME-base64
|
* scheme. Note that this is *not* compatible with the standard MIME-base64
|
||||||
* encoding.
|
* encoding.
|
||||||
*
|
*
|
||||||
* @param d
|
* @param d the byte array to encode
|
||||||
* 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
|
* @throws IllegalArgumentException if the length is invalid
|
||||||
* if the length is invalid
|
|
||||||
*/
|
*/
|
||||||
private static String encode_base64(byte d[], int len)
|
private static String encode_base64(byte d[], int len)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@ -135,8 +132,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
* 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
|
* @param x the base64-encoded value
|
||||||
* 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) {
|
||||||
@ -150,13 +146,10 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
* Note that this is *not* compatible with the standard MIME-base64
|
* Note that this is *not* compatible with the standard MIME-base64
|
||||||
* encoding.
|
* encoding.
|
||||||
*
|
*
|
||||||
* @param s
|
* @param s the string to decode
|
||||||
* 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
|
* @throws IllegalArgumentException if maxolen is invalid
|
||||||
* if maxolen is invalid
|
|
||||||
*/
|
*/
|
||||||
private static byte[] decode_base64(String s, int maxolen)
|
private static byte[] decode_base64(String s, int maxolen)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@ -202,10 +195,8 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
/**
|
/**
|
||||||
* Blowfish encipher a single 64-bit block encoded as two 32-bit halves
|
* Blowfish encipher a single 64-bit block encoded as two 32-bit halves
|
||||||
*
|
*
|
||||||
* @param lr
|
* @param lr an array containing the two 32-bit half blocks
|
||||||
* 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 final void encipher(int lr[], int off) {
|
private final 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];
|
||||||
@ -233,10 +224,8 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
/**
|
/**
|
||||||
* Cycically extract a word of key material
|
* Cycically extract a word of key material
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data the string to extract the data from
|
||||||
* the string to extract the data from
|
* @param offp a "pointer" (as a one-entry array) to the current offset into
|
||||||
* @param offp
|
|
||||||
* a "pointer" (as a one-entry array) to the current offset into
|
|
||||||
* data
|
* data
|
||||||
* @return the next word of material from data
|
* @return the next word of material from data
|
||||||
*/
|
*/
|
||||||
@ -265,8 +254,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
/**
|
/**
|
||||||
* Key the Blowfish cipher
|
* Key the Blowfish cipher
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key an array containing the key
|
||||||
* an array containing the key
|
|
||||||
*/
|
*/
|
||||||
private void key(byte key[]) {
|
private void key(byte key[]) {
|
||||||
int i;
|
int i;
|
||||||
@ -295,10 +283,8 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
* in "A Future-Adaptable Password Scheme"
|
* in "A Future-Adaptable Password Scheme"
|
||||||
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data salt information
|
||||||
* 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;
|
||||||
@ -329,12 +315,9 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
/**
|
/**
|
||||||
* Perform the central password hashing step in the bcrypt scheme
|
* Perform the central password hashing step in the bcrypt scheme
|
||||||
*
|
*
|
||||||
* @param password
|
* @param password the password to hash
|
||||||
* the password to hash
|
* @param salt the binary salt to hash with the password
|
||||||
* @param salt
|
* @param log_rounds the binary logarithm of the number of rounds of hashing to
|
||||||
* the binary salt to hash with the password
|
|
||||||
* @param log_rounds
|
|
||||||
* the binary logarithm of the number of rounds of hashing to
|
|
||||||
* apply
|
* apply
|
||||||
* @return an array containing the binary hashed password
|
* @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
|
* Hash a password using the OpenBSD bcrypt scheme
|
||||||
*
|
*
|
||||||
* @param password
|
* @param password the password to hash
|
||||||
* the password to hash
|
* @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
|
||||||
* @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) {
|
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
|
* Generate a salt for use with the BCrypt.hashpw() method
|
||||||
*
|
*
|
||||||
* @param log_rounds
|
* @param log_rounds the log2 of the number of rounds of hashing to apply - the
|
||||||
* the log2 of the number of rounds of hashing to apply - the
|
|
||||||
* work factor therefore increases as 2**log_rounds.
|
* work factor therefore increases as 2**log_rounds.
|
||||||
* @param random
|
* @param random an instance of SecureRandom to use
|
||||||
* 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) {
|
||||||
@ -458,8 +437,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* Generate a salt for use with the BCrypt.hashpw() method
|
||||||
*
|
*
|
||||||
* @param log_rounds
|
* @param log_rounds the log2 of the number of rounds of hashing to apply - the
|
||||||
* the log2 of the number of rounds of hashing to apply - the
|
|
||||||
* work factor therefore increases as 2**log_rounds.
|
* work factor therefore increases as 2**log_rounds.
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
*/
|
*/
|
||||||
@ -480,10 +458,8 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
/**
|
/**
|
||||||
* Check that a plaintext password matches a previously hashed one
|
* Check that a plaintext password matches a previously hashed one
|
||||||
*
|
*
|
||||||
* @param plaintext
|
* @param plaintext the plaintext password to verify
|
||||||
* 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) {
|
||||||
@ -494,12 +470,9 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
* Check that a text password matches a previously hashed one with the
|
* Check that a text password matches a previously hashed one with the
|
||||||
* specified number of rounds using recursion
|
* specified number of rounds using recursion
|
||||||
*
|
*
|
||||||
* @param text
|
* @param text plaintext or hashed text
|
||||||
* plaintext or hashed text
|
* @param hashed the previously-hashed password
|
||||||
* @param hashed
|
* @param rounds number of rounds to hash the password
|
||||||
* the previously-hashed password
|
|
||||||
* @param rounds
|
|
||||||
* number of rounds to hash the password
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean checkpw(String text, String hashed, int rounds) {
|
public static boolean checkpw(String text, String hashed, int rounds) {
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user