2023-12-02 00:26:57 -08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023 Braydon (Rainnny). All rights reserved.
|
|
|
|
*
|
|
|
|
* For inquiries, please contact braydonrainnny@gmail.com
|
|
|
|
*/
|
2023-05-30 22:54:34 -07:00
|
|
|
package me.braydon.license;
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import com.google.gson.GsonBuilder;
|
2023-05-31 16:10:56 -07:00
|
|
|
import jakarta.annotation.PostConstruct;
|
2023-05-30 22:54:34 -07:00
|
|
|
import lombok.NonNull;
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2023-05-31 16:10:56 -07:00
|
|
|
import org.mindrot.jbcrypt.BCrypt;
|
2023-05-30 22:54:34 -07:00
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Braydon
|
|
|
|
*/
|
|
|
|
@SpringBootApplication
|
2023-05-31 19:36:35 -07:00
|
|
|
@Slf4j(topic = "License Server")
|
2023-05-30 22:54:34 -07:00
|
|
|
public class LicenseServer {
|
|
|
|
public static final Gson GSON = new GsonBuilder()
|
|
|
|
.serializeNulls()
|
|
|
|
.create();
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
public static void main(@NonNull String[] args) {
|
|
|
|
File config = new File("application.yml");
|
|
|
|
if (!config.exists()) { // Saving the default config if it doesn't exist locally
|
|
|
|
Files.copy(Objects.requireNonNull(LicenseServer.class.getResourceAsStream("/application.yml")), config.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
log.info("Saved the default configuration to '{}', please re-launch the application", // Log the default config being saved
|
|
|
|
config.getAbsolutePath()
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log.info("Found configuration at '{}'", config.getAbsolutePath()); // Log the found config
|
|
|
|
SpringApplication.run(LicenseServer.class, args); // Load the application
|
|
|
|
}
|
2023-05-31 16:10:56 -07:00
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
public void onInitialize() {
|
|
|
|
// Log a randomly generated salt
|
|
|
|
log.info("Generated a random salt: {} (This is only for you to copy and paste for config)", BCrypt.gensalt());
|
|
|
|
}
|
2023-05-30 22:54:34 -07:00
|
|
|
}
|