Adds version and key status prep on new accounts.
This commit is contained in:
@ -19,6 +19,11 @@ public class secureCalls {
|
||||
}
|
||||
public static void oneTimeKeyEmail (String email, String key, String user)
|
||||
{
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
electronicMailHandler.otkEmail(email,key,user);
|
||||
}
|
||||
};
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.jamesquinley.DelegationServices;
|
||||
|
||||
import com.jamesquinley.Asecure.electronicMailHandler;
|
||||
import com.jamesquinley.Asecure.secureCalls;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.MongoClientSettings;
|
||||
@ -454,15 +455,22 @@ public class delegationServices {
|
||||
String Path;
|
||||
String UserName;
|
||||
String Email;
|
||||
Boolean accountKeyStatus = false;
|
||||
try {
|
||||
accountServer = accountS.find(eq("User", username)).first();
|
||||
Password = (String) accountServer.get("Password");
|
||||
System.out.println("Stuff");
|
||||
Email = (String) accountServer.get("Email");
|
||||
if (accountServer.get("Status").equals(true)) {
|
||||
System.out.println("Stuff1");
|
||||
if (accountServer.get("Version").equals("1"))
|
||||
if (accountServer.get("Version").equals("1")) {
|
||||
try {
|
||||
accountKeyStatus = accountServer.getBoolean("keyStatus");
|
||||
} catch (Exception NPE)
|
||||
{
|
||||
System.out.println("Generating OTP");
|
||||
System.out.println("Assuming False Due To Variable Not Existing For User.");
|
||||
accountKeyStatus = false;
|
||||
}
|
||||
if (accountKeyStatus == false ) {
|
||||
System.out.println(accountKeyStatus);
|
||||
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
@ -472,12 +480,51 @@ public class delegationServices {
|
||||
char randomChar = alphabet.charAt(index);
|
||||
sb.append(randomChar);
|
||||
}
|
||||
String randomString = sb.toString();
|
||||
String OTK = sb.toString();
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
BasicDBObject keyApplicationIndex = new BasicDBObject();
|
||||
searchQuery.append("clientid", ClientID);
|
||||
keyApplicationIndex.append("Email", Email);
|
||||
secureCalls.oneTimeKeyEmail(((String) accountServer.get("Email")), OTK, username);
|
||||
BasicDBObject updateQuery = new BasicDBObject();
|
||||
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||
BasicDBObject keyApply = new BasicDBObject();
|
||||
BasicDBObject keyAccountState = new BasicDBObject();
|
||||
updateQuery.append("$set",
|
||||
new BasicDBObject().append("type", 53));
|
||||
updateQuery1.append("$set",
|
||||
new BasicDBObject().append("status", true));
|
||||
keyAccountState.append("$set",
|
||||
new BasicDBObject().append("keyStatus", true));
|
||||
keyApply.append("$set",
|
||||
new BasicDBObject().append("tempKey", OTK));
|
||||
accountS.updateOne(keyApplicationIndex, keyApply);
|
||||
accountS.updateOne(keyApplicationIndex, keyAccountState);
|
||||
dCollection.updateOne(searchQuery, updateQuery);
|
||||
dCollection.updateOne(searchQuery, updateQuery1);
|
||||
accountKeyStatus = true;
|
||||
} else {
|
||||
System.out.println("RS1");
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
searchQuery.append("clientid", ClientID);
|
||||
BasicDBObject updateQuery = new BasicDBObject();
|
||||
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||
updateQuery.append("$set",
|
||||
new BasicDBObject().append("type", 53));
|
||||
updateQuery1.append("$set",
|
||||
new BasicDBObject().append("status", true));
|
||||
dCollection.updateOne(searchQuery, updateQuery);
|
||||
dCollection.updateOne(searchQuery, updateQuery1);
|
||||
//delegationTimer.trigger();
|
||||
delegationTimer.DeleteTargetRequest(ClientID);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("RS1");
|
||||
if (Password.equals(password)) {
|
||||
System.out.println("R3c");
|
||||
Token = (int) accountServer.get("Token");
|
||||
Fname = (String) accountServer.get("FName");
|
||||
Path = (String) accountServer.get("Path");
|
||||
@ -553,6 +600,35 @@ public class delegationServices {
|
||||
delegationTimer.DeleteTargetRequest(ClientID);
|
||||
}
|
||||
} catch (Exception ERC) {
|
||||
System.out.println("Something Went Wrong: " + ERC.getLocalizedMessage());
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
searchQuery.append("clientid", ClientID);
|
||||
|
||||
BasicDBObject updateQuery = new BasicDBObject();
|
||||
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||
updateQuery.append("$set",
|
||||
new BasicDBObject().append("type", 9));
|
||||
updateQuery1.append("$set",
|
||||
new BasicDBObject().append("status", true));
|
||||
dCollection.updateOne(searchQuery, updateQuery);
|
||||
dCollection.updateOne(searchQuery, updateQuery1);
|
||||
//delegationTimer.trigger();
|
||||
delegationTimer.DeleteTargetRequest(ClientID);
|
||||
}
|
||||
|
||||
}
|
||||
if (requesttype == 54) {
|
||||
System.out.println("Verifying OTK");
|
||||
String userKey = (String) Lrequest.get("otk");
|
||||
Document accountServer;
|
||||
try {
|
||||
accountServer = accountS.find(eq("tempKey", userKey)).first();
|
||||
if (accountServer.get("Status").equals(true))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception ERC) {
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
searchQuery.append("clientid", ClientID);
|
||||
|
||||
@ -882,7 +958,8 @@ public class delegationServices {
|
||||
createForm.append("Token", tokenSTGEN);
|
||||
createForm.append("Control", 1);
|
||||
createForm.append("Upgrade", 0);
|
||||
createForm.append("Version", 2);
|
||||
createForm.append("Version","2");
|
||||
createForm.append("keyStatus", false);
|
||||
//createForm.append("Uid",uid);
|
||||
createForm.append("lastNet", Macid);
|
||||
accountS.insertOne(createForm);
|
||||
|
Reference in New Issue
Block a user