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)
|
public static void oneTimeKeyEmail (String email, String key, String user)
|
||||||
{
|
{
|
||||||
electronicMailHandler.otkEmail(email,key,user);
|
final Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
electronicMailHandler.otkEmail(email,key,user);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
runnable.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.jamesquinley.DelegationServices;
|
package com.jamesquinley.DelegationServices;
|
||||||
|
|
||||||
import com.jamesquinley.Asecure.electronicMailHandler;
|
import com.jamesquinley.Asecure.electronicMailHandler;
|
||||||
|
import com.jamesquinley.Asecure.secureCalls;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
import com.mongodb.ConnectionString;
|
import com.mongodb.ConnectionString;
|
||||||
import com.mongodb.MongoClientSettings;
|
import com.mongodb.MongoClientSettings;
|
||||||
@ -445,8 +446,8 @@ public class delegationServices {
|
|||||||
}
|
}
|
||||||
if (requesttype == 2) {
|
if (requesttype == 2) {
|
||||||
System.out.println("Login Request (USR&PASS)");
|
System.out.println("Login Request (USR&PASS)");
|
||||||
String username = (String) Lrequest.get("User");
|
String username = (String) Lrequest.get("User");
|
||||||
String password = (String) Lrequest.get("Password");
|
String password = (String) Lrequest.get("Password");
|
||||||
Document accountServer;
|
Document accountServer;
|
||||||
String Password;
|
String Password;
|
||||||
int Token;
|
int Token;
|
||||||
@ -454,30 +455,76 @@ public class delegationServices {
|
|||||||
String Path;
|
String Path;
|
||||||
String UserName;
|
String UserName;
|
||||||
String Email;
|
String Email;
|
||||||
|
Boolean accountKeyStatus = false;
|
||||||
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");
|
Email = (String) accountServer.get("Email");
|
||||||
if (accountServer.get("Status").equals(true)) {
|
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");
|
||||||
System.out.println("Generating OTP");
|
} catch (Exception NPE)
|
||||||
|
{
|
||||||
|
System.out.println("Assuming False Due To Variable Not Existing For User.");
|
||||||
|
accountKeyStatus = false;
|
||||||
|
}
|
||||||
|
if (accountKeyStatus == false ) {
|
||||||
|
System.out.println(accountKeyStatus);
|
||||||
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
|
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int length = 15;
|
int length = 15;
|
||||||
for(int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int index = random.nextInt(alphabet.length());
|
int index = random.nextInt(alphabet.length());
|
||||||
char randomChar = alphabet.charAt(index);
|
char randomChar = alphabet.charAt(index);
|
||||||
sb.append(randomChar);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
System.out.println("RS1");
|
||||||
if (Password.equals(password)) {
|
if (Password.equals(password)) {
|
||||||
|
System.out.println("R3c");
|
||||||
Token = (int) accountServer.get("Token");
|
Token = (int) accountServer.get("Token");
|
||||||
Fname = (String) accountServer.get("FName");
|
Fname = (String) accountServer.get("FName");
|
||||||
Path = (String) accountServer.get("Path");
|
Path = (String) accountServer.get("Path");
|
||||||
@ -553,6 +600,35 @@ public class delegationServices {
|
|||||||
delegationTimer.DeleteTargetRequest(ClientID);
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
}
|
}
|
||||||
} catch (Exception ERC) {
|
} 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();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
searchQuery.append("clientid", ClientID);
|
searchQuery.append("clientid", ClientID);
|
||||||
|
|
||||||
@ -882,7 +958,8 @@ 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("Version","2");
|
||||||
|
createForm.append("keyStatus", false);
|
||||||
//createForm.append("Uid",uid);
|
//createForm.append("Uid",uid);
|
||||||
createForm.append("lastNet", Macid);
|
createForm.append("lastNet", Macid);
|
||||||
accountS.insertOne(createForm);
|
accountS.insertOne(createForm);
|
||||||
|
Reference in New Issue
Block a user