From f67d886000ebe435e217502024fc776d9c7c9c0f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 23 Nov 2017 23:25:56 +0100 Subject: [PATCH] Fixes, changed to port 443, more fixes Aaand I forgot to pull the master branch --- .gitignore | 2 ++ .settings/org.eclipse.jdt.core.prefs | 1 + pom.xml | 2 +- src/buttondevteam/website/AcmeClient.java | 26 ++++++++----------- .../website/ButtonWebsiteModule.java | 9 ++++--- src/buttondevteam/website/WebUser.java | 2 +- .../website/page/AcmeChallengePage.java | 14 +++++----- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 7d0ab85..d6ecfc9 100644 --- a/.gitignore +++ b/.gitignore @@ -218,3 +218,5 @@ TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar *.name .idea/compiler.xml *.xml + +upload_key diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 35068d9..714351a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml index 88c2608..d9ed662 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ - org.apache.commons + commons-io commons-io 1.3.2 provided diff --git a/src/buttondevteam/website/AcmeClient.java b/src/buttondevteam/website/AcmeClient.java index f0494ba..2564651 100644 --- a/src/buttondevteam/website/AcmeClient.java +++ b/src/buttondevteam/website/AcmeClient.java @@ -244,28 +244,24 @@ public class AcmeClient { * Domain name to be authorized * @return {@link Challenge} to verify */ - @SuppressWarnings("unused") public Challenge httpChallenge(Authorization auth, String domain) throws AcmeException { // Find a single http-01 challenge Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE); if (challenge == null) { throw new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do..."); } - if (ButtonWebsiteModule.PORT == 80) - LOG.info("Storing the challenge data."); - else - LOG.info("Store the challenge data! Can't do automatically."); + // if (ButtonWebsiteModule.PORT == 443) + LOG.info("Storing the challenge data."); + /* + * else LOG.info("Store the challenge data! Can't do automatically."); + */ LOG.info("It should be reachable at: http://" + domain + "/.well-known/acme-challenge/" + challenge.getToken()); - LOG.info("File name: " + challenge.getToken()); - LOG.info("Content: " + challenge.getAuthorization()); - LOG.info("Press any key to continue..."); - if (ButtonWebsiteModule.PORT != 80) - try { - System.in.read(); - } catch (IOException e) { - e.printStackTrace(); - } - ButtonWebsiteModule.addPage(new AcmeChallengePage(challenge.getToken(), challenge.getAuthorization())); + // LOG.info("File name: " + challenge.getToken()); + // LOG.info("Content: " + challenge.getAuthorization()); + /* + * LOG.info("Press any key to continue..."); if (ButtonWebsiteModule.PORT != 443) try { System.in.read(); } catch (IOException e) { e.printStackTrace(); } + */ + AcmeChallengePage.setValues(challenge.getToken(), challenge.getAuthorization()); return challenge; } diff --git a/src/buttondevteam/website/ButtonWebsiteModule.java b/src/buttondevteam/website/ButtonWebsiteModule.java index a219aab..5f783b8 100644 --- a/src/buttondevteam/website/ButtonWebsiteModule.java +++ b/src/buttondevteam/website/ButtonWebsiteModule.java @@ -31,7 +31,7 @@ import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.website.page.*; public class ButtonWebsiteModule extends JavaPlugin { - public static final int PORT = 8080; + public static final int PORT = 443; private static HttpsServer server; public ButtonWebsiteModule() { @@ -111,19 +111,22 @@ public class ButtonWebsiteModule extends JavaPlugin { @Override public void onEnable() { addPage(new IndexPage()); + addPage(new LoginPage()); + addPage(new ProfilePage()); TBMCCoreAPI.RegisterUserClass(WebUser.class); Bukkit.getScheduler().runTaskAsynchronously(this, () -> { this.getLogger().info("Starting webserver..."); server.setExecutor( new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue(100))); - ((Runnable) server::start).run(); // Totally normal way of calling a method - this.getLogger().info("Webserver started"); final Calendar calendar = Calendar.getInstance(); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week + addPage(new AcmeChallengePage()); // Add before the server gets started Thread t = new Thread(() -> AcmeClient.main("server.figytuna.com")); t.setContextClassLoader(getClass().getClassLoader()); t.start(); } + ((Runnable) server::start).run(); // Totally normal way of calling a method + this.getLogger().info("Webserver started"); }); } diff --git a/src/buttondevteam/website/WebUser.java b/src/buttondevteam/website/WebUser.java index 859e5ab..0b1558b 100644 --- a/src/buttondevteam/website/WebUser.java +++ b/src/buttondevteam/website/WebUser.java @@ -17,6 +17,6 @@ public class WebUser extends ChromaGamerBase { } public PlayerData sessionID() { - return data(); + return data(new UUID(0, 0)); } } diff --git a/src/buttondevteam/website/page/AcmeChallengePage.java b/src/buttondevteam/website/page/AcmeChallengePage.java index 0395166..353a9fe 100644 --- a/src/buttondevteam/website/page/AcmeChallengePage.java +++ b/src/buttondevteam/website/page/AcmeChallengePage.java @@ -6,11 +6,6 @@ import buttondevteam.website.io.Response; public class AcmeChallengePage extends Page { - public AcmeChallengePage(String token, String content) { - this.token = token; - this.content = content; - } - @Override public String GetName() { return ".well-known/acme-challenge/" + token; @@ -23,7 +18,12 @@ public class AcmeChallengePage extends Page { return new Response(200, content, exchange); } - private String token; - private String content; + private static String token; + private static String content; + + public static void setValues(String token, String content) { + AcmeChallengePage.token = token; + AcmeChallengePage.content = content; + } }