diff --git a/src/main/java/com/jamesquinley/Asecure/emailVerify.java b/src/main/java/com/jamesquinley/Asecure/emailVerify.java index 304bed1..c667462 100644 --- a/src/main/java/com/jamesquinley/Asecure/emailVerify.java +++ b/src/main/java/com/jamesquinley/Asecure/emailVerify.java @@ -43,9 +43,9 @@ public class emailVerify { message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiverEmail)); message.setSubject("Welcome To Obsidian Core Studios!"); - message.setText("Seems you've signed up for an account we're happy you're here, and welcome to the Obsidian Core Studios Family! \n \n \n \n \n " + + message.setText("Seems you've signed up for an account we're happy you're here, and welcome to the Obsidian Core Studios Family! \n\n\n\n\n" + "This Was Sent On Behalf Of Obsidian Core Studios By Our Super Cool Login Robots." + - "\n You'll Only Get This Type Email Once."); + "\n You'll Only Get This Email Once."); Transport.send(message); System.out.println("Sent Onboarding Email"); @@ -54,7 +54,7 @@ public class emailVerify { System.err.println("Email ONBOARD Not sent due to an error"); } } - public static void SendEmailThroughGmail(String receiverEmail, String User) { + public static void newLocation (String receiverEmail, String User, String Adr, String OldAdr) { //get date for email Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy"); @@ -80,8 +80,9 @@ public class emailVerify { message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiverEmail)); message.setSubject("Obsidian Core Account Login Notice | " + Date); - message.setText("We detected a new login on your account " +"(at " + dateFormat.format(dt) + " PDT)" + ". If this was you ignore this email, if it wasn't you, please change your password. \n \n \n \n" + - " \n This email (" + receiverEmail + ") is linked to the Obsidian Core Account "+ User + " \n These security emails can't be opted out of. \n \n This was sent on behalf of Obsidian Core Studios by our super cool login robots."); + message.setText("Something Seems Fishy, A Login Was Detected At A New Location (" + Adr + " Compared To Your Last Logon " + OldAdr +") "+"(at " + dateFormat.format(dt) + " PST)" + ". If this was you ignore this email, if it wasn't you, please contact us (Respond To This Email).\n\n\n\n" + + " \nThis email (" + receiverEmail + ") is linked to the Obsidian Core Account "+ User + " \nThese security emails can't be opted out of. \n\nThis was sent on behalf of Obsidian Core Studios by our super cool login robots.\n\n\n\n" + + "The MAC address used has been set as your account's default ("+Adr + ")"); Transport.send(message); System.out.println("Alert Sent"); diff --git a/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java b/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java index 3641518..d39fd88 100644 --- a/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java +++ b/src/main/java/com/jamesquinley/DelegationServices/delegationServices.java @@ -71,6 +71,8 @@ public class delegationServices { static MongoCollection FNETDOC = accountDatabase.getCollection("FNet"); static int RequestR; //still need to config + public static String lastNet = null; + public static String Macid = null; public static void delegationProcesser() { int ClientID = 0; Document Lrequest = dCollection.find(eq("status", false)).first(); @@ -84,8 +86,11 @@ public class delegationServices { try { try { ClientID = (int) Lrequest.get("clientid"); + Macid = (String) Lrequest.get("net"); + System.out.println(Macid); + } catch (Exception exrp) { - System.out.println("Failed To Get Client ID"); + System.out.println("Failed To Get Client ID & MacAdr"); delegationTimer.DeleteTargetRequest(ClientID); } @@ -348,7 +353,9 @@ public class delegationServices { Path = (String) accountServer.get("Path"); Email = (String) accountServer.get("Email"); UserName = (String) accountServer.get("User"); - com.jamesquinley.Asecure.emailVerify.SendEmailThroughGmail(Email, UserName); + lastNet = (String) accountServer.get("lastNet"); + localNet.macRead(Macid,lastNet,Email,UserName,Token); + // com.jamesquinley.Asecure.emailVerify.SendEmailThroughGmail(Email, UserName); BasicDBObject searchQuery = new BasicDBObject(); searchQuery.append("clientid", ClientID); @@ -456,9 +463,10 @@ public class delegationServices { Fname = (String) accountServer.get("FName"); Path = (String) accountServer.get("Path"); Email = (String) accountServer.get("Email"); - UserName = (String) accountServer.get("User"); - com.jamesquinley.Asecure.emailVerify.SendEmailThroughGmail(Email, UserName); + lastNet = (String) accountServer.get("lastNet"); + localNet.macRead(Macid,lastNet,Email,UserName,TKN); + // com.jamesquinley.Asecure.emailVerify.SendEmailThroughGmail(Email, UserName); BasicDBObject searchQuery = new BasicDBObject(); searchQuery.append("clientid", ClientID); @@ -727,6 +735,7 @@ public class delegationServices { createForm.append("Token", tokenSTGEN); createForm.append("Control", 1); createForm.append("Upgrade", 0); + createForm.append("lastNet", Macid); accountS.insertOne(createForm); FnetInit.append("User", User); FnetInit.append("Status", true); diff --git a/src/main/java/com/jamesquinley/DelegationServices/localNet.java b/src/main/java/com/jamesquinley/DelegationServices/localNet.java new file mode 100644 index 0000000..a05e496 --- /dev/null +++ b/src/main/java/com/jamesquinley/DelegationServices/localNet.java @@ -0,0 +1,25 @@ +package com.jamesquinley.DelegationServices; + +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) + { + if (NewMac.equals(OldMac)) + { + System.out.println("User Logged In From A Known Computer, not sending email"); + } else + { + System.out.println("Hey this user Logged In From A new Location, dispatching email!"); + com.jamesquinley.Asecure.emailVerify.newLocation(email,UName,NewMac, OldMac); + System.out.println("Switching Trusted Net To New Local"); + BasicDBObject searchQuery = new BasicDBObject(); + searchQuery.append("Token", Token); + BasicDBObject updateQuery = new BasicDBObject(); + updateQuery.append("$set", new BasicDBObject().append("lastNet", NewMac)); + accountS.updateOne(searchQuery, updateQuery); + } + } +}