Fixed UltraAuth support

This commit is contained in:
games647
2016-03-05 21:47:28 +01:00
parent 099b8e5d0a
commit 9c0ad7d70c
4 changed files with 1412 additions and 62 deletions

View File

@ -1,7 +1,12 @@
######0.6
* Added /premium [player] command with optional player parameter
* Fixed 1.9 bugs
* Added UltraAuth support
######0.5 ######0.5
* Added unpremium command * Added unpremium command
* Added /premium [player] command with optional player parameter
* Added autologin - See config * Added autologin - See config
* Added config * Added config
* Added isRegistered API method * Added isRegistered API method

View File

@ -2,25 +2,20 @@ package com.github.games647.fastlogin.bukkit;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.Key; import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.KeyPairGenerator; import java.security.KeyPairGenerator;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException; import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
/** /**
@ -64,19 +59,19 @@ public class EncryptionUtil {
} }
} }
public static PublicKey decodePublicKey(byte[] encodedKey) { // public static PublicKey decodePublicKey(byte[] encodedKey) {
try { // try {
KeyFactory keyfactory = KeyFactory.getInstance("RSA"); // KeyFactory keyfactory = KeyFactory.getInstance("RSA");
//
X509EncodedKeySpec x509encodedkeyspec = new X509EncodedKeySpec(encodedKey); // X509EncodedKeySpec x509encodedkeyspec = new X509EncodedKeySpec(encodedKey);
return keyfactory.generatePublic(x509encodedkeyspec); // return keyfactory.generatePublic(x509encodedkeyspec);
} catch (NoSuchAlgorithmException | InvalidKeySpecException nosuchalgorithmexception) { // } catch (NoSuchAlgorithmException | InvalidKeySpecException nosuchalgorithmexception) {
//ignore // //ignore
} // }
//
System.err.println("Public key reconstitute failed!"); // System.err.println("Public key reconstitute failed!");
return null; // return null;
} // }
public static SecretKey decryptSharedKey(PrivateKey privateKey, byte[] encryptedSharedKey) { public static SecretKey decryptSharedKey(PrivateKey privateKey, byte[] encryptedSharedKey) {
return new SecretKeySpec(decryptData(privateKey, encryptedSharedKey), "AES"); return new SecretKeySpec(decryptData(privateKey, encryptedSharedKey), "AES");
@ -110,17 +105,17 @@ public class EncryptionUtil {
System.err.println("Cipher creation failed!"); System.err.println("Cipher creation failed!");
return null; return null;
} }
//
public static Cipher createBufferedBlockCipher(int operationMode, Key key) { // public static Cipher createBufferedBlockCipher(int operationMode, Key key) {
try { // try {
Cipher cipher = Cipher.getInstance("AES/CFB8/NoPadding"); // Cipher cipher = Cipher.getInstance("AES/CFB8/NoPadding");
//
cipher.init(operationMode, key, new IvParameterSpec(key.getEncoded())); // cipher.init(operationMode, key, new IvParameterSpec(key.getEncoded()));
return cipher; // return cipher;
} catch (GeneralSecurityException generalsecurityexception) { // } catch (GeneralSecurityException generalsecurityexception) {
throw new RuntimeException(generalsecurityexception); // throw new RuntimeException(generalsecurityexception);
} // }
} // }
private EncryptionUtil() { private EncryptionUtil() {
//utility //utility

View File

@ -56,6 +56,8 @@ public class BukkitJoinListener implements Listener {
if (session.needsRegistration()) { if (session.needsRegistration()) {
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName()); plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
plugin.getEnabledPremium().add(session.getUsername());
String generatedPassword = plugin.generateStringPassword(); String generatedPassword = plugin.generateStringPassword();
plugin.getAuthPlugin().forceRegister(player, generatedPassword); plugin.getAuthPlugin().forceRegister(player, generatedPassword);
player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: " player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: "