50 lines
1.4 KiB
Java
50 lines
1.4 KiB
Java
package xyz.etztech.serverapi.token;
|
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class TokenList {
|
|
private final boolean protectGET;
|
|
private final boolean protectPOST;
|
|
private final List<Token> tokens;
|
|
|
|
public TokenList(boolean protectGET, boolean protectPOST, List<Token> tokens) {
|
|
this.protectGET = protectGET;
|
|
this.protectPOST = protectPOST;
|
|
this.tokens = tokens;
|
|
}
|
|
|
|
public TokenList(ConfigurationSection auth) {
|
|
if (auth == null) {
|
|
this.protectGET = false;
|
|
this.protectPOST = false;
|
|
this.tokens = null;
|
|
return;
|
|
}
|
|
this.protectGET = auth.getBoolean("get", true);
|
|
this.protectPOST = auth.getBoolean("post", true);
|
|
this.tokens = new ArrayList<>();
|
|
ConfigurationSection tokenSection = auth.getConfigurationSection("tokens");
|
|
if (tokenSection == null) {
|
|
return;
|
|
}
|
|
for (String token : tokenSection.getKeys(false)) {
|
|
this.tokens.add(new Token(token, TokenScope.parseScope(tokenSection.getString(token, "none"))));
|
|
}
|
|
}
|
|
|
|
public boolean isProtectGET() {
|
|
return protectGET;
|
|
}
|
|
|
|
public boolean isProtectPOST() {
|
|
return protectPOST;
|
|
}
|
|
|
|
public List<Token> getTokens() {
|
|
return tokens;
|
|
}
|
|
}
|