mirror of
https://github.com/gnmyt/LicenseAPI.git
synced 2026-01-10 10:11:47 +00:00
Update LicenseValidator.java
This commit is contained in:
@ -19,7 +19,8 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class LicenseValidator {
|
public class LicenseValidator {
|
||||||
|
|
||||||
private static final String BASE_URL = "https://api.licenseapi.de/v1/";
|
private final int API_VERSION = 1;
|
||||||
|
private final String baseUrl;
|
||||||
private final String validationKey;
|
private final String validationKey;
|
||||||
|
|
||||||
private int retries = 3;
|
private int retries = 3;
|
||||||
@ -27,10 +28,12 @@ public class LicenseValidator {
|
|||||||
/**
|
/**
|
||||||
* Creates a new {@link LicenseValidator} with the given validation key.
|
* Creates a new {@link LicenseValidator} with the given validation key.
|
||||||
*
|
*
|
||||||
|
* @param baseUrl The base url of your LicenseAPI server (e.g. https://your-server.de)
|
||||||
* @param validationKey The validation key of your project. You can find it in the project
|
* @param validationKey The validation key of your project. You can find it in the project
|
||||||
* settings.
|
* settings.
|
||||||
*/
|
*/
|
||||||
public LicenseValidator(String validationKey) {
|
public LicenseValidator(String baseUrl, String validationKey) {
|
||||||
|
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
|
||||||
this.validationKey = validationKey;
|
this.validationKey = validationKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +45,7 @@ public class LicenseValidator {
|
|||||||
*/
|
*/
|
||||||
private String retrieveLicenseRaw(String licenseKey) {
|
private String retrieveLicenseRaw(String licenseKey) {
|
||||||
try {
|
try {
|
||||||
String url = String.format("%s/validate/%s", BASE_URL, URLDecoder.decode(licenseKey, "UTF-8"));
|
String url = String.format("%s/api/v%s/validate/%s", baseUrl, API_VERSION, URLDecoder.decode(licenseKey, "UTF-8"));
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
|
|||||||
Reference in New Issue
Block a user