Fix FileAlreadyExistsException for sym linked folders

This commit is contained in:
games647
2018-01-27 21:49:32 +01:00
parent 856613a8c7
commit dcef62fa57
6 changed files with 32 additions and 30 deletions
@@ -1,8 +1,7 @@
package com.github.games647.fastlogin.bukkit;
import com.google.common.base.Charsets;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.KeyPair;
@@ -28,6 +27,10 @@ public class EncryptionUtil {
public static final int VERIFY_TOKEN_LENGTH = 4;
public static final String KEY_PAIR_ALGORITHM = "RSA";
private EncryptionUtil() {
//utility
}
/**
* Generate a RSA key pair
*
@@ -61,9 +64,9 @@ public class EncryptionUtil {
/**
* Generate the server id based on client and server data.
*
* @param sessionId session for the current login attempt
* @param sessionId session for the current login attempt
* @param sharedSecret shared secret between the client and the server
* @param publicKey public key of the server
* @param publicKey public key of the server
* @return the server id formatted as a hexadecimal string.
*/
public static String getServerIdHashString(String sessionId, Key sharedSecret, PublicKey publicKey) {
@@ -80,9 +83,9 @@ public class EncryptionUtil {
/**
* Decrypts the content and extracts the key spec.
*
* @param cipher decryption cipher
* @param cipher decryption cipher
* @param privateKey private key of the server
* @param sharedKey the encrypted shared key
* @param sharedKey the encrypted shared key
* @return shared secret key
* @throws GeneralSecurityException
*/
@@ -95,8 +98,8 @@ public class EncryptionUtil {
* Decrypted the given data using the cipher.
*
* @param cipher decryption cypher
* @param key server private key
* @param data the encrypted data
* @param key server private key
* @param data the encrypted data
* @return clear text data
* @throws GeneralSecurityException if it fails to initialize and decrypt the data
*/
@@ -109,14 +112,10 @@ public class EncryptionUtil {
throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
digest.update(sessionId.getBytes(Charsets.ISO_8859_1));
digest.update(sessionId.getBytes(StandardCharsets.ISO_8859_1));
digest.update(sharedSecret.getEncoded());
digest.update(publicKey.getEncoded());
return digest.digest();
}
private EncryptionUtil() {
//utility
}
}
@@ -4,15 +4,14 @@ import com.github.games647.fastlogin.bukkit.commands.CrackedCommand;
import com.github.games647.fastlogin.bukkit.commands.PremiumCommand;
import com.github.games647.fastlogin.bukkit.listener.BungeeListener;
import com.github.games647.fastlogin.bukkit.listener.JoinListener;
import com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener;
import com.github.games647.fastlogin.bukkit.listener.protocollib.ProtocolLibListener;
import com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener;
import com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener;
import com.github.games647.fastlogin.bukkit.tasks.DelayedAuthHook;
import com.github.games647.fastlogin.core.CommonUtil;
import com.github.games647.fastlogin.core.mojang.MojangApiConnector;
import com.github.games647.fastlogin.core.shared.FastLoginCore;
import com.github.games647.fastlogin.core.shared.PlatformPlugin;
import com.google.common.collect.Iterables;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.common.net.HostAndPort;
@@ -20,6 +19,7 @@ import com.google.common.net.HostAndPort;
import java.nio.file.Path;
import java.security.KeyPair;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadFactory;
@@ -124,13 +124,14 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
if (sender instanceof PluginMessageRecipient) {
notifyBungeeCord((PluginMessageRecipient) sender, target, activate, true);
} else {
Player firstPlayer = Iterables.getFirst(getServer().getOnlinePlayers(), null);
if (firstPlayer == null) {
Optional<? extends Player> optPlayer = getServer().getOnlinePlayers().stream().findFirst();
if (!optPlayer.isPresent()) {
logger.info("No player online to send a plugin message to the proxy");
return;
}
notifyBungeeCord(firstPlayer, target, activate, false);
notifyBungeeCord(optPlayer.get(), target, activate, false);
}
}