From 09808204b5231fc2551dff4b77b18309ea51ab8a Mon Sep 17 00:00:00 2001 From: James Quinley Date: Thu, 10 Nov 2022 07:01:35 -0800 Subject: [PATCH] Set to beta server, this starts the transition to the "modern" framework. --- .idea/artifacts/AOTSKBetaServer.xml | 25 ++++++ .../delegationServices.java | 78 ++++++++++--------- .../DelegationServices/localNet.java | 2 +- .../DelegationServices/status.java | 2 +- 4 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 .idea/artifacts/AOTSKBetaServer.xml diff --git a/.idea/artifacts/AOTSKBetaServer.xml b/.idea/artifacts/AOTSKBetaServer.xml new file mode 100644 index 0000000..8399203 --- /dev/null +++ b/.idea/artifacts/AOTSKBetaServer.xml @@ -0,0 +1,25 @@ + + + $PROJECT_DIR$/out/artifacts/AOTSKBetaServer + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java b/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java index 5fdb676..ab905e4 100644 --- a/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java +++ b/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java @@ -260,22 +260,22 @@ public class delegationServices { } if (requesttype == 0) { - int CTOKEN = (int) Lrequest.get("Token"); + String CTOKEN = (String) Lrequest.get("Token"); System.out.println("Sync Request (Read)"); Document accountServer; String Password; - int Token; + String Token; String Fname; String Path; String UserName; String Email; try { accountServer = accountS.find(eq("Token", CTOKEN)).first(); - Token = (int) accountServer.get("Token"); + Token = (String) accountServer.get("Token"); if (accountServer.get("Status").equals(true)) { - if (Token == CTOKEN) { + if (Token.equals(CTOKEN)) { - Token = (int) accountServer.get("Token"); + Token = (String) accountServer.get("Token"); Password = (String) accountServer.get("Password"); Fname = (String) accountServer.get("FName"); Path = (String) accountServer.get("Path"); @@ -368,18 +368,18 @@ public class delegationServices { //sync write request if (requesttype == 1) { System.out.println("Sync Request (Write)"); - int CTOKEN = (int) Lrequest.get("Token"); + String CTOKEN = (String) Lrequest.get("Token"); Document accountServer; - int Token; + String Token; String Fname; String Path; String UserName; try { accountServer = accountS.find(eq("Token", CTOKEN)).first(); - Token = (int) accountServer.get("Token"); + Token = (String) accountServer.get("Token"); if (accountServer.get("Status").equals(true)) { - if (Token == CTOKEN) { - Token = (int) Lrequest.get("Token"); + if (Token.equals(CTOKEN)) { + Token = (String) Lrequest.get("Token"); Path = (String) Lrequest.get("Path"); System.out.println("Got info."); BasicDBObject searchQuery = new BasicDBObject(); @@ -454,7 +454,7 @@ public class delegationServices { String password = (String) Lrequest.get("Password"); Document accountServer; String Password; - int Token; + String Token; String Fname; String Path; String UserName; @@ -528,7 +528,7 @@ public class delegationServices { System.out.println("RSC"); if (Password.equals(password)) { System.out.println("R3c"); - Token = (int) accountServer.get("Token"); + Token = (String) accountServer.get("Token"); Fname = (String) accountServer.get("FName"); Path = (String) accountServer.get("Path"); Email = (String) accountServer.get("Email"); @@ -777,10 +777,10 @@ public class delegationServices { } if (requesttype == 3) { System.out.println("Login Request (TKN)"); - int CTOKEN = (int) Lrequest.get("Token"); + String CTOKEN = (String) Lrequest.get("Token"); // Document TResolve = dCollection.find(eq("type", 3)).first(); Document accountServer; - int TKN; + String TKN; String Password; String Fname; String Path; @@ -789,10 +789,10 @@ public class delegationServices { String keychainUUID; try { accountServer = accountS.find(eq("Token", CTOKEN)).first(); - TKN = (int) accountServer.get("Token"); + TKN = (String) accountServer.get("Token"); if (accountServer.get("Status").equals(true)) { - if (TKN == CTOKEN) { - TKN = (int) accountServer.get("Token"); + if (TKN.equals(CTOKEN)) { + TKN = (String) accountServer.get("Token"); Password = (String) accountServer.get("Password"); Fname = (String) accountServer.get("FName"); Path = (String) accountServer.get("Path"); @@ -1053,14 +1053,19 @@ public class delegationServices { String Password = (String) DServer.get("Password"); String Email = (String) DServer.get("Email"); String FName = (String) DServer.get("FName"); - int min = 100000000; - int max = 999999999; - double tokenGEN = Math.random() * (max - min + 1) + min; - int tokenSTGEN = (int) tokenGEN; + String sourcet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; + StringBuilder sbt = new StringBuilder(); + Random random = new Random(); + int tokenlength = 60; + for (int i = 0; i < tokenlength; i++) { + int index = random.nextInt(sourcet.length()); + char randomChar = sourcet.charAt(index); + sbt.append(randomChar); + } + String Token = sbt.toString(); //Above makes token, it will be remade if it already exists String source = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; StringBuilder sb = new StringBuilder(); - Random random = new Random(); int length = 40; for (int i = 0; i < length; i++) { int index = random.nextInt(source.length()); @@ -1088,19 +1093,26 @@ public class delegationServices { } catch (Exception exr) { System.out.println("Username Is Open"); try { - Document DupeToken = accountS.find(eq("Token", tokenSTGEN)).first(); - int DupeToke1n = (int) DupeToken.get("Token"); + Document DupeToken = accountS.find(eq("Token", Token)).first(); + String DupeToke1n = (String) DupeToken.get("Token"); System.out.println("Got Token from request"); Boolean TokenOpen = false; while (TokenOpen == false) { - tokenGEN = Math.random() * (max - min + 1) + min; - tokenSTGEN = (int) tokenGEN; + for (int i = 0; i < tokenlength; i++) { + int index = random.nextInt(sourcet.length()); + char randomChar = sourcet.charAt(index); + sbt.append(randomChar); + } + Token = sbt.toString(); try { - DupeToken = accountS.find(eq("Token", tokenSTGEN)).first(); - DupeToke1n = (int) DupeToken.get("Token"); + DupeToken = accountS.find(eq("Token", Token)).first(); + DupeToke1n = (String) DupeToken.get("Token"); System.out.println("Token Is Reserved, Try Again."); - tokenGEN = Math.random() * (max - min + 1) + min; - tokenSTGEN = (int) tokenGEN; + for (int i = 0; i < tokenlength; i++) { + int index = random.nextInt(sourcet.length()); + char randomChar = sourcet.charAt(index); + sbt.append(randomChar); + } } catch (Exception exDr) { TokenOpen = true; System.out.println("Token Free (While EXP)"); @@ -1157,7 +1169,7 @@ public class delegationServices { createForm.append("Entitlements", "NA"); createForm.append("Path", "C:\\ObsidianCoreStudios\\Application\\"); createForm.append("Freinds", " "); - createForm.append("Token", tokenSTGEN); + createForm.append("Token", Token); createForm.append("UUID", UUID); createForm.append("Control", 1); createForm.append("Upgrade", 0); @@ -1652,10 +1664,6 @@ public class delegationServices { delegationTimer.DeleteTargetRequest(ClientID); } } - - - //above is finding one request and starting wheels - //delegationTimer.trigger(); delegate(); } diff --git a/src/main/java/com/jamesquinley/DelegationServices/localNet.java b/src/main/java/com/jamesquinley/DelegationServices/localNet.java index 18b2e1d..8eaf68a 100644 --- a/src/main/java/com/jamesquinley/DelegationServices/localNet.java +++ b/src/main/java/com/jamesquinley/DelegationServices/localNet.java @@ -6,7 +6,7 @@ import com.mongodb.BasicDBObject; import static com.jamesquinley.DelegationServices.delegationServices.accountS; public class localNet { - public static void macRead (String NewMac, String OldMac, String email, String UName, int Token) + public static void macRead (String NewMac, String OldMac, String email, String UName, String Token) { if (OldMac.contains(NewMac)) { diff --git a/src/main/java/com/jamesquinley/DelegationServices/status.java b/src/main/java/com/jamesquinley/DelegationServices/status.java index 421c889..de7ede6 100644 --- a/src/main/java/com/jamesquinley/DelegationServices/status.java +++ b/src/main/java/com/jamesquinley/DelegationServices/status.java @@ -1,6 +1,6 @@ package com.jamesquinley.DelegationServices; public class status { - public static boolean betaServer = false; + public static boolean betaServer = true; public static String serverVersion = "1.1"; }