-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>me.hsgamer</groupId> | ||
<artifactId>hscore-license</artifactId> | ||
<version>4.3.27-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>hscore-license-spigotmc</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>me.hsgamer</groupId> | ||
<artifactId>hscore-license-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
...cense-spigotmc/src/main/java/me/hsgamer/hscore/license/spigotmc/SpigotLicenseChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package me.hsgamer.hscore.license.spigotmc; | ||
|
||
import me.hsgamer.hscore.license.common.LicenseChecker; | ||
import me.hsgamer.hscore.license.common.LicenseResult; | ||
|
||
public class SpigotLicenseChecker implements LicenseChecker { | ||
private final String resource; | ||
private final SpigotLicenseFetcher fetcher; | ||
|
||
public SpigotLicenseChecker(String resource, SpigotLicenseFetcher fetcher) { | ||
this.resource = resource; | ||
this.fetcher = fetcher; | ||
} | ||
|
||
public SpigotLicenseChecker(String resource) { | ||
this(resource, SpigotLicenseFetcher.defaultFetcher()); | ||
} | ||
|
||
@Override | ||
public LicenseResult checkLicense() { | ||
SpigotLicenseEntry entry = fetcher.fetchLicense(); | ||
return new LicenseResult(entry.isValid() && resource.equals(entry.getResource()), entry.toProperties()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...license-spigotmc/src/main/java/me/hsgamer/hscore/license/spigotmc/SpigotLicenseEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.hsgamer.hscore.license.spigotmc; | ||
|
||
import me.hsgamer.hscore.license.common.CommonLicenseProperty; | ||
import me.hsgamer.hscore.license.common.LicenseProperties; | ||
|
||
public class SpigotLicenseEntry { | ||
private final String user; | ||
private final String resource; | ||
private final String nonce; | ||
|
||
public SpigotLicenseEntry(String user, String resource, String nonce) { | ||
this.user = user; | ||
this.resource = resource; | ||
this.nonce = nonce; | ||
} | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
public String getResource() { | ||
return resource; | ||
} | ||
|
||
public String getNonce() { | ||
return nonce; | ||
} | ||
|
||
public boolean isValid() { | ||
return | ||
user != null && !user.contains("__USER__") | ||
&& resource != null && !resource.contains("__RESOURCE__") | ||
&& nonce != null && !nonce.contains("__NONCE__"); | ||
} | ||
|
||
public LicenseProperties toProperties() { | ||
LicenseProperties properties = new LicenseProperties(); | ||
properties.setProperty(CommonLicenseProperty.USER, user); | ||
properties.setProperty(CommonLicenseProperty.RESOURCE, resource); | ||
properties.setProperty(CommonLicenseProperty.NONCE, nonce); | ||
return properties; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...cense-spigotmc/src/main/java/me/hsgamer/hscore/license/spigotmc/SpigotLicenseFetcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.hsgamer.hscore.license.spigotmc; | ||
|
||
public interface SpigotLicenseFetcher { | ||
static SpigotLicenseFetcher defaultFetcher() { | ||
return () -> { | ||
// Will be replaced by SpigotMC | ||
return new SpigotLicenseEntry( | ||
"%%__USER__%%", | ||
"%%__RESOURCE__%%", | ||
"%%__NONCE__%%" | ||
); | ||
}; | ||
} | ||
|
||
SpigotLicenseEntry fetchLicense(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters