aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-08 22:11:33 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-08 22:11:33 +0900
commitf6a3ae6948b940d0bcc2deddde37cdf2349cfa46 (patch)
tree982de5e91c079ddfde360c649792f8476379627f /src/main/java/kr
parent9dda9c40514b24b87e33006a0d65fb00e5d62bde (diff)
downloadSkyblock-Dungeons-Guide-f6a3ae6948b940d0bcc2deddde37cdf2349cfa46.tar.gz
Skyblock-Dungeons-Guide-f6a3ae6948b940d0bcc2deddde37cdf2349cfa46.tar.bz2
Skyblock-Dungeons-Guide-f6a3ae6948b940d0bcc2deddde37cdf2349cfa46.zip
put cap for readin
Diffstat (limited to 'src/main/java/kr')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java14
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java20
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java2
3 files changed, 26 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
index e41fadbe..cc2a6243 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
@@ -1,7 +1,5 @@
package kr.syeyoung.dungeonsguide;
-import com.auth0.jwt.JWT;
-import com.auth0.jwt.interfaces.DecodedJWT;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
@@ -52,14 +50,20 @@ public class Authenticator {
String jwt = requestAuth(session.getProfile());
MinecraftSessionService yggdrasilMinecraftSessionService = Minecraft.getMinecraft().getSessionService();
- DecodedJWT jwt2 = JWT.decode(jwt);
- String hash = calculateAuthHash(DatatypeConverter.parseBase64Binary(jwt2.getClaim("sharedSecret").asString()),
- DatatypeConverter.parseBase64Binary(jwt2.getClaim("publicKey").asString()));
+ JsonObject jwt2 = parseJWT(jwt);
+ String hash = calculateAuthHash(DatatypeConverter.parseBase64Binary(jwt2.get("sharedSecret").getAsString()),
+ DatatypeConverter.parseBase64Binary(jwt2.get("publicKey").getAsString()));
yggdrasilMinecraftSessionService.joinServer(session.getProfile(), token, hash);
this.token = requestAuth2(jwt, keyPair.getPublic());
return this.token;
}
+ public JsonObject parseJWT(String jwt) {
+ String payload = jwt.split("\\.")[1].replace("+", "-").replace("/", "_");
+ String json = new String(DatatypeConverter.parseBase64Binary(payload));
+ return (JsonObject) new JsonParser().parse(json);
+ }
+
private String requestAuth(GameProfile profile) throws IOException {
HttpURLConnection huc = (HttpURLConnection) new URL(DOMAIN+"auth/requestAuth").openConnection();
huc.setRequestProperty("User-Agent", "DungeonsGuide/1.0");
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java b/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
index dc440405..e3a7e255 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
@@ -44,16 +44,26 @@ public class NetworkClassLoader extends ClassLoader {
}
private byte[] loadClassFromFile(String fileName) throws BadPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException {
- byte[] buffer;
InputStream inputStream = authenticator.getInputStream(fileName.replace('.', '/')+ ".class");
+ long length = 0;
+ {
+ for (int i = 4; i >= 0; i--) {
+ length |= (inputStream.read() & 0xFF) << i * 8;
+ }
+ }
+
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
int nextValue = 0;
try {
- while ( (nextValue = inputStream.read()) != -1 ) {
- byteStream.write(nextValue);
+ byte[] buffer = new byte[1024];
+ while ( (inputStream.read(buffer)) != -1 ) {
+ byteStream.write(buffer);
}
} catch (Exception e) {}
- buffer = byteStream.toByteArray();
- return buffer;
+ byte[] byte1 = byteStream.toByteArray();
+ byte[] byte2 = new byte[(int) length];
+ System.arraycopy(byte1, 0, byte2, 0, byte2.length);
+
+ return byte2;
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java
index 3119311a..2fc225df 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java
@@ -68,6 +68,7 @@ public class DungeonRoomInfoRegistry {
uuidMap.clear();
Authenticator authenticator = DungeonsGuide.getDungeonsGuide().getAuthenticator();
InputStream inputStream = authenticator.getInputStream("roomdata/datas.txt");
+ inputStream.read(new byte[4]);
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String name;
while ((name = br.readLine()) != null) {
@@ -75,6 +76,7 @@ public class DungeonRoomInfoRegistry {
if (name.endsWith(".roomdata")) continue;
try {
InputStream fis = authenticator.getInputStream(name);
+ fis.read(new byte[4]);
ObjectInputStream ois = new ObjectInputStream(fis);
DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject();
ois.close();