Account deletion is now stable and safe to launch, other features will be getting bugfixes to make the server software more stable.

This commit is contained in:
JSQui 2022-10-15 22:31:36 -07:00
parent 1c25899408
commit 31603e5ccc
3 changed files with 115 additions and 58 deletions

View File

@ -96,7 +96,7 @@ public class electronicMailHandler {
"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");
System.out.println("Sent goodbye Email");
} catch (Exception e) {
e.printStackTrace();
@ -220,6 +220,48 @@ public class electronicMailHandler {
System.err.println("Was Not Sent Because Of An Error.");
}
}
public static void otkDeletionEmailResend (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("It seems you've tried to delete your account in the past, and clicked the button again so here's the same info." +
"\nHey 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 RESent");
} catch (Exception e) {
e.printStackTrace();
System.err.println("Was Not Sent Because Of An Error.");
}
}
public static void otkMigrate (String receiverEmail, String User) {
//get date for email

View File

@ -25,8 +25,7 @@ import java.util.List;
import java.util.Random;
import java.util.UUID;
import static com.jamesquinley.Asecure.electronicMailHandler.offBoarding;
import static com.jamesquinley.Asecure.electronicMailHandler.otkDeletionEmail;
import static com.jamesquinley.Asecure.electronicMailHandler.*;
import static com.jamesquinley.Asecure.secureCalls.accountMigrationComplete;
import static com.mongodb.client.model.Filters.eq;
import static java.util.concurrent.TimeUnit.SECONDS;
@ -1466,13 +1465,6 @@ public class delegationServices {
File myObj = new File(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt");
if (myObj.createNewFile()) {
System.out.println("Log File created: " + myObj.getName());
} else {
System.out.println("Log already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
FileWriter writer = new FileWriter(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt", true);
writer.write("This bug report is for: " + applicationName);
writer.write("\r\n");
@ -1486,6 +1478,13 @@ public class delegationServices {
writer.write("\r\n");
writer.write("Submission Time (Local To Server): " + timeCurrent);
writer.close();
} else {
System.out.println("Log already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred when attempting to log.");
}
BasicDBObject updateQuery = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("status", true));
@ -1508,13 +1507,6 @@ public class delegationServices {
File myObj = new File(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt");
if (myObj.createNewFile()) {
System.out.println("Log File created: " + myObj.getName());
} else {
System.out.println("Log already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
FileWriter writer = new FileWriter(homedir + "/ocs/logs/" + applicationName + bugDetails + timeCurrent +".txt", true);
writer.write("This bug report is for: " + applicationName);
writer.write("\r\n");
@ -1532,6 +1524,12 @@ public class delegationServices {
writer.write("\r\n");
writer.write(bugLog);
writer.close();
} else {
System.out.println("Log already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred while attempting to log.");
}
BasicDBObject updateQuery = new BasicDBObject();
updateQuery.append("$set",
new BasicDBObject().append("status", true));
@ -1606,6 +1604,19 @@ public class delegationServices {
}
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 = false;
}
if (keyStatus == false)
{
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
StringBuilder sb = new StringBuilder();
@ -1616,24 +1627,29 @@ public class delegationServices {
char randomChar = alphabet.charAt(index);
sb.append(randomChar);
}
String OTK = sb.toString();
String accountUUID = (String) Lrequest.get("uuid");
OTK = sb.toString();
BasicDBObject deleteKey = new BasicDBObject();
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("UUID", accountUUID);
BasicDBObject deleteKeyStatus = new BasicDBObject();
BasicDBObject deleteTie = new BasicDBObject();
deleteTie.append("UUID", accountUUID);
deleteKey.append("$set",
new BasicDBObject().append("delOTK",OTK));
accountS.updateOne(searchQuery, deleteKey);
deleteKeyStatus.append("$set",
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"));
}
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);
}
} else {

View File

@ -15,6 +15,5 @@ public class init
System.out.println( "We're starting the login delegation server, please wait one moment while we check a few things.");
com.jamesquinley.DelegationServices.delegationTimer.trigger();
System.out.println("We've started everything, requests are now being served");
com.jamesquinley.testing.splitFNet.splitNet();
}
}