Added OTK email and basic gen, need to work on callback and OTK storage within the account database.
This commit is contained in:
parent
cafab0fce1
commit
f9a71152b6
@ -8,7 +8,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
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
|
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
|
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.");
|
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 {
|
javax.mail.Authenticator {
|
||||||
public PasswordAuthentication
|
public PasswordAuthentication
|
||||||
getPasswordAuthentication() {
|
getPasswordAuthentication() {
|
||||||
@ -104,9 +143,4 @@ public class emailVerify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,16 +2,12 @@ package com.jamesquinley.Asecure;
|
|||||||
|
|
||||||
import com.jamesquinley.DelegationServices.delegationServices;
|
import com.jamesquinley.DelegationServices.delegationServices;
|
||||||
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class secureCalls {
|
public class secureCalls {
|
||||||
public static void locationBasedEmail (String email, String user, String adr, String oldAdr)
|
public static void locationBasedEmail (String email, String user, String adr, String oldAdr)
|
||||||
{
|
{
|
||||||
final Runnable runnable = new Runnable() {
|
final Runnable runnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
emailVerify.newLocation(email , user, adr, oldAdr);
|
electronicMailHandler.newLocation(email , user, adr, oldAdr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
runnable.run();
|
runnable.run();
|
||||||
@ -21,4 +17,8 @@ public class secureCalls {
|
|||||||
{
|
{
|
||||||
delegationServices.banUserEmail(email);
|
delegationServices.banUserEmail(email);
|
||||||
}
|
}
|
||||||
|
public static void oneTimeKeyEmail (String email, String key, String user)
|
||||||
|
{
|
||||||
|
electronicMailHandler.otkEmail(email,key,user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.jamesquinley.DelegationServices;
|
package com.jamesquinley.DelegationServices;
|
||||||
|
|
||||||
|
import com.jamesquinley.Asecure.electronicMailHandler;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
import com.mongodb.ConnectionString;
|
import com.mongodb.ConnectionString;
|
||||||
import com.mongodb.MongoClientSettings;
|
import com.mongodb.MongoClientSettings;
|
||||||
@ -10,7 +11,7 @@ import com.mongodb.client.MongoCollection;
|
|||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
import javax.print.Doc;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.mongodb.client.model.Filters.eq;
|
import static com.mongodb.client.model.Filters.eq;
|
||||||
@ -456,7 +457,26 @@ 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");
|
||||||
|
System.out.println("Stuff");
|
||||||
if (accountServer.get("Status").equals(true)) {
|
if (accountServer.get("Status").equals(true)) {
|
||||||
|
System.out.println("Stuff1");
|
||||||
|
if (accountServer.get("Version").equals("1"))
|
||||||
|
{
|
||||||
|
System.out.println("Generating OTP");
|
||||||
|
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
Random random = new Random();
|
||||||
|
int length = 15;
|
||||||
|
for(int i = 0; i < length; i++) {
|
||||||
|
int index = random.nextInt(alphabet.length());
|
||||||
|
char randomChar = alphabet.charAt(index);
|
||||||
|
sb.append(randomChar);
|
||||||
|
}
|
||||||
|
String randomString = sb.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
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");
|
||||||
@ -516,6 +536,7 @@ public class delegationServices {
|
|||||||
//delegationTimer.trigger();
|
//delegationTimer.trigger();
|
||||||
delegationTimer.DeleteTargetRequest(ClientID);
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Banned Account");
|
System.out.println("Banned Account");
|
||||||
BasicDBObject searchQuery = new BasicDBObject();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
@ -861,6 +882,7 @@ public class delegationServices {
|
|||||||
createForm.append("Token", tokenSTGEN);
|
createForm.append("Token", tokenSTGEN);
|
||||||
createForm.append("Control", 1);
|
createForm.append("Control", 1);
|
||||||
createForm.append("Upgrade", 0);
|
createForm.append("Upgrade", 0);
|
||||||
|
createForm.append("Version", 2);
|
||||||
//createForm.append("Uid",uid);
|
//createForm.append("Uid",uid);
|
||||||
createForm.append("lastNet", Macid);
|
createForm.append("lastNet", Macid);
|
||||||
accountS.insertOne(createForm);
|
accountS.insertOne(createForm);
|
||||||
@ -872,7 +894,7 @@ public class delegationServices {
|
|||||||
FNETDOC.insertOne(FnetInit);
|
FNETDOC.insertOne(FnetInit);
|
||||||
BasicDBObject searchQuery = new BasicDBObject();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
searchQuery.append("clientid", ClientID);
|
searchQuery.append("clientid", ClientID);
|
||||||
com.jamesquinley.Asecure.emailVerify.Onboarding(Email, User);
|
electronicMailHandler.Onboarding(Email, User);
|
||||||
BasicDBObject updateQuery = new BasicDBObject();
|
BasicDBObject updateQuery = new BasicDBObject();
|
||||||
BasicDBObject updateQuery1 = new BasicDBObject();
|
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||||
updateQuery.append("$set",
|
updateQuery.append("$set",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user