Fixed account issue, when no UUID dupe was found nullpointer was thrown and caused timeout and server to fail to serve new requests, looking for a cleaner fix but this works for now.

This commit is contained in:
James Quinley 2022-07-30 21:38:29 -07:00
parent a87023d196
commit 4fd6678791

View File

@ -1057,7 +1057,7 @@ public class delegationServices {
try { try {
Document DupeToken = accountS.find(eq("Token", tokenSTGEN)).first(); Document DupeToken = accountS.find(eq("Token", tokenSTGEN)).first();
int DupeToke1n = (int) DupeToken.get("Token"); int DupeToke1n = (int) DupeToken.get("Token");
System.out.println("Got Token from request");
Boolean TokenOpen = false; Boolean TokenOpen = false;
while (TokenOpen == false) { while (TokenOpen == false) {
tokenGEN = Math.random() * (max - min + 1) + min; tokenGEN = Math.random() * (max - min + 1) + min;
@ -1074,10 +1074,11 @@ public class delegationServices {
} }
} }
} catch (Exception token) { } catch (Exception token) {
System.out.println("Working on UUID");
try { try {
Document DupeUUID = accountS.find(eq("UUID", UUID)).first(); Document DupeUUID = accountS.find(eq("UUID", UUID)).first();
String DupeUUIDS = (String) DupeUUID.get("UUID"); String DupeUUIDS = (String) DupeUUID.get("UUID");
System.out.println("Got Gen UUID");
Boolean UUIDOPEN = false; Boolean UUIDOPEN = false;
while (UUIDOPEN == false) { while (UUIDOPEN == false) {
length = 40; length = 40;
@ -1089,6 +1090,7 @@ public class delegationServices {
} }
String UUIDGEN = sb.toString(); String UUIDGEN = sb.toString();
try { try {
System.out.println("Retry UUID");
DupeUUID = accountS.find(eq("UUID", UUID)).first(); DupeUUID = accountS.find(eq("UUID", UUID)).first();
DupeUUIDS = (String) DupeUUID.get("UUID"); DupeUUIDS = (String) DupeUUID.get("UUID");
System.out.println("UUID Is Reserved, Try Again."); System.out.println("UUID Is Reserved, Try Again.");
@ -1148,8 +1150,49 @@ public class delegationServices {
dCollection.updateOne(searchQuery, updateQuery1); dCollection.updateOne(searchQuery, updateQuery1);
System.out.println("Update Request With Finished Status"); System.out.println("Update Request With Finished Status");
delegationTimer.DeleteTargetRequest(ClientID); delegationTimer.DeleteTargetRequest(ClientID);
} catch (Exception uuid) { } catch (NullPointerException uuid) {
System.out.println("Something went wrong..."); System.out.println("Token & UUID Free (Main)");
System.out.println("Creating.");
Document createForm = new Document();
Document FnetInit = new Document();
createForm.append("User", User);
createForm.append("Password", Password);
createForm.append("Status", true);
createForm.append("Flagged", false);
createForm.append("Email", Email);
createForm.append("FName", FName);
createForm.append("Entitlements", "NA");
createForm.append("Path", "C:\\ObsidianCoreStudios\\Application\\");
createForm.append("Freinds", " ");
createForm.append("Token", tokenSTGEN);
createForm.append("UUID", UUID);
createForm.append("Control", 1);
createForm.append("Upgrade", 0);
createForm.append("Version","2");
createForm.append("keyStatus", false);
//createForm.append("Uid",uid);
createForm.append("lastNet", Macid);
accountS.insertOne(createForm);
FnetInit.append("User", User);
FnetInit.append("Status", true);
FnetInit.append("Friends", " ");
FnetInit.append("Token", tokenSTGEN);
FnetInit.append("UUID", UUID);
FnetInit.append("Control", 1);
FNETDOC.insertOne(FnetInit);
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
electronicMailHandler.Onboarding(Email, User);
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type", 4));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
dCollection.updateOne(searchQuery, updateQuery1);
System.out.println("Update Request With Finished Status");
delegationTimer.DeleteTargetRequest(ClientID);
} }
} }
@ -1160,7 +1203,7 @@ public class delegationServices {
//TODO rewrite to just need username, password will be set by system later //TODO rewrite to just need username, password will be set by system later
{ {
delegationTimer.DeleteTargetRequest(ClientID); delegationTimer.DeleteTargetRequest(ClientID);
System.out.println("Account Creation Request"); System.out.println("Shadow Account Creation Request");
Document DServer = dCollection.find(eq("clientid", ClientID)).first(); Document DServer = dCollection.find(eq("clientid", ClientID)).first();
String User = (String) DServer.get("User"); String User = (String) DServer.get("User");
String Password = (String) DServer.get("Password"); String Password = (String) DServer.get("Password");