Объеденение в один .php файл

This commit is contained in:
sasha0552 2019-04-07 22:47:27 +06:00
parent 737568dd93
commit 71cf43ca12

View file

@ -10,19 +10,11 @@
import java.util.UUID;
public final class RequestAuthHandler extends AuthHandler {
// Из конфига строки
private String urlGetAll;
private String urlGetUUID;
private String urlGetUsername;
private String urlUpdateAccessToken;
private String urlUpdateServerID;
// TODO Обьеденить все
private String url;
@Override
public void init() {
if (urlGetAll == null) LogHelper.error("[Verify][AuthHandler] urlGetAll cannot be null");
if (urlGetUUID == null) LogHelper.error("[Verify][AuthHandler] urlGetUUID cannot be null");
if (urlGetUsername == null) LogHelper.error("[Verify][AuthHandler] urlGetUsername cannot be null");
if (url == null) LogHelper.error("[Verify][AuthHandler] urlGetAll cannot be null");
}
@Override
@ -33,14 +25,14 @@ public UUID auth(AuthProviderResult authResult) throws IOException {
@Override
public UUID checkServer(String username, String serverID) throws IOException {
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(urlGetUUID, "type", "GetUUID", "username", IOHelper.urlEncode(username))));
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(url, "type", "GetUUID", "username", IOHelper.urlEncode(username))));
UUID stringTOuuid = UUID.fromString(currentResponse);
return stringTOuuid;
}
@Override
public boolean joinServer(String username, String accessToken, String serverID) throws IOException {
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(urlGetAll, "type", "GetAll", "username", IOHelper.urlEncode(username), "accessToken", IOHelper.urlEncode(accessToken), "serverID", IOHelper.urlEncode(serverID))));
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(url, "type", "GetAll", "username", IOHelper.urlEncode(username), "accessToken", IOHelper.urlEncode(accessToken), "serverID", IOHelper.urlEncode(serverID))));
String[] joinServerParams = currentResponse.split(":");
if (joinServerParams[0] == username && joinServerParams[1] == accessToken) {
if (joinServerParams[2] == serverID || joinServerParams == null) {
@ -52,7 +44,7 @@ public boolean joinServer(String username, String accessToken, String serverID)
@Override
public UUID usernameToUUID(String username) throws IOException {
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(urlGetUUID, "type", "GetUUID", "username", IOHelper.urlEncode(username))));
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(url, "type", "GetUUID", "username", IOHelper.urlEncode(username))));
UUID stringTOuuid = UUID.fromString(currentResponse);
return stringTOuuid;
}
@ -60,7 +52,7 @@ public UUID usernameToUUID(String username) throws IOException {
@Override
public String uuidToUsername(UUID uuid) throws IOException {
String uuidTOstring = uuid.toString();
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(urlGetUsername, "type", "GetUsername", "uuid", IOHelper.urlEncode(uuidTOstring))));
String currentResponse = IOHelper.request(new URL(CommonHelper.replace(url, "type", "GetUsername", "uuid", IOHelper.urlEncode(uuidTOstring))));
return currentResponse;
}