Tells the truth.

This commit is contained in:
James Quinley 2022-10-24 22:13:58 -07:00
parent 0637de4866
commit 675c315f2b
4 changed files with 446 additions and 487 deletions

View File

@ -149,7 +149,7 @@
<addClasspath>true</addClasspath>
<!-- Specifies that all dependencies of our application are found -->
<!-- Configures the main class of the application -->
<mainClass>com.jamesquinley.init</mainClass>
<mainClass>com.jamesquinley.Main</mainClass>
</manifest>
</archive>
</configuration>

View File

@ -15,15 +15,10 @@ import org.bson.Document;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import static com.jamesquinley.Asecure.electronicMailHandler.*;
import static com.jamesquinley.Asecure.secureCalls.accountMigrationComplete;
@ -38,11 +33,10 @@ public class delegationServices {
static MongoCollection<Document> dCollection;
static MongoDatabase RGFilterDB;
static MongoCollection<Document> RGFilter;
public static void connectionInit (Boolean beta)
{
public static void connectionInit(Boolean beta) {
//TODO Send Server Version As Standard.
if (beta == true)
{
if (beta == true) {
scReadconnectionString = new ConnectionString("mongodb+srv://serverClientBeta:Unz6c3I0wjrUVBIf@delegationrequest.qnvfa.mongodb.net/mDelegationRequest?retryWrites=true&w=majority");
//connects to database that beta clients can use.
System.out.println("This is a beta server build (and will only work on that type)");
@ -57,8 +51,7 @@ public class delegationServices {
dCollection = dClientDatabase.getCollection("accountRequestBeta");
RGFilterDB = dClient.getDatabase("rgcon");
RGFilter = RGFilterDB.getCollection("blocked");
} else
{
} else {
scReadconnectionString = new ConnectionString("mongodb+srv://serverClient:x2sJ8Qu0VVMifNLX@accountdelegation.n06hb.mongodb.net/DelegationRequest?retryWrites=true&w=majority");
//connects to database that production clients can use
System.out.println("This is a production server build (and will only work on that type)");
@ -75,7 +68,8 @@ public class delegationServices {
RGFilter = RGFilterDB.getCollection("blocked");
}
}
//TODO get switcher working, NPE currently triggers on post init, move below code block into if statement, or outside of it so it will do the same thing regardless of t/f switch output
//TODO get switcher working, NPE currently triggers on post init, move below code block into if statement, or outside of it so it will do the same thing regardless of t/f switch output
static ConnectionString AccountCon = new ConnectionString("mongodb+srv://DelegationServerClient:UNxldb8abSJkWscG@account.ufgrh.mongodb.net/account?retryWrites=true&w=majority");
static MongoClientSettings AccountSettings = MongoClientSettings.builder()
.applyConnectionString(AccountCon)
@ -92,13 +86,12 @@ public class delegationServices {
public static String lastNet = null;
public static String Macid = null;
public static void banUserID(String UUID)
{
public static void banUserID(String UUID) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("UUID", UUID);
BasicDBObject updateQuery2 = new BasicDBObject();
updateQuery2.append("$set",
new BasicDBObject().append("Status",false));
new BasicDBObject().append("Status", false));
accountS.updateOne(searchQuery, updateQuery2);
}
@ -106,8 +99,7 @@ public class delegationServices {
Document Filter;
int ClientID = 0;
Document Lrequest = dCollection.find(eq("status", false)).first();
if ((boolean) Lrequest.get("status") == true)
{
if ((boolean) Lrequest.get("status") == true) {
System.out.println("This request was completed, ignoring");
@ -130,10 +122,8 @@ public class delegationServices {
String RG = (String) Lrequest.get("rg");
Filter = RGFilter.find(eq("rgkey", "UAROCKS")).first();
String blockedRG = (String) Filter.get("rgflag");
if ((Boolean)Filter.get("serviceState") == false)
{
if ((Boolean)Filter.get("serviceTermination") == true)
{
if ((Boolean) Filter.get("serviceState") == false) {
if ((Boolean) Filter.get("serviceTermination") == true) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("rid", Lrequest.get("rid"));
@ -143,15 +133,14 @@ public class delegationServices {
updateQuery.append("$set",
new BasicDBObject().append("type", 60));
updateQuery2.append("$set",
new BasicDBObject().append("dn",Filter.get("serviceTerminationNotes")));
new BasicDBObject().append("dn", Filter.get("serviceTerminationNotes")));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
dCollection.updateOne(searchQuery, updateQuery2);
dCollection.updateOne(searchQuery, updateQuery1);
delegationTimer.DeleteTargetRequest(ClientID);
} else
{
} else {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("rid", Lrequest.get("rid"));
@ -161,7 +150,7 @@ public class delegationServices {
updateQuery.append("$set",
new BasicDBObject().append("type", 52));
updateQuery2.append("$set",
new BasicDBObject().append("dn",Filter.get("deniedmsg")));
new BasicDBObject().append("dn", Filter.get("deniedmsg")));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -481,12 +470,11 @@ public class delegationServices {
if (accountServer.get("Version").equals("1")) {
try {
accountKeyStatus = accountServer.getBoolean("keyStatus");
} catch (Exception NPE)
{
} catch (Exception NPE) {
System.out.println("Assuming False Due To Variable Not Existing For User.");
accountKeyStatus = false;
}
if (accountKeyStatus == false ) {
if (accountKeyStatus == false) {
System.out.println(accountKeyStatus);
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
StringBuilder sb = new StringBuilder();
@ -536,9 +524,7 @@ public class delegationServices {
delegationTimer.DeleteTargetRequest(ClientID);
}
}
else
{
} else {
System.out.println("RSC");
if (Password.equals(password)) {
System.out.println("R3c");
@ -650,10 +636,8 @@ public class delegationServices {
try {
accountServer = accountS.find(eq("tempKey", userKey)).first();
serverUserName = (String) accountServer.get("User");
if (accountServer.get("Status").equals(true))
{
if (userName.equalsIgnoreCase(serverUserName))
{
if (accountServer.get("Status").equals(true)) {
if (userName.equalsIgnoreCase(serverUserName)) {
System.out.println("This key is correct.");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -661,7 +645,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",55));
new BasicDBObject().append("type", 55));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -669,9 +653,7 @@ public class delegationServices {
//delegationTimer.trigger();
delegationTimer.DeleteTargetRequest(ClientID);
}
else
{
} else {
System.out.println("This key is incorrect");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -679,7 +661,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",56));
new BasicDBObject().append("type", 56));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -696,7 +678,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",56));
new BasicDBObject().append("type", 56));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -705,8 +687,7 @@ public class delegationServices {
}
}
if (requesttype == 57)
{
if (requesttype == 57) {
System.out.println("Verifying email with account tied to OTK");
try {
String userKey = (String) Lrequest.get("otk");
@ -737,13 +718,13 @@ public class delegationServices {
BasicDBObject updateQuery3 = new BasicDBObject();
System.out.println("Objects are ready.");
updateQuery.append("$set",
new BasicDBObject().append("Password",requestedPassword));
new BasicDBObject().append("Password", requestedPassword));
updateQuery1.append("$unset",
new BasicDBObject().append("tempKey", ""));
updateQuery2.append("$set",
new BasicDBObject().append("Version","2"));
new BasicDBObject().append("Version", "2"));
updateQuery3.append("$set",
new BasicDBObject().append("keyStatus",false));
new BasicDBObject().append("keyStatus", false));
System.out.println("Objects set");
accountS.updateOne(searchQuery, updateQuery);
accountS.updateOne(searchQuery, updateQuery1);
@ -754,7 +735,7 @@ public class delegationServices {
BasicDBObject finalizeRequest = new BasicDBObject();
System.out.println("Objects close init");
closeRequestType.append("$set",
new BasicDBObject().append("type",58));
new BasicDBObject().append("type", 58));
finalizeRequest.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery1, closeRequestType);
@ -763,9 +744,7 @@ public class delegationServices {
delegationTimer.DeleteTargetRequest(ClientID);
System.out.println("request finished correctly");
accountMigrationComplete(serverEmail, userName);
}
else
{
} else {
System.out.println("request denied");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -773,7 +752,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",59));
new BasicDBObject().append("type", 59));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -788,7 +767,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",59));
new BasicDBObject().append("type", 59));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -917,8 +896,7 @@ public class delegationServices {
}
}
if (requesttype == 18) {
if ((Boolean)Filter.get("gameActive") == true)
{
if ((Boolean) Filter.get("gameActive") == true) {
//Deprecated, a killswitch has been added under rgcon in the field "gameActive"
//TOKEN LOGIN FOR GAME, DOES NOT SEND EMAIL, LAUNCHER WILL NOT USE THIS.
System.out.println("Game Login");
@ -1050,9 +1028,7 @@ public class delegationServices {
delegationTimer.DeleteTargetRequest(ClientID);
//delegationTimer.trigger();
}
}
else
{
} else {
System.out.println("Login rejected, game client EOS has been reached.");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -1185,14 +1161,14 @@ public class delegationServices {
createForm.append("UUID", UUID);
createForm.append("Control", 1);
createForm.append("Upgrade", 0);
createForm.append("Version","2");
createForm.append("Version", "2");
createForm.append("keyStatus", false);
//createForm.append("Uid",uid);
createForm.append("lastNet", Macid);
accountS.insertOne(createForm);
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
electronicMailHandler.Onboarding(Email, User,UUID);
electronicMailHandler.Onboarding(Email, User, UUID);
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
@ -1382,25 +1358,20 @@ public class delegationServices {
//delegationTimer.trigger();
}
}
if (requesttype == 14)
{
if (requesttype == 14) {
//TODO Finish making a secure deletion process.
String requestClientUUID = (String) Lrequest.get("UUID");
String requestClientToken = (String) Lrequest.get("token");
String requestClientMAC = (String) Lrequest.get("mac");
}
if (requesttype == 61)
{
if (requesttype == 61) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
System.out.println("Init ClientTraceback");
String policyDocument;
try
{
try {
policyDocument = Files.readString(Path.of(System.getProperty("user.home") + "/ocs/policy/launcher/legal/eula.txt"));
}
catch (Exception EXR)
{
} catch (Exception EXR) {
System.out.println("Unable to pull file, fallback.");
policyDocument = "Policy file does not exist on server. This is an issue on our end. Error ID: " + EXR;
}
@ -1419,19 +1390,15 @@ public class delegationServices {
dCollection.updateOne(searchQuery, updateQuery3);
delegationTimer.DeleteTargetRequest(ClientID);
}
if (requesttype == 63)
{
if (requesttype == 63) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
System.out.println("Init ClientTraceback");
String policyDocument;
try
{
try {
// File homedir = new File(System.getProperty("user.home"));
policyDocument = Files.readString(Path.of(System.getProperty("user.home") + "/ocs/policy/launcher/legal/eula.txt"));
}
catch (Exception EXR)
{
} catch (Exception EXR) {
System.out.println("Unable to pull file, fallback.");
policyDocument = "Policy file does not exist on server. This is an issue on our end. Error ID: " + EXR;
}
@ -1450,8 +1417,7 @@ public class delegationServices {
dCollection.updateOne(searchQuery, updateQuery3);
delegationTimer.DeleteTargetRequest(ClientID);
}
if (requesttype == 65)
{
if (requesttype == 65) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
System.out.println("Collecting Error Data");
@ -1462,10 +1428,10 @@ public class delegationServices {
String bugSeverity = Lrequest.get("bugSeverity").toString();
String timeCurrent = LocalDateTime.now().toString(); //ISO-8601: yyyy-MM-ddTHH:mm:ss.S
try {
File myObj = new File(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt");
File myObj = new File(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent + ".txt");
if (myObj.createNewFile()) {
System.out.println("Log File created: " + myObj.getName());
FileWriter writer = new FileWriter(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt", true);
FileWriter writer = new FileWriter(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent + ".txt", true);
writer.write("This bug report is for: " + applicationName);
writer.write("\r\n");
writer.write("The bug severity is level: " + bugSeverity);
@ -1491,8 +1457,7 @@ public class delegationServices {
dCollection.updateOne(searchQuery, updateQuery);
delegationServices.TargetDelete(ClientID);
}
if (requesttype == 66)
{
if (requesttype == 66) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
System.out.println("Collecting Error Data");
@ -1504,10 +1469,10 @@ public class delegationServices {
String bugLog = Lrequest.get("bugLog").toString();
String timeCurrent = LocalDateTime.now().toString(); //ISO-8601: yyyy-MM-ddTHH:mm:ss.S
try {
File myObj = new File(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt");
File myObj = new File(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent + ".txt");
if (myObj.createNewFile()) {
System.out.println("Log File created: " + myObj.getName());
FileWriter writer = new FileWriter(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt", true);
FileWriter writer = new FileWriter(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent + ".txt", true);
writer.write("This bug report is for: " + applicationName);
writer.write("\r\n");
writer.write("The bug severity is level: " + bugSeverity);
@ -1546,10 +1511,8 @@ public class delegationServices {
try {
accountServer = accountS.find(eq("delOTK", userKey)).first();
serverUUID = (String) accountServer.get("UUID");
if (accountServer.get("Status").equals(true))
{
if (clientUUID.equalsIgnoreCase(serverUUID))
{
if (accountServer.get("Status").equals(true)) {
if (clientUUID.equalsIgnoreCase(serverUUID)) {
System.out.println("This key is correct.");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -1557,18 +1520,16 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",69));
new BasicDBObject().append("type", 69));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
dCollection.updateOne(searchQuery, updateQuery1);
//delegationTimer.trigger();
offBoarding((String)accountServer.get("Email"), (String)accountServer.get("User"), (String)accountServer.get("FName"));
offBoarding((String) accountServer.get("Email"), (String) accountServer.get("User"), (String) accountServer.get("FName"));
delegationTimer.DeleteTargetRequest(ClientID);
accountS.deleteOne(accountServer);
}
else
{
} else {
System.out.println("This key is incorrect");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -1576,7 +1537,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",70));
new BasicDBObject().append("type", 70));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -1593,7 +1554,7 @@ public class delegationServices {
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type",56));
new BasicDBObject().append("type", 56));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
dCollection.updateOne(searchQuery, updateQuery);
@ -1602,21 +1563,18 @@ public class delegationServices {
}
}
if (requesttype == 67)
{
if (requesttype == 67) {
String OTK = "keyNotSetDueToError(ERR24)";
Boolean keyStatus = false;
//default false, since will be set to true if the mesurement exists on linked account
String accountUUID = (String) Lrequest.get("uuid");
Document linkedAccount = accountS.find(eq("UUID", accountUUID)).first();
try {
keyStatus = (boolean)linkedAccount.get("delStatus");
} catch (Exception NPE)
{
keyStatus = (boolean) linkedAccount.get("delStatus");
} catch (Exception NPE) {
keyStatus = false;
}
if (keyStatus == false)
{
if (keyStatus == false) {
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
StringBuilder sb = new StringBuilder();
Random random = new Random();
@ -1632,16 +1590,14 @@ public class delegationServices {
BasicDBObject deleteTie = new BasicDBObject();
deleteTie.append("UUID", accountUUID);
deleteKey.append("$set",
new BasicDBObject().append("delOTK",OTK));
new BasicDBObject().append("delOTK", OTK));
deleteKeyStatus.append("$set",
new BasicDBObject().append("delStatus",true));
new BasicDBObject().append("delStatus", true));
accountS.updateOne(deleteTie, deleteKey);
accountS.updateOne(deleteTie, deleteKeyStatus);
otkDeletionEmail((String)linkedAccount.get("Email"),OTK,(String)linkedAccount.get("User"));
}
else
{
otkDeletionEmailResend((String)linkedAccount.get("Email"),(String)linkedAccount.get("delOTK"),(String)linkedAccount.get("User"));
otkDeletionEmail((String) linkedAccount.get("Email"), OTK, (String) linkedAccount.get("User"));
} else {
otkDeletionEmailResend((String) linkedAccount.get("Email"), (String) linkedAccount.get("delOTK"), (String) linkedAccount.get("User"));
}
BasicDBObject clearCL = new BasicDBObject();
clearCL.append("clientid", ClientID);
@ -1677,7 +1633,7 @@ public class delegationServices {
}
}
} catch (Exception Erp) {
System.out.println("Malformed Request, Non Recoverable ErrorInfo: " +Erp);
System.out.println("Malformed Request, Non Recoverable ErrorInfo: " + Erp);
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid", ClientID);
@ -1689,21 +1645,21 @@ public class delegationServices {
new BasicDBObject().append("status", true));
updateQuery1.append("$set",
new BasicDBObject().append("pos", "934"));
Lrequest.append("status",true);
Lrequest.append("status", true);
dCollection.updateOne(searchQuery, updateQuery1);
dCollection.updateOne(searchQuery, updateQuery);
dCollection.updateOne(searchQuery,updateQuery);
dCollection.updateOne(searchQuery, updateQuery);
delegationTimer.DeleteTargetRequest(ClientID);
}
}
//above is finding one request and starting wheels
//delegationTimer.trigger();
delegate();
}
public static void Purge () {
public static void Purge() {
BasicDBObject searchQueryT = new BasicDBObject();
BasicDBObject searchQueryF = new BasicDBObject();
searchQueryT.append("status", true);
@ -1713,31 +1669,34 @@ public class delegationServices {
System.out.println("Flushed Server");
}
public static void TargetDelete (int CID) {
public static void TargetDelete(int CID) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("clientid",CID);
searchQuery.append("clientid", CID);
dCollection.deleteMany(searchQuery);
System.out.println("Flushed a targeted request (CID) from the server");
}
public static void TargetDeleteRID (int CID) {
public static void TargetDeleteRID(int CID) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("rid",CID);
searchQuery.append("rid", CID);
dCollection.deleteMany(searchQuery);
System.out.println("Flushed a targeted request (RID) from the server");
} public static void delegate ()
{
}
public static void delegate() {
userAuthetication();
}
public static void userAuthetication (){
public static void userAuthetication() {
try {
delegationProcesser();
} catch (Exception exr) {
delegationTimer.trigger();
//Shit is so janky, I tell it not to crash when it wants to crash
}
}
}
}

View File

@ -6,7 +6,7 @@ import com.jamesquinley.DelegationServices.status;
Hey there! This is the source code for AOTSK-Delegation Server, self explanitory.
Also this is multi line so I can justify using this type of comment.
*/
public class init
public class Main
{
public static void main( String[] args )
{

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.jamesquinley.init
Main-Class: com.jamesquinley.Main