Ejemplo n.º 1
0
        private void CreateHardwareVaults()
        {
            TestingHardwareVaults = new List <HardwareVault>();

            for (int i = 0; i < HardwareVaultsCount; i++)
            {
                var hardwareVault = new HardwareVault
                {
                    Id       = $"{i}",
                    MAC      = $"Q{i}:W{i}:E{i}",
                    Model    = "ST102",
                    RFID     = $"{i}{i}{i}",
                    Firmware = "3.5.2",
                    HardwareVaultProfileId = ServerConstants.DefaulHardwareVaultProfileId
                };

                TestingHardwareVaults.Add(hardwareVault);

                if (hardwareVault.Id == HardwareVaultId)
                {
                    HardwareVault            = hardwareVault;
                    hardwareVault.EmployeeId = EmployeetId;
                }
            }

            _hardwareVaultRepository.AddRangeAsync(TestingHardwareVaults);
        }
Ejemplo n.º 2
0
 public async Task WipeVaultAsync(Device remoteDevice, HardwareVault vault)
 {
     if (!remoteDevice.AccessLevel.IsLinkRequired)
     {
         await remoteDevice.Wipe(ConvertUtils.HexStringToBytes(_dataProtectionService.Decrypt(vault.MasterPassword)));
     }
 }
Ejemplo n.º 3
0
        public async Task<IActionResult> EditHardwareVaultRfid(string id, EditHardwareVaultRfidDto vaultDto)
        {
            if (id != vaultDto.Id)
            {
                return BadRequest();
            }

            try
            {
                var vault = new HardwareVault()
                {
                    Id = vaultDto.Id,
                    RFID = vaultDto.RFID
                };

                await _hardwareVaultService.UpdateRfidAsync(vault);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return StatusCode(500, new { error = ex.Message });
            }

            return NoContent();
        }
Ejemplo n.º 4
0
        public async Task AccessVaultAsync(Device remoteDevice, HardwareVault vault)
        {
            var accessParams = await _hardwareVaultService.GetAccessParamsAsync(vault.Id);

            var key = ConvertUtils.HexStringToBytes(_dataProtectionService.Decrypt(vault.MasterPassword));
            await remoteDevice.Access(DateTime.UtcNow, key, accessParams);
        }
Ejemplo n.º 5
0
        private async Task OpenDialogRemoveHardwareVaultAsync(HardwareVault hardwareVault)
        {
            if (!await VerifyAdUserAsync())
            {
                return;
            }

            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(DeleteHardwareVault));
                builder.AddAttribute(1, nameof(DeleteHardwareVault.HardwareVaultId), hardwareVault.Id);
                builder.CloseComponent();
            };

            var instance = await ModalDialogService.ShowAsync("Delete hardware vault", body);

            var result = await instance.Result;

            if (result.Succeeded)
            {
                await LoadEmployeeAsync();

                await SynchronizationService.UpdateEmployeeDetails(PageId, EmployeeId);
            }
        }
Ejemplo n.º 6
0
        public async Task AddProfileAsync(HardwareVault vault)
        {
            var previousProfileTask = await _hardwareVaultTaskRepository
                                      .Query()
                                      .FirstOrDefaultAsync(x => x.HardwareVaultId == vault.Id && x.Operation == TaskOperation.Profile);

            var newProfileTask = new HardwareVaultTask
            {
                CreatedAt       = DateTime.UtcNow,
                Operation       = TaskOperation.Profile,
                Timestamp       = UnixTime.GetUnixTimeUtcNow(),
                HardwareVaultId = vault.Id,
                Password        = vault.MasterPassword,
            };

            using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                if (previousProfileTask != null)
                {
                    await _hardwareVaultTaskRepository.DeleteAsync(previousProfileTask);
                }

                await _hardwareVaultTaskRepository.AddAsync(newProfileTask);

                transactionScope.Complete();
            }
        }
Ejemplo n.º 7
0
 private async Task SelectedItemChangedAsync(HardwareVault hardwareVault)
 {
     await InvokeAsync(() =>
     {
         SelectedHardwareVault = hardwareVault;
         StateHasChanged();
     });
 }
Ejemplo n.º 8
0
        public async Task SuspendVaultAsync(Device remoteDevice, HardwareVault vault)
        {
            if (vault.IsStatusApplied)
            {
                return;
            }

            var code = Encoding.UTF8.GetBytes(await _hardwareVaultService.GetVaultActivationCodeAsync(vault.Id));
            var key  = ConvertUtils.HexStringToBytes(_dataProtectionService.Decrypt(vault.MasterPassword));
            await remoteDevice.LockDeviceCode(key, code, 3);

            await _hardwareVaultService.SetVaultStatusAppliedAsync(vault);
        }
Ejemplo n.º 9
0
        private async Task OpenDialogShowActivationCodeAsync(HardwareVault hardwareVault)
        {
            if (!await VerifyAdUserAsync())
            {
                return;
            }

            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(HardwareVaults.ShowActivationCode));
                builder.AddAttribute(1, nameof(HardwareVaults.ShowActivationCode.HardwareVaultId), hardwareVault.Id);
                builder.CloseComponent();
            };

            await ModalDialogService.ShowAsync("Activation code", body);
        }
Ejemplo n.º 10
0
        private async Task OpenDialogHardwareVaultDetailsAsync(HardwareVault hardwareVault)
        {
            if (!await VerifyAdUserAsync())
            {
                return;
            }

            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(HardwareVaultDetails));
                builder.AddAttribute(1, nameof(HardwareVaultDetails.HardwareVault), hardwareVault);
                builder.CloseComponent();
            };

            await ModalDialogService.ShowAsync("Hardware vault details", body);
        }
Ejemplo n.º 11
0
        private async Task OpenDialogRemoveHardwareVaultAsync(HardwareVault hardwareVault)
        {
            if (!await VerifyAdUserAsync())
            {
                return;
            }

            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(DeleteHardwareVault));
                builder.AddAttribute(1, "Refresh", EventCallback.Factory.Create(this, LoadEmployeeAsync));
                builder.AddAttribute(2, "HardwareVaultId", hardwareVault.Id);
                builder.AddAttribute(3, nameof(DeleteHardwareVault.ExceptPageId), PageId);
                builder.CloseComponent();
            };

            await ModalDialogService.ShowAsync("Delete hardware vault", body);
        }