Allows For Creation Of Limited Accounts (via DBS)
This commit is contained in:
parent
09ea12a35a
commit
730728260b
@ -14,31 +14,51 @@ import static com.mongodb.client.model.Filters.eq;
|
|||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
|
||||||
public class delegationServices {
|
public class delegationServices {
|
||||||
static ConnectionString BetascReadconnectionString = new ConnectionString("mongodb+srv://serverClientBeta:Unz6c3I0wjrUVBIf@delegationrequest.qnvfa.mongodb.net/mDelegationRequest?retryWrites=true&w=majority");
|
static ConnectionString scReadconnectionString;
|
||||||
static MongoClientSettings BetascReadsettings = MongoClientSettings.builder()
|
static MongoClientSettings scReadsettings;
|
||||||
.applyConnectionString(BetascReadconnectionString)
|
static MongoClient dClient;
|
||||||
.applyToSocketSettings(builder ->
|
static MongoDatabase dClientDatabase;
|
||||||
builder.connectTimeout(5, SECONDS)
|
static MongoCollection<Document> dCollection;
|
||||||
.readTimeout(6, SECONDS))
|
static MongoDatabase RGFilterDB;
|
||||||
.build();
|
static MongoCollection<Document> RGFilter;
|
||||||
static MongoClient BetadClient = MongoClients.create(BetascReadsettings);
|
|
||||||
static MongoDatabase BetadClientDatabase = BetadClient.getDatabase("DelegationRequest");
|
|
||||||
static MongoCollection<Document> BetadCollection = BetadClientDatabase.getCollection("accountRequest");
|
|
||||||
|
|
||||||
static ConnectionString scReadconnectionString = new ConnectionString("mongodb+srv://serverClient:x2sJ8Qu0VVMifNLX@accountdelegation.n06hb.mongodb.net/DelegationRequest?retryWrites=true&w=majority");
|
public static void connectionInit (Boolean beta)
|
||||||
static MongoClientSettings scReadsettings = MongoClientSettings.builder()
|
{
|
||||||
|
if (beta == true)
|
||||||
|
{
|
||||||
|
scReadconnectionString = new ConnectionString("mongodb+srv://serverClientBeta:Unz6c3I0wjrUVBIf@delegationrequest.qnvfa.mongodb.net/mDelegationRequest?retryWrites=true&w=majority");
|
||||||
|
//connects to database that beta clients can use.
|
||||||
|
System.out.println("This is a beta server build (and will only work on that type)");
|
||||||
|
scReadsettings = MongoClientSettings.builder()
|
||||||
.applyConnectionString(scReadconnectionString)
|
.applyConnectionString(scReadconnectionString)
|
||||||
.applyToSocketSettings(builder ->
|
.applyToSocketSettings(builder ->
|
||||||
builder.connectTimeout(5, SECONDS)
|
builder.connectTimeout(5, SECONDS)
|
||||||
.readTimeout(6, SECONDS))
|
.readTimeout(6, SECONDS))
|
||||||
.build();
|
.build();
|
||||||
static MongoClient dClient = MongoClients.create(scReadsettings);
|
dClient = MongoClients.create(scReadsettings);
|
||||||
static MongoDatabase dClientDatabase = dClient.getDatabase("DelegationRequest");
|
dClientDatabase = dClient.getDatabase("DelegationRequest");
|
||||||
static MongoCollection<Document> dCollection = dClientDatabase.getCollection("accountRequest");
|
dCollection = dClientDatabase.getCollection("accountRequest");
|
||||||
|
RGFilterDB = dClient.getDatabase("rgcon");
|
||||||
static MongoDatabase RGFilterDB = dClient.getDatabase("rgcon");
|
RGFilter = RGFilterDB.getCollection("blocked");
|
||||||
static MongoCollection<Document> RGFilter = RGFilterDB.getCollection("blocked");
|
} else
|
||||||
|
{
|
||||||
|
scReadconnectionString = new ConnectionString("mongodb+srv://serverClient:x2sJ8Qu0VVMifNLX@accountdelegation.n06hb.mongodb.net/DelegationRequest?retryWrites=true&w=majority");
|
||||||
|
//connects to database that production clients can use
|
||||||
|
System.out.println("This is a production server build (and will only work on that type)");
|
||||||
|
scReadsettings = MongoClientSettings.builder()
|
||||||
|
.applyConnectionString(scReadconnectionString)
|
||||||
|
.applyToSocketSettings(builder ->
|
||||||
|
builder.connectTimeout(5, SECONDS)
|
||||||
|
.readTimeout(6, SECONDS))
|
||||||
|
.build();
|
||||||
|
dClient = MongoClients.create(scReadsettings);
|
||||||
|
dClientDatabase = dClient.getDatabase("DelegationRequest");
|
||||||
|
dCollection = dClientDatabase.getCollection("accountRequest");
|
||||||
|
RGFilterDB = dClient.getDatabase("rgcon");
|
||||||
|
RGFilter = RGFilterDB.getCollection("blocked");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//TODO get switcher working, NPE currently triggers on post init, move below code block into if statement, or outside of it so it will do the same thing regardless of t/f switch output
|
||||||
static ConnectionString AccountCon = new ConnectionString("mongodb+srv://DelegationServerClient:UNxldb8abSJkWscG@account.ufgrh.mongodb.net/account?retryWrites=true&w=majority");
|
static ConnectionString AccountCon = new ConnectionString("mongodb+srv://DelegationServerClient:UNxldb8abSJkWscG@account.ufgrh.mongodb.net/account?retryWrites=true&w=majority");
|
||||||
static MongoClientSettings AccountSettings = MongoClientSettings.builder()
|
static MongoClientSettings AccountSettings = MongoClientSettings.builder()
|
||||||
.applyConnectionString(AccountCon)
|
.applyConnectionString(AccountCon)
|
||||||
@ -96,7 +116,7 @@ public class delegationServices {
|
|||||||
|
|
||||||
System.out.println("Delegation Has Started");
|
System.out.println("Delegation Has Started");
|
||||||
if(requesttype == 0 || requesttype == 1 || requesttype == 2 || requesttype == 3 || requesttype == 4 || requesttype == 5 || requesttype == 6 || requesttype ==7 || requesttype == 8 || requesttype ==9 || requesttype ==10 || requesttype ==11 || requesttype ==12) {
|
if(requesttype == 0 || requesttype == 1 || requesttype == 2 || requesttype == 3 || requesttype == 4 || requesttype == 5 || requesttype == 6 || requesttype ==7 || requesttype == 8 || requesttype ==9 || requesttype ==10 || requesttype ==11 || requesttype ==12) {
|
||||||
if (requesttype == 7 || requesttype == 12 || requesttype == 4 || requesttype == 5 || requesttype == 6 || requesttype == 19) {
|
if (requesttype == 7 || requesttype == 12 || requesttype == 4 || requesttype == 5 || requesttype == 6 || requesttype == 19 || requesttype == 20) {
|
||||||
System.out.println("An Excluded Request (7MAL, 12S, 4C, 5C, 6C) Has Been Detected, Ignoring");
|
System.out.println("An Excluded Request (7MAL, 12S, 4C, 5C, 6C) Has Been Detected, Ignoring");
|
||||||
//Thinking of moving all purge timer call to here to centralize deletion decision.
|
//Thinking of moving all purge timer call to here to centralize deletion decision.
|
||||||
}
|
}
|
||||||
@ -738,7 +758,90 @@ public class delegationServices {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (requesttype == 20)
|
||||||
|
//TODO rewrite to just need username, password will be set by system later
|
||||||
|
{
|
||||||
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
|
System.out.println("Account Creation Request");
|
||||||
|
Document DServer = dCollection.find(eq("clientid",ClientID)).first();
|
||||||
|
String User = (String) DServer.get("User");
|
||||||
|
// String Password = (String) DServer.get("Password");
|
||||||
|
// String Email = (String) DServer.get("Email");
|
||||||
|
String FName = User;
|
||||||
|
int min = 100000000;
|
||||||
|
int max = 999999999;
|
||||||
|
double tokenGEN = Math.random()*(max-min+1)+min;
|
||||||
|
int tokenSTGEN = (int) tokenGEN;
|
||||||
|
|
||||||
|
//verify open cert
|
||||||
|
try {
|
||||||
|
Document DupeUser = accountS.find(eq("User", User)).first();
|
||||||
|
String DUPE = (String) DupeUser.get("User");
|
||||||
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
|
searchQuery.append("clientid", ClientID);
|
||||||
|
|
||||||
|
BasicDBObject updateQuery = new BasicDBObject();
|
||||||
|
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||||
|
updateQuery.append("$set",
|
||||||
|
new BasicDBObject().append("type", 6));
|
||||||
|
updateQuery1.append("$set",
|
||||||
|
new BasicDBObject().append("status", true));
|
||||||
|
dCollection.updateOne(searchQuery, updateQuery);
|
||||||
|
dCollection.updateOne(searchQuery, updateQuery1);
|
||||||
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
|
} catch (Exception exr) {
|
||||||
|
System.out.println("Username Is Open");
|
||||||
|
try {
|
||||||
|
Document DupeToken = accountS.find(eq("Token", tokenSTGEN)).first();
|
||||||
|
int DupeToke1n = (int) DupeToken.get("Token");
|
||||||
|
|
||||||
|
Boolean TokenOpen = false;
|
||||||
|
while (TokenOpen == false) {
|
||||||
|
tokenGEN = Math.random()*(max-min+1)+min;
|
||||||
|
tokenSTGEN = (int) tokenGEN;
|
||||||
|
try {
|
||||||
|
DupeToken = accountS.find(eq("Token", tokenSTGEN)).first();
|
||||||
|
DupeToke1n = (int) DupeToken.get("Token");
|
||||||
|
System.out.println("Token Is Reserved, Try Again.");
|
||||||
|
tokenGEN = Math.random()*(max-min+1)+min;
|
||||||
|
tokenSTGEN = (int) tokenGEN;
|
||||||
|
} catch (Exception exDr) {
|
||||||
|
TokenOpen = true;
|
||||||
|
System.out.println("Token Free (While EXP)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception exrs) {
|
||||||
|
System.out.println("Token Free (Main)");
|
||||||
|
System.out.println("Creating.");
|
||||||
|
Document createForm = new Document();
|
||||||
|
createForm.append("User", User);
|
||||||
|
createForm.append("Status", true);
|
||||||
|
createForm.append("limited", true);
|
||||||
|
createForm.append("Flagged", false);
|
||||||
|
createForm.append("FName", FName);
|
||||||
|
createForm.append("Entitlements", "NA");
|
||||||
|
createForm.append("Path", "C:\\ObsidianCoreStudios\\Launcher\\AOTSK\\");
|
||||||
|
createForm.append("Freinds", " ");
|
||||||
|
createForm.append("Token", tokenSTGEN);
|
||||||
|
createForm.append("Control", 1);
|
||||||
|
accountS.insertOne(createForm);
|
||||||
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
|
searchQuery.append("clientid", ClientID);
|
||||||
|
BasicDBObject updateQuery = new BasicDBObject();
|
||||||
|
BasicDBObject updateQuery1 = new BasicDBObject();
|
||||||
|
updateQuery.append("$set",
|
||||||
|
new BasicDBObject().append("type", 4));
|
||||||
|
updateQuery1.append("$set",
|
||||||
|
new BasicDBObject().append("status", true));
|
||||||
|
dCollection.updateOne(searchQuery, updateQuery);
|
||||||
|
dCollection.updateOne(searchQuery, updateQuery1);
|
||||||
|
System.out.println("Update Request With Finished Status");
|
||||||
|
delegationTimer.DeleteTargetRequest(ClientID);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Malformed Request, Non Recoverable");
|
System.out.println("Malformed Request, Non Recoverable");
|
||||||
BasicDBObject searchQuery = new BasicDBObject();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
package com.jamesquinley;
|
package com.jamesquinley;
|
||||||
|
|
||||||
|
import com.jamesquinley.DelegationServices.status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Hey there! This is the source code for AOTSK-Delegation Server, self explanitory.
|
Hey there! This is the source code for AOTSK-Delegation Server, self explanitory.
|
||||||
Also this is multi line so I can justify using this type of comment.
|
Also this is multi line so I can justify using this type of comment.
|
||||||
@ -7,6 +10,7 @@ public class init
|
|||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
|
com.jamesquinley.DelegationServices.delegationServices.connectionInit(status.betaServer);
|
||||||
com.jamesquinley.DelegationServices.delegationServices.Purge();
|
com.jamesquinley.DelegationServices.delegationServices.Purge();
|
||||||
System.out.println( "We're starting the login delegation server, please wait one moment while we check a few things.");
|
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();
|
com.jamesquinley.DelegationServices.delegationTimer.trigger();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user