From cca62351793c7733206260cb5f12e19a18cb63cb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 12 Jun 2018 00:14:07 +0200 Subject: [PATCH] Updated Acme client, needs migrating --- pom.xml | 10 ++---- src/buttondevteam/website/AcmeClient.java | 34 ++++++++----------- .../website/ButtonWebsiteModule.java | 3 +- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 67befd7..684028b 100644 --- a/pom.xml +++ b/pom.xml @@ -45,11 +45,6 @@ - - - - - *:* @@ -126,15 +121,16 @@ master-SNAPSHOT provided + org.shredzone.acme4j acme4j-client - 0.10 + 2.1 org.shredzone.acme4j acme4j-utils - 0.10 + 2.1 diff --git a/src/buttondevteam/website/AcmeClient.java b/src/buttondevteam/website/AcmeClient.java index 9722667..b00a61a 100644 --- a/src/buttondevteam/website/AcmeClient.java +++ b/src/buttondevteam/website/AcmeClient.java @@ -13,23 +13,14 @@ */ //Modified package buttondevteam.website; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Writer; -import java.net.URI; -import java.security.KeyPair; -import java.security.cert.X509Certificate; -import java.util.Arrays; -import java.util.Collection; - -import org.shredzone.acme4j.*; +import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.website.page.AcmeChallengePage; +import org.shredzone.acme4j.Authorization; +import org.shredzone.acme4j.Certificate; +import org.shredzone.acme4j.Session; +import org.shredzone.acme4j.Status; import org.shredzone.acme4j.challenge.Challenge; import org.shredzone.acme4j.challenge.Http01Challenge; -import org.shredzone.acme4j.exception.AcmeConflictException; import org.shredzone.acme4j.exception.AcmeException; import org.shredzone.acme4j.util.CSRBuilder; import org.shredzone.acme4j.util.CertificateUtils; @@ -37,8 +28,12 @@ import org.shredzone.acme4j.util.KeyPairUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import buttondevteam.lib.TBMCCoreAPI; -import buttondevteam.website.page.AcmeChallengePage; +import java.io.*; +import java.net.URI; +import java.security.KeyPair; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.Collection; /** * A simple client test tool. @@ -73,12 +68,11 @@ public class AcmeClient { // Load the user key file. If there is no key file, create a new one. // Keep this key pair in a safe place! In a production environment, you will not be // able to access your account again if you should lose the key pair. - KeyPair userKeyPair = loadOrCreateKeyPair(USER_KEY_FILE); + KeyPair userKeyPair = loadOrCreateKeyPair(USER_KEY_FILE); //TODO: Migrate to new version // Create a session for Let's Encrypt. // Use "acme://letsencrypt.org" for production server - Session session = new Session("acme://letsencrypt.org" + (TBMCCoreAPI.IsTestServer() ? "/staging" : ""), - userKeyPair); + Session session = new Session("acme://letsencrypt.org" + (TBMCCoreAPI.IsTestServer() ? "/staging" : "")); // Get the Registration to the account. // If there is no account yet, create a new one. diff --git a/src/buttondevteam/website/ButtonWebsiteModule.java b/src/buttondevteam/website/ButtonWebsiteModule.java index c1f022a..6e21f05 100644 --- a/src/buttondevteam/website/ButtonWebsiteModule.java +++ b/src/buttondevteam/website/ButtonWebsiteModule.java @@ -132,7 +132,8 @@ public class ButtonWebsiteModule extends JavaPlugin { } }); final Calendar calendar = Calendar.getInstance(); - if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week + //if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week + if (true) { //TODO: TMP Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); AcmeClient.main("server.figytuna.com"); // Task is running async so we don't need an extra thread }