mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Added a cryptography service to encrypt protected information (unused atm)
Corrected a bug when deleting recycle bin
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Common\Behaviors\DirtyStatusBehavior.cs" />
|
||||
<Compile Include="Common\Interfaces\ICryptographyClient.cs" />
|
||||
<Compile Include="Common\Interfaces\IDatabaseSettingsProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\IDatabaseProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\IEntityVm.cs" />
|
||||
<Compile Include="Common\Interfaces\IFileProxy.cs" />
|
||||
|
@@ -1,12 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface ICryptographyClient
|
||||
{
|
||||
IEnumerable<BaseEntity> Ciphers { get; }
|
||||
IEnumerable<BaseEntity> KeyDerivations { get; }
|
||||
IEnumerable<string> CompressionAlgorithms { get; }
|
||||
Task<string> Protect(string value);
|
||||
Task<string> UnProtect(string value);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IDatabaseSettingsProxy
|
||||
{
|
||||
IEnumerable<BaseEntity> Ciphers { get; }
|
||||
IEnumerable<BaseEntity> KeyDerivations { get; }
|
||||
IEnumerable<string> CompressionAlgorithms { get; }
|
||||
}
|
||||
}
|
@@ -25,12 +25,13 @@ namespace ModernKeePass.Application.Group.Commands.DeleteGroup
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
var isRecycleBin = message.GroupId.Equals(_database.RecycleBinId);
|
||||
if (_database.IsRecycleBinEnabled && (string.IsNullOrEmpty(_database.RecycleBinId) || _database.RecycleBinId.Equals(Constants.EmptyId)))
|
||||
{
|
||||
_database.CreateGroup(_database.RootGroupId, message.RecycleBinName, true);
|
||||
}
|
||||
|
||||
if (!_database.IsRecycleBinEnabled || message.ParentGroupId.Equals(_database.RecycleBinId))
|
||||
if (!_database.IsRecycleBinEnabled || message.ParentGroupId.Equals(_database.RecycleBinId) || isRecycleBin)
|
||||
{
|
||||
_database.DeleteEntity(message.GroupId);
|
||||
}
|
||||
@@ -40,6 +41,7 @@ namespace ModernKeePass.Application.Group.Commands.DeleteGroup
|
||||
}
|
||||
|
||||
await _database.RemoveGroup(message.ParentGroupId, message.GroupId);
|
||||
if (isRecycleBin) _database.RecycleBinId = Constants.EmptyId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,16 +10,16 @@ namespace ModernKeePass.Application.Parameters.Queries.GetCiphers
|
||||
{
|
||||
public class GetCiphersQueryHandler: IRequestHandler<GetCiphersQuery, IEnumerable<CipherVm>>
|
||||
{
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
private readonly IDatabaseSettingsProxy _databaseSettings;
|
||||
|
||||
public GetCiphersQueryHandler(ICryptographyClient cryptography)
|
||||
public GetCiphersQueryHandler(IDatabaseSettingsProxy databaseSettings)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_databaseSettings = databaseSettings;
|
||||
}
|
||||
|
||||
public IEnumerable<CipherVm> Handle(GetCiphersQuery message)
|
||||
{
|
||||
return _cryptography.Ciphers.Select(c => new CipherVm
|
||||
return _databaseSettings.Ciphers.Select(c => new CipherVm
|
||||
{
|
||||
Id = c.Id,
|
||||
Name = c.Name
|
||||
|
@@ -9,16 +9,16 @@ namespace ModernKeePass.Application.Parameters.Queries.GetCompressions
|
||||
{
|
||||
public class GetCompressionsQueryHandler : IRequestHandler<GetCompressionsQuery, IEnumerable<string>>
|
||||
{
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
private readonly IDatabaseSettingsProxy _databaseSettings;
|
||||
|
||||
public GetCompressionsQueryHandler(ICryptographyClient cryptography)
|
||||
public GetCompressionsQueryHandler(IDatabaseSettingsProxy databaseSettings)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_databaseSettings = databaseSettings;
|
||||
}
|
||||
|
||||
public IEnumerable<string> Handle(GetCompressionsQuery message)
|
||||
{
|
||||
return _cryptography.CompressionAlgorithms.OrderBy(c => c);
|
||||
return _databaseSettings.CompressionAlgorithms.OrderBy(c => c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,16 +10,16 @@ namespace ModernKeePass.Application.Parameters.Queries.GetKeyDerivations
|
||||
{
|
||||
public class GetKeyDerivationsQueryHandler : IRequestHandler<GetKeyDerivationsQuery, IEnumerable<KeyDerivationVm>>
|
||||
{
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
private readonly IDatabaseSettingsProxy _databaseSettings;
|
||||
|
||||
public GetKeyDerivationsQueryHandler(ICryptographyClient cryptography)
|
||||
public GetKeyDerivationsQueryHandler(IDatabaseSettingsProxy databaseSettings)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_databaseSettings = databaseSettings;
|
||||
}
|
||||
|
||||
public IEnumerable<KeyDerivationVm> Handle(GetKeyDerivationsQuery message)
|
||||
{
|
||||
return _cryptography.KeyDerivations.Select(c => new KeyDerivationVm
|
||||
return _databaseSettings.KeyDerivations.Select(c => new KeyDerivationVm
|
||||
{
|
||||
Id = c.Id,
|
||||
Name = c.Name
|
||||
|
Reference in New Issue
Block a user