aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/Authenticator.java17
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java3
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/Main.java16
3 files changed, 28 insertions, 8 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
index 44e0908c..5b15fde6 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
@@ -28,6 +28,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.util.Session;
import net.minecraftforge.fml.common.ProgressManager;
import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
@@ -129,8 +130,12 @@ public class Authenticator {
connection.setDoOutput(true);
connection.getOutputStream().write(("{\"uuid\":\""+profile.getId().toString()+"\",\"nickname\":\""+profile.getName()+"\"}").getBytes());
- InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream());
- JsonObject json = (JsonObject) new JsonParser().parse(inputStreamReader);
+ String payload = String.join("\n", IOUtils.readLines(connection.getErrorStream() == null ? connection.getInputStream() : connection.getErrorStream()));
+ if (connection.getResponseCode() >= 400)
+ System.out.println("https://dungeons.guide/auth/requestAuth :: Received "+connection.getResponseCode()+" along with\n"+payload);
+
+ JsonObject json = (JsonObject) new JsonParser().parse(payload);
+
if (!"ok".equals(json.get("status").getAsString())) {
return null;
}
@@ -145,9 +150,11 @@ public class Authenticator {
urlConnection.setDoOutput(true);
urlConnection.getOutputStream().write(("{\"jwt\":\""+tempToken+"\",\"publicKey\":\""+Base64.encodeBase64URLSafeString(clientKey.getEncoded())+"\"}").getBytes());
- urlConnection.getResponseCode();
- InputStreamReader reader = new InputStreamReader(urlConnection.getInputStream());
- JsonObject jsonObject = (JsonObject) new JsonParser().parse(reader);
+ String payload = String.join("\n", IOUtils.readLines(urlConnection.getErrorStream() == null ? urlConnection.getInputStream() : urlConnection.getErrorStream()));
+ if (urlConnection.getResponseCode() >= 400)
+ System.out.println("https://dungeons.guide/auth/authenticate :: Received "+urlConnection.getResponseCode()+" along with\n"+payload);
+
+ JsonObject jsonObject = (JsonObject) new JsonParser().parse(payload);
if (!"ok".equals(jsonObject.get("status").getAsString())) {
return null;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
index da277b2c..63ba70a9 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
@@ -143,8 +143,7 @@ public class DungeonsGuide implements DGInterface, CloseListener {
MinecraftForge.EVENT_BUS.register(cosmeticsManager);
try {
- stompConnection = new StompClient(new URI(stompURL), authenticator.getToken(), this);
- MinecraftForge.EVENT_BUS.post(new StompConnectedEvent(stompConnection));
+ connectStomp();
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Main.java b/src/main/java/kr/syeyoung/dungeonsguide/Main.java
index 873cb6e0..6e2e887e 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/Main.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Main.java
@@ -68,7 +68,17 @@ public class Main
MinecraftForge.EVENT_BUS.register(this);
if (dgInterface != null) {
main = this;
- dgInterface.init(initializationEvent);
+ try {
+ dgInterface.init(initializationEvent);
+ } catch (Exception e) {
+ cause = e;
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ PrintStream printStream = new PrintStream(byteArrayOutputStream);
+ e.printStackTrace(printStream);
+ stacktrace = new String(byteArrayOutputStream.toByteArray());
+
+ e.printStackTrace();
+ }
}
}
@@ -111,6 +121,8 @@ public class Main
while (progressBar.getStep() < progressBar.getSteps())
progressBar.step("random-"+progressBar.getStep());
ProgressManager.pop(progressBar);
+
+ e.printStackTrace();
}
}
} catch (IOException | AuthenticationException | NoSuchAlgorithmException | CertificateException | KeyStoreException | KeyManagementException | InvalidKeySpecException | SignatureException e) {
@@ -123,6 +135,8 @@ public class Main
while (progressBar.getStep() < progressBar.getSteps())
progressBar.step("random-"+progressBar.getStep());
ProgressManager.pop(progressBar);
+
+ e.printStackTrace();
}
}