Working Build

This commit is contained in:
James 2022-02-05 08:31:24 -08:00
parent 0006a0e887
commit 5a612c9e5a
4 changed files with 384 additions and 334 deletions

21
.idea/artifacts/LoginServer.xml generated Normal file
View File

@ -0,0 +1,21 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="LoginServer">
<output-path>$PROJECT_DIR$/out/artifacts/LoginServer</output-path>
<root id="archive" name="AOTSK-Login-Delegation-Server.jar">
<element id="module-output" name="AOTSK-Login-Delegation-Server" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/mongodb/bson/4.3.2/bson-4.3.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/mongodb/mongodb-driver-core/4.3.2/mongodb-driver-core-4.3.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/jfoenix/jfoenix/8.0.10/jfoenix-8.0.10.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jsoup/jsoup/1.14.2/jsoup-1.14.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-core/2.17.0/log4j-core-2.17.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/mongodb/mongodb-driver-sync/4.3.2/mongodb-driver-sync-4.3.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/controlsfx/controlsfx/11.1.1/controlsfx-11.1.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/lingala/zip4j/zip4j/2.6.1/zip4j-2.6.1.jar" path-in-jar="/" />
</root>
</artifact>
</component>

View File

@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Server" type="Application" factoryName="Application"> <configuration default="false" name="Server Client " type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.jamesquinley.startup" /> <option name="MAIN_CLASS_NAME" value="com.jamesquinley.startup" />
<module name="AOTSK-Login-Delegation-Server" /> <module name="AOTSK-Login-Delegation-Server" />
<method v="2"> <method v="2">

View File

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

View File

