public override int Run(string[] remainingArguments) { var license = _uow.Settings.Get(QueryExpressionFactory.GetQueryExpression <tbl_Setting>() .Where(x => x.ConfigKey == "RebexLicense").ToLambda()).OrderBy(x => x.Created) .Last(); Rebex.Licensing.Key = license.ConfigValue; AsymmetricKeyAlgorithm.Register(Curve25519.Create); AsymmetricKeyAlgorithm.Register(Ed25519.Create); AsymmetricKeyAlgorithm.Register(EllipticCurveAlgorithm.Create); try { if (string.IsNullOrEmpty(_privKeyPass)) { Console.Out.Write(" *** Enter password for the private key *** : "); _privKeyPass = StandardInput.GetHiddenInput(); } Console.Out.WriteLine(); Console.Out.WriteLine("Opened " + _path.FullName); KeyHelper.ImportPrivKey(_conf, _uow, _privKeyPass, SignatureHashAlgorithm.SHA256, new FileInfo(_path.FullName)); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { if (_user.tbl_UserMount != null) { Console.Out.WriteLine(" *** The user already has a mount ***"); Console.Out.WriteLine(); ConsoleHelper.StdOutUserMounts(new List <tbl_UserMount> { _user.tbl_UserMount }); return(StandardOutput.FondFarewell()); } var credentials = _uow.Credentials.Get(); ConsoleHelper.StdOutCredentials(credentials); Console.Out.WriteLine(); Console.Out.Write(" *** Enter GUID of credential to use for mount *** : "); var input = StandardInput.GetInput(); _user.tbl_UserMount.CredentialId = Guid.Parse(input); _uow.Users.Update(_user); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var config = _uow.Settings.Get(QueryExpressionFactory.GetQueryExpression <tbl_Setting>() .Where(x => x.ConfigKey == _configType.ToString()).ToLambda()) .SingleOrDefault(); if (config == null) { throw new ConsoleHelpAsException($" *** Invalid config type '{_configType.ToString()}' ***"); } config.ConfigValue = _configValue; _uow.Settings.Update(config); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { FormatOutput.Users(_uow, new List <E_User> { _user }); Console.Out.WriteLine(); Console.Out.Write(" *** Enter 'yes' to delete user *** : "); var input = StandardInput.GetInput(); Console.Out.WriteLine(); if (input.ToLower() == "yes") { _ = _service.User_DeleteV1(_user.Id) .Result; } return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var license = _uow.Settings.Get(QueryExpressionFactory.GetQueryExpression <tbl_Setting>() .Where(x => x.ConfigKey == "RebexLicense").ToLambda()).OrderBy(x => x.Created) .Last(); Rebex.Licensing.Key = license.ConfigValue; AsymmetricKeyAlgorithm.Register(Curve25519.Create); AsymmetricKeyAlgorithm.Register(Ed25519.Create); AsymmetricKeyAlgorithm.Register(EllipticCurveAlgorithm.Create); if (string.IsNullOrEmpty(_secretCurrent)) { Console.Out.Write(" *** Enter current secret to encrypt passwords *** : "); _secretCurrent = StandardInput.GetHiddenInput(); } if (string.IsNullOrEmpty(_secretNew)) { Console.Out.Write(" *** Enter new secret to encrypt passwords *** : "); _secretNew = StandardInput.GetHiddenInput(); } else { _secretNew = AlphaNumeric.CreateString(32); Console.Out.WriteLine($" *** The new secret to encrypt passwords is *** : {_secretNew}"); } var keys = _uow.PrivateKeys.Get().ToList(); var creds = _uow.Credentials.Get().ToList(); Console.Out.WriteLine(); Console.Out.WriteLine(" *** Current private key pass ciphertexts *** "); ConsoleHelper.StdOutKeyPairSecrets(keys); Console.Out.WriteLine(); Console.Out.WriteLine(" *** Current credential password ciphertexts *** "); ConsoleHelper.StdOutCredentialSecrets(creds); keys = KeyHelper.EditPrivKeySecrets(_uow, keys, _secretCurrent, _secretNew).ToList(); creds = UserHelper.EditCredentialSecrets(_uow, creds, _secretCurrent, _secretNew).ToList(); Console.Out.WriteLine(); Console.Out.WriteLine(" *** New private key pass ciphertexts *** "); ConsoleHelper.StdOutKeyPairSecrets(keys); Console.Out.WriteLine(); Console.Out.WriteLine(" *** New credential password ciphertexts *** "); ConsoleHelper.StdOutCredentialSecrets(creds); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var expression = QueryExpressionFactory.GetQueryExpression <E_User>(); if (!string.IsNullOrEmpty(_filter)) { expression = expression.Where(x => x.UserName.Contains(_filter)); } _users = _uow.Users.Get(expression.ToLambda(), new List <Expression <Func <E_User, object> > >() { x => x.UserClaims, x => x.UserLogins, x => x.UserRoles, }) .TakeLast(_count); FormatOutput.Users(_uow, _users.OrderBy(x => x.UserName)); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { Console.Out.Write($" *** Enter password for audience '{_audience.Name}' *** : "); var decryptedPass = StandardInput.GetHiddenInput(); Console.Out.WriteLine(); _ = _service.Audience_SetPasswordV1(_audience.Id, new PasswordAddV1() { EntityId = _audience.Id, NewPassword = decryptedPass, NewPasswordConfirm = decryptedPass, }).Result; var audience = _service.Audience_GetV1(_audience.Id.ToString()) .Result; FormatOutput.Audiences(_uow, new List <E_Audience> { _map.Map <E_Audience>(audience) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var env = new ContextService(InstanceContext.DeployedOrLocal); var uow = new UnitOfWork(_conf["Databases:IdentityEntities_EFCore"], env); var data = new DefaultDataFactory(uow); if (_create) { Console.WriteLine(); Console.WriteLine("\tPress key to create default data..."); Console.ReadKey(); data.CreateSettings(); data.CreateIssuers(); data.CreateAudiences(); data.CreateAudienceRoles(); data.CreateRoles(); data.CreateLogins(); data.CreateUsers(); data.CreateUserLogins(); data.CreateUserRoles(); Console.WriteLine("\tCompleted create default data..."); Console.WriteLine(); } else if (_destroy) { Console.WriteLine(); Console.WriteLine("\tPress key to destroy default data..."); Console.ReadKey(); data.Destroy(); Console.WriteLine("\tCompleted destroy default data..."); Console.WriteLine(); } else if (_destroyAll) { Console.WriteLine(); Console.WriteLine("\tPress key to destroy all data..."); Console.ReadKey(); data.Destroy(); Console.WriteLine("\tCompleted destroy all data..."); Console.WriteLine(); } return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var credentials = _uow.Credentials.Get(); if (credentials.Where(x => x.Domain == _credDomain && x.UserName == _credLogin).Any()) { Console.Out.WriteLine(" *** The credential entered already exists ***"); Console.Out.WriteLine(); ConsoleHelper.StdOutCredentials(credentials); return(StandardOutput.FondFarewell()); } if (string.IsNullOrEmpty(_credPass)) { Console.Out.Write(" *** Enter credential password to use *** : "); _credPass = StandardInput.GetHiddenInput(); Console.Out.WriteLine(); } var secret = _conf["Databases:AuroraSecret"]; var cipherText = AES.EncryptString(_credPass, secret); var plainText = AES.DecryptString(cipherText, secret); if (_credPass != plainText) { throw new ArithmeticException(); } var credential = _uow.Credentials.Create( new tbl_Credential { Id = Guid.NewGuid(), Domain = _credDomain, UserName = _credLogin, Password = cipherText, Created = DateTime.Now, Enabled = true, Deletable = true, }); _uow.Commit(); Console.Out.WriteLine(); ConsoleHelper.StdOutCredentials(credentials); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var admin = new AdminService(_conf); admin.Grant = new ResourceOwnerGrantV2(_conf); var users = admin.User_GetV1(new DataStateV1() { Sort = new List <IDataStateSort>() { new DataStateV1Sort() { Field = "userName", Dir = "asc" } }, Skip = 0, Take = 100, }).Result; foreach (var entry in users.Data) { Console.Out.WriteLine($" User '{entry.UserName}' with GUID '{entry.Id}'"); } Console.Out.WriteLine(); Console.Out.Write(" *** Enter GUID of (identity) user to use *** : "); var input = StandardInput.GetInput(); var user = _uow.Users.Create( new tbl_User { IdentityId = Guid.Parse(input), IdentityAlias = _userName, RequirePassword = true, RequirePublicKey = false, FileSystemType = _fileSystem.ToString(), Enabled = true, Deletable = false, Created = DateTime.Now, }); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { _uow.Users.Update(_user); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { UserV1 user = null; try { if (_human) { user = _service.User_CreateV1( new UserV1() { UserName = _userName, Email = _userName, FirstName = _firstName, LastName = _lastName, IsLockedOut = false, IsHumanBeing = true, IsDeletable = true, }).Result; } else { user = _service.User_CreateV1NoConfirm( new UserV1() { UserName = _userName, Email = _userName, FirstName = _firstName, LastName = _lastName, IsLockedOut = false, IsHumanBeing = false, IsDeletable = true, }).Result; } _ = _service.User_AddToLoginV1(user.Id, _login.Id) .Result; FormatOutput.Users(_uow, new List <E_User> { _map.Map <E_User>(user) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { FormatOutput.Users(_uow, new List <E_User> { _user }, true); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var keys = _uow.PublicKeys.Get(QueryExpressionFactory.GetQueryExpression <tbl_PublicKey>() .Where(x => x.IdentityId == _user.IdentityId && x.Deletable == false).ToLambda()); ConsoleHelper.StdOutKeyPairs(keys.OrderBy(x => x.Created)); if (_delete) { Console.Out.Write(" *** Enter GUID of public key to delete *** : "); var input = Guid.Parse(StandardInput.GetInput()); var key = _uow.PublicKeys.Get(QueryExpressionFactory.GetQueryExpression <tbl_PublicKey>() .Where(x => x.IdentityId == _user.IdentityId && x.Id == input).ToLambda()) .SingleOrDefault(); if (key != null) { _uow.PublicKeys.Delete(QueryExpressionFactory.GetQueryExpression <tbl_PublicKey>() .Where(x => x.IdentityId == _user.IdentityId && x.Deletable == false && x.Id == key.Id).ToLambda()); _uow.PrivateKeys.Delete(QueryExpressionFactory.GetQueryExpression <tbl_PrivateKey>() .Where(x => x.IdentityId == _user.IdentityId && x.Deletable == false && x.Id == key.PrivateKeyId).ToLambda()); _uow.Commit(); } } else if (_deleteAll) { _uow.PublicKeys.Delete(QueryExpressionFactory.GetQueryExpression <tbl_PublicKey>() .Where(x => x.IdentityId == _user.IdentityId && x.Deletable == false).ToLambda()); _uow.PrivateKeys.Delete(QueryExpressionFactory.GetQueryExpression <tbl_PrivateKey>() .Where(x => x.IdentityId == _user.IdentityId && x.Deletable == false).ToLambda()); _uow.Commit(); } return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { ConsoleHelper.StdOutKeyPairs(_user.tbl_PublicKey.OrderBy(x => x.Created)); Console.Out.WriteLine(); ConsoleHelper.StdOutUserMounts(new List <tbl_UserMount> { _user.tbl_UserMount }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var credential = _uow.Credentials.Get(QueryExpressionFactory.GetQueryExpression <tbl_Credential>() .Where(x => x.Domain == _credDomain && x.UserName == _credLogin).ToLambda()) .SingleOrDefault(); if (credential == null) { throw new ConsoleHelpAsException($" *** Invalid credential '{_credDomain}\\{_credLogin}' ***"); } if (string.IsNullOrEmpty(_credPass)) { Console.Out.Write(" *** Enter credential password to use *** : "); _credPass = StandardInput.GetHiddenInput(); Console.Out.WriteLine(); } var secret = _conf["Databases:AuroraSecret"]; var cipherText = AES.EncryptString(_credPass, secret); var plainText = AES.DecryptString(cipherText, secret); if (_credPass != plainText) { throw new ArithmeticException(); } credential.Password = cipherText; credential.LastUpdated = DateTime.Now; _uow.Credentials.Update(credential); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var mount = _user.tbl_UserMount; ConsoleHelper.StdOutUserMounts(new List <tbl_UserMount> { mount }); _uow.UserMounts.Delete(mount); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var nets = _uow.Networks.Get(QueryExpressionFactory.GetQueryExpression <tbl_Network>() .Where(x => x.IdentityId == _user.IdentityId).ToLambda()); ConsoleHelper.StdOutNetworks(nets); if (_delete) { Console.Out.Write(" *** Enter GUID of network to delete *** : "); var input = Guid.Parse(StandardInput.GetInput()); var key = _uow.Networks.Get(QueryExpressionFactory.GetQueryExpression <tbl_Network>() .Where(x => x.IdentityId == _user.IdentityId && x.Id == input).ToLambda()) .SingleOrDefault(); if (key != null) { _uow.Networks.Delete(QueryExpressionFactory.GetQueryExpression <tbl_Network>() .Where(x => x.IdentityId == _user.IdentityId && x.Id == key.Id).ToLambda()); _uow.Commit(); } } else if (_deleteAll) { _uow.Networks.Delete(QueryExpressionFactory.GetQueryExpression <tbl_Network>() .Where(x => x.IdentityId == _user.IdentityId).ToLambda()); _uow.Commit(); } return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var credentials = _uow.Credentials.Get(QueryExpressionFactory.GetQueryExpression <tbl_Credential>() .Where(x => x.Deletable == true).ToLambda()); ConsoleHelper.StdOutCredentials(credentials); if (_credID == Guid.Empty) { Console.Out.WriteLine(); Console.Out.Write(" *** Enter GUID of credential to delete *** : "); _credID = Guid.Parse(StandardInput.GetInput()); } var mounts = _uow.UserMounts.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserMount>() .Where(x => x.CredentialId == _credID).ToLambda()); if (mounts.Any()) { Console.Out.WriteLine(); Console.Out.WriteLine(" *** The credential can not be deleted while in use ***"); Console.Out.WriteLine(); ConsoleHelper.StdOutUserMounts(mounts); return(StandardOutput.FondFarewell()); } _uow.Credentials.Delete(QueryExpressionFactory.GetQueryExpression <tbl_Credential>() .Where(x => x.Id == _credID && x.Deletable == true).ToLambda()); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { _ = _service.Audience_AddToRoleV1(_audience.Id, _role.Id) .Result; var audience = _service.Audience_GetV1(_audience.Id.ToString()) .Result; FormatOutput.Audiences(_uow, new List <E_Audience> { _map.Map <E_Audience>(audience) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { _ = _service.User_RemoveFromRoleV1(_user.Id, _role.Id) .Result; var user = _service.User_GetV1(_user.Id.ToString()) .Result; FormatOutput.Users(_uow, new List <E_User> { _map.Map <E_User>(user) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { if (string.IsNullOrEmpty(_credPass)) { Console.Out.Write(" *** Enter credential password to use *** : "); _credPass = StandardInput.GetHiddenInput(); Console.Out.WriteLine(); } /* * Get the user token for the specified user, domain, and password using the unmanaged LogonUser method. * The local machine name can be used for the domain name to impersonate a user on this machine. */ var safeAccessTokenHandle = UserHelper.GetSafeAccessTokenHandle(_credDomain, _credLogin, _credPass); Console.Out.WriteLine("Beginning user is " + WindowsIdentity.GetCurrent().Name); Console.Out.WriteLine(); /* * to run as unimpersonated, pass 'SafeAccessTokenHandle.InvalidHandle' instead of variable 'safeAccessTokenHandle' */ WindowsIdentity.RunImpersonated(safeAccessTokenHandle, () => { Console.Out.WriteLine("Impersonated user is " + WindowsIdentity.GetCurrent().Name); Console.Out.WriteLine(); }); Console.Out.WriteLine("Ending user is " + WindowsIdentity.GetCurrent().Name); Console.Out.WriteLine(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { _uow.Settings.Create( new tbl_Setting { Id = Guid.NewGuid(), ConfigKey = _configType.ToString(), ConfigValue = _configValue, Deletable = true, Created = DateTime.UtcNow, }); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { if (_hashType == HashTypes.PBKDF2) { Console.Write("Enter plain text value: "); var clearText = StandardInput.GetHiddenInput(); var hashText = PBKDF2.Create(clearText); if (!PBKDF2.Validate(hashText, clearText)) { Console.WriteLine("Failed to generate hash. Please try again."); } else { Console.WriteLine(); Console.WriteLine(" Hash value: " + hashText); } } if (_hashType == HashTypes.SHA256) { Console.Write("Enter plain text value: "); var clearText = StandardInput.GetHiddenInput(); var hashText = SHA256.Create(clearText); Console.WriteLine(); Console.WriteLine(" Hash value: " + hashText); } return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var login = _service.Login_CreateV1( new LoginV1() { Name = _loginName, IsEnabled = true, IsDeletable = true, }).Result; FormatOutput.Logins(_uow, new List <E_Login> { _map.Map <E_Login>(login) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var issuer = _service.Issuer_CreateV1( new IssuerV1() { Name = _issuerName, IsEnabled = true, IsDeletable = true, }).Result; FormatOutput.Issuers(_uow, new List <E_Issuer> { _map.Map <E_Issuer>(issuer) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { if (!string.IsNullOrEmpty(_privKeyPass)) { Console.Out.Write(" *** Enter password for the private key *** : "); _privKeyPass = StandardInput.GetHiddenInput(); } else { _privKeyPass = AlphaNumeric.CreateString(32); Console.Out.WriteLine($" *** The password for the private key *** : {_privKeyPass}"); } if (string.IsNullOrEmpty(_pubKeyComment)) { _pubKeyComment = Dns.GetHostName(); } var privKey = KeyHelper.CreatePrivKey(_conf, _uow, _user, _keyAlgo, _privKeySize, _privKeyPass, SignatureHashAlgorithm.SHA256, _pubKeyComment); var pubKey = _uow.PublicKeys.Get(QueryExpressionFactory.GetQueryExpression <tbl_PublicKey>() .Where(x => x.PrivateKeyId == privKey.Id).ToLambda()) .Single(); Console.Out.WriteLine(); Console.Out.WriteLine($"{privKey.KeyValue}"); Console.Out.WriteLine($"{pubKey.KeyValue}"); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var audience = _service.Audience_CreateV1( new AudienceV1() { IssuerId = _issuer.Id, Name = _audienceName, IsLockedOut = false, IsDeletable = true, }).Result; FormatOutput.Audiences(_uow, new List <E_Audience> { _map.Map <E_Audience>(audience) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { var role = _service.Role_CreateV1( new RoleV1() { AudienceId = _audience.Id, Name = _roleName, IsEnabled = true, IsDeletable = true, }).Result; FormatOutput.Roles(_uow, new List <E_Role> { _map.Map <E_Role>(role) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public override int Run(string[] remainingArguments) { try { _uow.Networks.Create( new tbl_Network { Id = Guid.NewGuid(), IdentityId = _user.IdentityId, Address = _cidr.ToString(), Action = _actionType.ToString(), Enabled = true, Created = DateTime.UtcNow, }); _uow.Commit(); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }