mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Removed ModernKeePassLib dependency
Code cleanup WIP on service replacement and VM use
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Parameters.Commands.SetCipher
|
||||
{
|
||||
public class SetCipherCommand : IRequest
|
||||
{
|
||||
public string CipherId { get; set; }
|
||||
|
||||
public class SetCipherCommandHandler : IRequestHandler<SetCipherCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetCipherCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetCipherCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.CipherId = message.CipherId;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Parameters.Commands.SetCompression
|
||||
{
|
||||
public class SetCompressionCommand : IRequest
|
||||
{
|
||||
public string Compression { get; set; }
|
||||
|
||||
public class SetCompressionCommandHandler : IRequestHandler<SetCompressionCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetCompressionCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetCompressionCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.Compression = message.Compression;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin
|
||||
{
|
||||
public class SetHasRecycleBinCommand : IRequest
|
||||
{
|
||||
public bool HasRecycleBin { get; set; }
|
||||
|
||||
public class SetHasRecycleBinCommandHandler : IRequestHandler<SetHasRecycleBinCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetHasRecycleBinCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetHasRecycleBinCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.IsRecycleBinEnabled = message.HasRecycleBin;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Parameters.Commands.SetKeyDerivation
|
||||
{
|
||||
public class SetKeyDerivationCommand : IRequest
|
||||
{
|
||||
public string KeyDerivationId { get; set; }
|
||||
|
||||
public class SetKeyDerivationCommandHandler : IRequestHandler<SetKeyDerivationCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetKeyDerivationCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetKeyDerivationCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.KeyDerivationId = message.KeyDerivationId;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Parameters.Commands.SetRecycleBin
|
||||
{
|
||||
public class SetRecycleBinCommand : IRequest
|
||||
{
|
||||
public string RecycleBinId { get; set; }
|
||||
|
||||
public class SetRecycleBinCommandHandler : IRequestHandler<SetRecycleBinCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetRecycleBinCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetRecycleBinCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.RecycleBinId = message.RecycleBinId;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
ModernKeePass.Application/Parameters/Models/CipherVm.cs
Normal file
18
ModernKeePass.Application/Parameters/Models/CipherVm.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using AutoMapper;
|
||||
using ModernKeePass.Application.Common.Mappings;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Models
|
||||
{
|
||||
public class CipherVm: IMapFrom<BaseEntity>
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public void Mapping(Profile profile)
|
||||
{
|
||||
profile.CreateMap<BaseEntity, CipherVm>()
|
||||
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
|
||||
.ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
using AutoMapper;
|
||||
using ModernKeePass.Application.Common.Mappings;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Models
|
||||
{
|
||||
public class KeyDerivationVm : IMapFrom<BaseEntity>
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public void Mapping(Profile profile)
|
||||
{
|
||||
profile.CreateMap<BaseEntity, CipherVm>()
|
||||
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
|
||||
.ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Cryptography.Models;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Queries.GetCiphers
|
||||
{
|
||||
public class GetCiphersQuery: IRequest<IEnumerable<CipherVm>>
|
||||
{
|
||||
public class GetCiphersQueryHandler: IRequestHandler<GetCiphersQuery, IEnumerable<CipherVm>>
|
||||
{
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public GetCiphersQueryHandler(ICryptographyClient cryptography, IMapper mapper)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public IEnumerable<CipherVm> Handle(GetCiphersQuery message)
|
||||
{
|
||||
yield return _mapper.Map<CipherVm>(_cryptography.Ciphers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Queries.GetCompressions
|
||||
{
|
||||
public class GetCompressionsQuery : IRequest<IEnumerable<string>>
|
||||
{
|
||||
public class GetCompressionsQueryHandler : IRequestHandler<GetCompressionsQuery, IEnumerable<string>>
|
||||
{
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
|
||||
public GetCompressionsQueryHandler(ICryptographyClient cryptography)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
}
|
||||
|
||||
public IEnumerable<string> Handle(GetCompressionsQuery message)
|
||||
{
|
||||
return _cryptography.CompressionAlgorithms.OrderBy(c => c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Cryptography.Models;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Queries.GetKeyDerivations
|
||||
{
|
||||
public class GetKeyDerivationsQuery : IRequest<IEnumerable<KeyDerivationVm>>
|
||||
{
|
||||
public class GetKeyDerivationsQueryHandler : IRequestHandler<GetKeyDerivationsQuery, IEnumerable<KeyDerivationVm>>
|
||||
{
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public GetKeyDerivationsQueryHandler(ICryptographyClient cryptography, IMapper mapper)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public IEnumerable<KeyDerivationVm> Handle(GetKeyDerivationsQuery message)
|
||||
{
|
||||
yield return _mapper.Map<KeyDerivationVm>(_cryptography.KeyDerivations);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user