@ -40,19 +40,29 @@ public class delegationServices {
public static void delegationProcesser() { public static void delegationProcesser() {
Document Lrequest = dCollection.find(eq("status", false)).first(); Document Lrequest = dCollection.find(eq("status", false)).first();
int ClientID = 0; int ClientID = 0;
int requesttype = (int) Lrequest.get("type");
System.out.println("Got Type, Getting Doc ID");
//TODO Get this working, it broke and it wont get OBJ id
System.out.println("Delegation Has Started");
if(requesttype == 0 || requesttype == 1 || requesttype == 2 || requesttype == 3 || requesttype == 4 || requesttype == 5 || requesttype == 6 || requesttype ==7 || requesttype == 8 || requesttype ==9 || requesttype ==10 || requesttype ==11 || requesttype ==12) {
if (requesttype == 7) {
System.out.println("An Excluded Request (7MAL) Has Been Detected, Ignoring");
}
String username = (String) Lrequest.get("User");
String password = (String) Lrequest.get("Password");
try { try {
ClientID = (int) Lrequest.get("clientid"); ClientID = (int) Lrequest.get("clientid");
} catch (Exception exrp) { } catch (Exception exrp) {
System.out.println("Failed To Get Client ID");
} }
//TODO ADD BAN CHECK TO PREVENT BAN CIRCUMNAVIGATION, THIS WILL BE ADDED LATER (This is being tested, already implemented)
String username = (String) Lrequest.get("User");
String password = (String) Lrequest.get("Password");
int CTOKEN = (int) Lrequest.get("Token"); int CTOKEN = (int) Lrequest.get("Token");
int requesttype = (int) Lrequest.get("type");
if (requesttype == 0) { if (requesttype == 0) {
System.out.println("Sync Request (Read" + System.out.println("Sync Request (Read)");
")");
Document accountServer; Document accountServer;
String Password; String Password;
int Token; int Token;
@ -63,7 +73,7 @@ public class delegationServices {
try { try {
accountServer = accountS.find(eq("Token", CTOKEN)).first(); accountServer = accountS.find(eq("Token", CTOKEN)).first();
Token = (int) accountServer.get("Token"); Token = (int) accountServer.get("Token");
if (accountServer.get("Status").equals("Active")) { if (accountServer.get("Status").equals(true)) {
if (Token == CTOKEN) { if (Token == CTOKEN) {
Token = (int) accountServer.get("Token"); Token = (int) accountServer.get("Token");
Password = (String) accountServer.get("Password"); Password = (String) accountServer.get("Password");
@ -165,7 +175,7 @@ public class delegationServices {
try { try {
accountServer = accountS.find(eq("Token", CTOKEN)).first(); accountServer = accountS.find(eq("Token", CTOKEN)).first();
Token = (int) accountServer.get("Token"); Token = (int) accountServer.get("Token");
if (accountServer.get("Status").equals("Active")) { if (accountServer.get("Status").equals(true)) {
System.out.println("Account is OK"); System.out.println("Account is OK");
if (Token == CTOKEN) { if (Token == CTOKEN) {
System.out.println("Logged In"); System.out.println("Logged In");
@ -271,7 +281,7 @@ public class delegationServices {
try { try {
accountServer = accountS.find(eq("User", username)).first(); accountServer = accountS.find(eq("User", username)).first();
Password = (String) accountServer.get("Password"); Password = (String) accountServer.get("Password");
if (accountServer.get("Status").equals("Active")) { if (accountServer.get("Status").equals(true)) {
if (Password.equals(password)) { if (Password.equals(password)) {
Token = (int) accountServer.get("Token"); Token = (int) accountServer.get("Token");
Fname = (String) accountServer.get("FName"); Fname = (String) accountServer.get("FName");
@ -373,7 +383,7 @@ public class delegationServices {
try { try {
accountServer = accountS.find(eq("Token", CTOKEN)).first(); accountServer = accountS.find(eq("Token", CTOKEN)).first();
TKN = (int) accountServer.get("Token"); TKN = (int) accountServer.get("Token");
if (accountServer.get("Status").equals("Active")) { if (accountServer.get("Status").equals(true)) {
if (TKN == CTOKEN) { if (TKN == CTOKEN) {
TKN = (int) accountServer.get("Token"); TKN = (int) accountServer.get("Token");
Password = (String) accountServer.get("Password"); Password = (String) accountServer.get("Password");
@ -464,6 +474,27 @@ public class delegationServices {
//delegationTimer.trigger(); //delegationTimer.trigger();
} }
} }
} else {
System.out.println("Malformed Request, Non Recoverable");
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("type", requesttype);
BasicDBObject updateQuery = new BasicDBObject();
BasicDBObject updateQuery1 = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("type", 7));
updateQuery1.append("$set",
new BasicDBObject().append("status", true));
Lrequest.append("status",true);
dCollection.updateOne(searchQuery, updateQuery1);
dCollection.updateOne(searchQuery, updateQuery);
}
//above is finding one request and starting wheels //above is finding one request and starting wheels
//delegationTimer.trigger(); //delegationTimer.trigger();
delegate(); delegate();
@ -473,26 +504,21 @@ public class delegationServices {
searchQuery.append("status", true); searchQuery.append("status", true);
BasicDBObject searchQuery1 = new BasicDBObject(); BasicDBObject searchQuery1 = new BasicDBObject();
searchQuery1.append("status", false); searchQuery1.append("status", false);
// dCollection.deleteMany(searchQuery); dCollection.deleteMany(searchQuery);
// dCollection.deleteMany(searchQuery1); dCollection.deleteMany(searchQuery1);
System.out.println("Flushed Server");
} }
public static void delegate () public static void delegate ()
{ {
Document userLookMutedLookUp = dCollection.find(eq("status", false)).first(); userAuthetication();
try {
userAuthetication(userLookMutedLookUp);
} catch (NullPointerException NPE) {
System.out.println("No Pending Authentication Requests");
delegationTimer.trigger();
} }
} public static void userAuthetication (){
public static void userAuthetication (Document doc){
try { try {
delegationProcesser(); delegationProcesser();
} catch (Exception exr) { } catch (Exception exr) {
System.out.println("No Pending Authentication"); System.out.println("No Pending Authentication: ");
delegationTimer.trigger(); delegationTimer.trigger();
} }
} }