Minor clean up
This commit is contained in:
21 files changed
+52
-52
No files matched your search
+1
-1
@@ -80,7 +80,7 @@ public abstract class ToggleCommand implements CommandExecutor {
|
||||
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
|
||||
} else {
|
||||
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
|
||||
if (!optPlayer.isPresent()) {
|
||||
if (optPlayer.isEmpty()) {
|
||||
plugin.getLog().info("No player online to send a plugin message to the proxy");
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Base64.Encoder;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
/**
|
||||
* Encryption and decryption minecraft util for connection between servers
|
||||
@@ -116,7 +116,7 @@ final class EncryptionUtil {
|
||||
* @param random random generator
|
||||
* @return a token with 4 bytes long
|
||||
*/
|
||||
public static byte[] generateVerifyToken(Random random) {
|
||||
public static byte[] generateVerifyToken(RandomGenerator random) {
|
||||
byte[] token = new byte[VERIFY_TOKEN_LENGTH];
|
||||
random.nextBytes(token);
|
||||
return token;
|
||||
|
||||
+2
-2
@@ -204,7 +204,7 @@ public class ProtocolLibListener extends PacketAdapter {
|
||||
Either<byte[], ?> either = packet.getSpecificModifier(Either.class).read(0);
|
||||
if (clientPublicKey == null) {
|
||||
Optional<byte[]> left = either.left();
|
||||
if (!left.isPresent()) {
|
||||
if (left.isEmpty()) {
|
||||
plugin.getLog().error("No verify token sent if requested without player signed key {}", sender);
|
||||
return false;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class ProtocolLibListener extends PacketAdapter {
|
||||
return EncryptionUtil.verifyNonce(expectedToken, keyPair.getPrivate(), left.get());
|
||||
} else {
|
||||
Optional<?> optSignatureData = either.right();
|
||||
if (!optSignatureData.isPresent()) {
|
||||
if (optSignatureData.isEmpty()) {
|
||||
plugin.getLog().error("No signature given to sent player signing key {}", sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class EncryptionUtilTest {
|
||||
|
||||
@Test
|
||||
void testVerifyToken() {
|
||||
val random = ThreadLocalRandom.current();
|
||||
@SuppressWarnings("SharedThreadLocalRandom") val random = ThreadLocalRandom.current();
|
||||
byte[] token = EncryptionUtil.generateVerifyToken(random);
|
||||
|
||||
assertAll(
|
||||
|
||||
+4
@@ -50,6 +50,10 @@ import java.util.Base64;
|
||||
|
||||
public class ResourceLoader {
|
||||
|
||||
private ResourceLoader() {
|
||||
// Utility
|
||||
}
|
||||
|
||||
public static RSAPrivateKey parsePrivateKey(String keySpec)
|
||||
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
try (
|
||||
|
||||
Reference in new issue
Block a user