Added OTK email and basic gen, need to work on callback and OTK storage within the account database.
This commit is contained in:
@ -8,7 +8,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
public class emailVerify {
|
||||
public class electronicMailHandler {
|
||||
/*
|
||||
This will handle both account creation verify and login verify tasks, it will not verify for token based logins as
|
||||
that form of login is client controlled and no user input is allowed, hacked clients are also locked out of the network
|
||||
@ -95,7 +95,46 @@ public class emailVerify {
|
||||
System.err.println("Was Not Sent Because Of An Error.");
|
||||
}
|
||||
}
|
||||
private static class SMTPAuthenticator extends
|
||||
|
||||
public static void otkEmail (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 continue, 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.");
|
||||
|
||||
Transport.send(message);
|
||||
System.out.println("Alert Sent");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Was Not Sent Because Of An Error.");
|
||||
}
|
||||
} private static class SMTPAuthenticator extends
|
||||
javax.mail.Authenticator {
|
||||
public PasswordAuthentication
|
||||
getPasswordAuthentication() {
|
||||
@ -104,9 +143,4 @@ public class emailVerify {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -2,16 +2,12 @@ package com.jamesquinley.Asecure;
|
||||
|
||||
import com.jamesquinley.DelegationServices.delegationServices;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class secureCalls {
|
||||
public static void locationBasedEmail (String email, String user, String adr, String oldAdr)
|
||||
{
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
emailVerify.newLocation(email , user, adr, oldAdr);
|
||||
electronicMailHandler.newLocation(email , user, adr, oldAdr);
|
||||
}
|
||||
};
|
||||
runnable.run();
|
||||
@ -21,4 +17,8 @@ public class secureCalls {
|
||||
{
|
||||
delegationServices.banUserEmail(email);
|
||||
}
|
||||
public static void oneTimeKeyEmail (String email, String key, String user)
|
||||
{
|
||||
electronicMailHandler.otkEmail(email,key,user);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user