This version has a semi working account deletion with emails that are sent along the way, not quite ready for live as key state is not stored and multiple keys can be made, although the latest revision is the one that will work.
This commit is contained in:
@ -57,6 +57,51 @@ public class electronicMailHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void offBoarding(String receiverEmail, String User, String Name) {
|
||||||
|
//get date for email
|
||||||
|
Date date = new Date();
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
|
||||||
|
String Date = formatter.format(date);
|
||||||
|
//get time for sign in time
|
||||||
|
Date dt = new Date();
|
||||||
|
SimpleDateFormat dateFormat;
|
||||||
|
dateFormat = new SimpleDateFormat("kk:mm:ss");
|
||||||
|
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.put("mail.smtp.host", emailSMTPserver);
|
||||||
|
props.put("mail.smtp.socketFactory.port", emailSMTPPort);
|
||||||
|
props.put("mail.smtp.socketFactory.class",
|
||||||
|
"javax.net.ssl.SSLSocketFactory");
|
||||||
|
props.put("mail.smtp.auth", "true");
|
||||||
|
props.put("mail.smtp.port", emailSMTPPort);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Authenticator auth = new SMTPAuthenticator();
|
||||||
|
Session session = Session.getInstance(props, auth);
|
||||||
|
Message message = new MimeMessage(session);
|
||||||
|
message.setFrom(new InternetAddress(senderEmailId));
|
||||||
|
message.setRecipients(Message.RecipientType.TO,
|
||||||
|
InternetAddress.parse(receiverEmail));
|
||||||
|
message.setSubject("Sorry to see you go");
|
||||||
|
message.setText("Hey " + Name + "," +
|
||||||
|
"\n" +
|
||||||
|
"We're sorry to see you go, you probably have a pretty valid reason to do so." +
|
||||||
|
"\n" +
|
||||||
|
"As such any data we have that you submitted is being deleted, this will take around a minute." +
|
||||||
|
"\n" +
|
||||||
|
"Thank you again for using our services, have a great day." +
|
||||||
|
"\n" +
|
||||||
|
"-Obsidian Core Services Team" +
|
||||||
|
"\n" +
|
||||||
|
"This email is for, " + User + ". If this is not your account, ignore this and check who has your email.");
|
||||||
|
|
||||||
|
Transport.send(message);
|
||||||
|
System.out.println("Sent Onboarding Email");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void newLocation (String receiverEmail, String User, String Adr, String OldAdr) {
|
public static void newLocation (String receiverEmail, String User, String Adr, String OldAdr) {
|
||||||
//get date for email
|
//get date for email
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
@ -134,6 +179,47 @@ public class electronicMailHandler {
|
|||||||
System.err.println("Was Not Sent Because Of An Error.");
|
System.err.println("Was Not Sent Because Of An Error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void otkDeletionEmail (String receiverEmail, String Key, String User) {
|
||||||
|
//get date for email
|
||||||
|
Date date = new Date();
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
|
||||||
|
String Date = formatter.format(date);
|
||||||
|
//get time for sign in time
|
||||||
|
Date dt = new Date();
|
||||||
|
SimpleDateFormat dateFormat;
|
||||||
|
dateFormat = new SimpleDateFormat("kk:mm:ss");
|
||||||
|
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.put("mail.smtp.host", emailSMTPserver);
|
||||||
|
props.put("mail.smtp.socketFactory.port", emailSMTPPort);
|
||||||
|
props.put("mail.smtp.socketFactory.class",
|
||||||
|
"javax.net.ssl.SSLSocketFactory");
|
||||||
|
props.put("mail.smtp.auth", "true");
|
||||||
|
props.put("mail.smtp.port", emailSMTPPort);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Authenticator auth = new SMTPAuthenticator();
|
||||||
|
Session session = Session.getInstance(props, auth);
|
||||||
|
Message message = new MimeMessage(session);
|
||||||
|
message.setFrom(new InternetAddress(senderEmailId));
|
||||||
|
message.setRecipients(Message.RecipientType.TO,
|
||||||
|
InternetAddress.parse(receiverEmail));
|
||||||
|
message.setSubject("Obsidian Core Account Notice");
|
||||||
|
message.setText("Hey there, as you may have seen in the launcher, you need a one time key to delete your account, this email can help! " +
|
||||||
|
"\nBefore we give you the required key to continue, a gentle reminder to NEVER SHARE YOUR PASSWORD OR ONE TIME KEY! " +
|
||||||
|
"\nWell, good luck! Your one time key is: " + Key +
|
||||||
|
"\nThis key will remain active until used, it was generated at your login attempt, and won't be regenerated after the initial creation of said key." +
|
||||||
|
"\nThis key will only work with the account tied to the username: " + User + ", and will only work one time, its in the name." +
|
||||||
|
"\nWe're sorry to see you go.");
|
||||||
|
|
||||||
|
Transport.send(message);
|
||||||
|
System.out.println("Alert Sent");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("Was Not Sent Because Of An Error.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void otkMigrate (String receiverEmail, String User) {
|
public static void otkMigrate (String receiverEmail, String User) {
|
||||||
//get date for email
|
//get date for email
|
||||||
|
@ -25,6 +25,8 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static com.jamesquinley.Asecure.electronicMailHandler.offBoarding;
|
||||||
|
import static com.jamesquinley.Asecure.electronicMailHandler.otkDeletionEmail;
|
||||||
import static com.jamesquinley.Asecure.secureCalls.accountMigrationComplete;
|
import static com.jamesquinley.Asecure.secureCalls.accountMigrationComplete;
|
||||||
import static com.mongodb.client.model.Filters.eq;
|
import static com.mongodb.client.model.Filters.eq;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
@ -1556,17 +1558,17 @@ public class delegationServices {
|
|||||||
if (requesttype == 68) {
|
if (requesttype == 68) {
|
||||||
System.out.println("Verifying OTK");
|
System.out.println("Verifying OTK");
|
||||||
String userKey = (String) Lrequest.get("otk");
|
String userKey = (String) Lrequest.get("otk");
|
||||||
String userName = (String) Lrequest.get("recoverUser");
|
String clientUUID = (String) Lrequest.get("uuid");
|
||||||
String serverUserName;
|
String serverUUID;
|
||||||
userKey = userKey.toUpperCase();
|
userKey = userKey.toUpperCase();
|
||||||
System.out.println(userKey);
|
System.out.println(userKey);
|
||||||
Document accountServer;
|
Document accountServer;
|
||||||
try {
|
try {
|
||||||
accountServer = accountS.find(eq("tempKey", userKey)).first();
|
accountServer = accountS.find(eq("delOTK", userKey)).first();
|
||||||
serverUserName = (String) accountServer.get("User");
|
serverUUID = (String) accountServer.get("UUID");
|
||||||
if (accountServer.get("Status").equals(true))
|
if (accountServer.get("Status").equals(true))
|
||||||
{
|
{
|
||||||
if (userName.equalsIgnoreCase(serverUserName))
|
if (clientUUID.equalsIgnoreCase(serverUUID))
|
||||||
{
|
{
|
||||||
System.out.println("This key is correct.");
|
System.out.println("This key is correct.");
|
||||||
BasicDBObject searchQuery = new BasicDBObject();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
@ -1575,14 +1577,15 @@ public class delegationServices {
|
|||||||
BasicDBObject updateQuery = new BasicDBObject();
|
BasicDBObject updateQuery = new BasicDBObject();
|
||||||
BasicDBObject updateQuery1 = new BasicDBObject();
|
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||||
updateQuery.append("$set",
|
updateQuery.append("$set",
|
||||||
new BasicDBObject().append("type",55));
|
new BasicDBObject().append("type",69));
|
||||||
updateQuery1.append("$set",
|
updateQuery1.append("$set",
|
||||||
new BasicDBObject().append("status", true));
|
new BasicDBObject().append("status", true));
|
||||||
dCollection.updateOne(searchQuery, updateQuery);
|
dCollection.updateOne(searchQuery, updateQuery);
|
||||||
dCollection.updateOne(searchQuery, updateQuery1);
|
dCollection.updateOne(searchQuery, updateQuery1);
|
||||||
//delegationTimer.trigger();
|
//delegationTimer.trigger();
|
||||||
|
offBoarding((String)accountServer.get("Email"), (String)accountServer.get("User"), (String)accountServer.get("FName"));
|
||||||
delegationTimer.DeleteTargetRequest(ClientID);
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
|
accountS.deleteOne(accountServer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1593,7 +1596,7 @@ public class delegationServices {
|
|||||||
BasicDBObject updateQuery = new BasicDBObject();
|
BasicDBObject updateQuery = new BasicDBObject();
|
||||||
BasicDBObject updateQuery1 = new BasicDBObject();
|
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||||
updateQuery.append("$set",
|
updateQuery.append("$set",
|
||||||
new BasicDBObject().append("type",56));
|
new BasicDBObject().append("type",70));
|
||||||
updateQuery1.append("$set",
|
updateQuery1.append("$set",
|
||||||
new BasicDBObject().append("status", true));
|
new BasicDBObject().append("status", true));
|
||||||
dCollection.updateOne(searchQuery, updateQuery);
|
dCollection.updateOne(searchQuery, updateQuery);
|
||||||
@ -1630,9 +1633,24 @@ public class delegationServices {
|
|||||||
char randomChar = alphabet.charAt(index);
|
char randomChar = alphabet.charAt(index);
|
||||||
sb.append(randomChar);
|
sb.append(randomChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
String OTK = sb.toString();
|
String OTK = sb.toString();
|
||||||
|
String accountUUID = (String) Lrequest.get("uuid");
|
||||||
|
BasicDBObject deleteKey = new BasicDBObject();
|
||||||
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
|
searchQuery.append("UUID", accountUUID);
|
||||||
|
deleteKey.append("$set",
|
||||||
|
new BasicDBObject().append("delOTK",OTK));
|
||||||
|
accountS.updateOne(searchQuery, deleteKey);
|
||||||
|
BasicDBObject clearCL = new BasicDBObject();
|
||||||
|
clearCL.append("clientid", ClientID);
|
||||||
|
BasicDBObject clearUO = new BasicDBObject();
|
||||||
|
clearUO.append("$set",
|
||||||
|
new BasicDBObject().append("status", true));
|
||||||
|
dCollection.updateOne(clearCL, clearUO);
|
||||||
|
System.out.println("Finished Del Generation");
|
||||||
|
Document linkedAccount = accountS.find(eq("UUID", accountUUID)).first();
|
||||||
|
otkDeletionEmail((String)linkedAccount.get("Email"),OTK,(String)linkedAccount.get("User"));
|
||||||
com.jamesquinley.DelegationServices.delegationTimer.DeleteTargetRequestQuick(ClientID);
|
com.jamesquinley.DelegationServices.delegationTimer.DeleteTargetRequestQuick(ClientID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1649,6 +1667,12 @@ public class delegationServices {
|
|||||||
Lrequest.append("status", true);
|
Lrequest.append("status", true);
|
||||||
dCollection.updateOne(searchQuery, updateQuery1);
|
dCollection.updateOne(searchQuery, updateQuery1);
|
||||||
dCollection.updateOne(searchQuery, updateQuery);
|
dCollection.updateOne(searchQuery, updateQuery);
|
||||||
|
BasicDBObject clearCL = new BasicDBObject();
|
||||||
|
clearCL.append("clientid", ClientID);
|
||||||
|
BasicDBObject clearUO = new BasicDBObject();
|
||||||
|
clearUO.append("$set",
|
||||||
|
new BasicDBObject().append("status", true));
|
||||||
|
dCollection.updateOne(clearUO, clearUO);
|
||||||
delegationTimer.DeleteTargetRequest(ClientID);
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user