UUID is mostly ready for prod line, it can generate and retry if an existing UUID is made.

This commit is contained in:
James Quinley 2022-07-02 16:39:18 -07:00
parent c705a5615a
commit 5d95990a0e

View File

@ -1024,8 +1024,19 @@ public class delegationServices {
int max = 999999999; int max = 999999999;
double tokenGEN = Math.random() * (max - min + 1) + min; double tokenGEN = Math.random() * (max - min + 1) + min;
int tokenSTGEN = (int) tokenGEN; int tokenSTGEN = (int) tokenGEN;
//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());
char randomChar = source.charAt(index);
sb.append(randomChar);
}
String UUID = sb.toString();
//Above makes UUID, will be remade if it already exists.
//verify open cert
try { try {
Document DupeUser = accountS.find(eq("User", User)).first(); Document DupeUser = accountS.find(eq("User", User)).first();
String DUPE = (String) DupeUser.get("User"); String DUPE = (String) DupeUser.get("User");
@ -1062,48 +1073,84 @@ public class delegationServices {
System.out.println("Token Free (While EXP)"); System.out.println("Token Free (While EXP)");
} }
} }
} catch (Exception exrs) { } catch (Exception token) {
UUID uid = UUID.randomUUID(); try {
System.out.println("Token Free (Main)"); Document DupeUUID = accountS.find(eq("UUID", UUID)).first();
System.out.println("Creating."); String DupeUUIDS = (String) DupeUUID.get("UUID");
Document createForm = new Document();
Document FnetInit = new Document(); Boolean UUIDOPEN = false;
createForm.append("User", User); while (UUIDOPEN == false) {
createForm.append("Password", Password); length = 40;
createForm.append("Status", true); sb = new StringBuilder();
createForm.append("Flagged", false); for (int i = 0; i < length; i++) {
createForm.append("Email", Email); int index = random.nextInt(source.length());
createForm.append("FName", FName); char randomChar = source.charAt(index);
createForm.append("Entitlements", "NA"); sb.append(randomChar);
createForm.append("Path", "C:\\ObsidianCoreStudios\\Application\\"); }
createForm.append("Freinds", " "); String UUIDGEN = sb.toString();
createForm.append("Token", tokenSTGEN); try {
createForm.append("Control", 1); DupeUUID = accountS.find(eq("UUID", UUID)).first();
createForm.append("Upgrade", 0); DupeUUIDS = (String) DupeUUID.get("UUID");
createForm.append("Version","2"); System.out.println("UUID Is Reserved, Try Again.");
createForm.append("keyStatus", false); length = 40;
//createForm.append("Uid",uid); sb = new StringBuilder();
createForm.append("lastNet", Macid); for (int i = 0; i < length; i++) {
accountS.insertOne(createForm); int index = random.nextInt(source.length());
FnetInit.append("User", User); char randomChar = source.charAt(index);
FnetInit.append("Status", true); sb.append(randomChar);
FnetInit.append("Freinds", " "); }
FnetInit.append("Token", tokenSTGEN); UUIDGEN = sb.toString();
FnetInit.append("Control", 1); UUID = UUIDGEN;
FNETDOC.insertOne(FnetInit); } catch (Exception exDr) {
BasicDBObject searchQuery = new BasicDBObject(); UUIDOPEN = true;
searchQuery.append("clientid", ClientID); System.out.println("UUID Free (While EXP)" + exDr);
electronicMailHandler.Onboarding(Email, User); }
BasicDBObject updateQuery = new BasicDBObject(); }
BasicDBObject updateQuery1 = new BasicDBObject(); System.out.println("Token & UUID Free (Main)");
updateQuery.append("$set", System.out.println("Creating.");
new BasicDBObject().append("type", 4)); Document createForm = new Document();
updateQuery1.append("$set", Document FnetInit = new Document();
new BasicDBObject().append("status", true)); createForm.append("User", User);
dCollection.updateOne(searchQuery, updateQuery); createForm.append("Password", Password);
dCollection.updateOne(searchQuery, updateQuery1); createForm.append("Status", true);
System.out.println("Update Request With Finished Status"); createForm.append("Flagged", false);
delegationTimer.DeleteTargetRequest(ClientID); 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);
} catch (Exception uuid) {
System.out.println("Something went wrong...");
}
} }