mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
1st working version in clean arch
WIP Parent group mapping issues
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System.Reflection;
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Infrastructure.Common;
|
||||
@@ -13,9 +11,6 @@ namespace ModernKeePass.Infrastructure
|
||||
{
|
||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services)
|
||||
{
|
||||
var assembly = typeof(DependencyInjection).GetTypeInfo().Assembly;
|
||||
services.AddAutoMapper(assembly);
|
||||
|
||||
services.AddSingleton(typeof(IDatabaseProxy), typeof(KeePassDatabaseClient));
|
||||
services.AddTransient(typeof(ICryptographyClient), typeof(KeePassCryptographyClient));
|
||||
services.AddTransient(typeof(IPasswordProxy), typeof(KeePassPasswordClient));
|
||||
|
@@ -19,6 +19,7 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
{
|
||||
Uri url;
|
||||
CreateMap<PwEntry, EntryEntity>()
|
||||
//.ForMember(dest => dest.Parent, opt => opt.MapFrom(src => src.ParentGroup))
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Uuid.ToHexString()))
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField)))
|
||||
.ForMember(dest => dest.UserName, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.UserNameField)))
|
||||
@@ -37,6 +38,7 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
.ForMember(dest => dest.AdditionalFields, opt => opt.MapFrom(src =>
|
||||
src.Strings.Where(s => !PwDefs.GetStandardFields().Contains(s.Key)).ToDictionary(s => s.Key, s => GetEntryValue(src, s.Key))))
|
||||
.ForMember(dest => dest.LastModificationDate, opt => opt.MapFrom(src => new DateTimeOffset(src.LastModificationTime)));
|
||||
//.MaxDepth(1);
|
||||
}
|
||||
|
||||
private void FromModelToDto()
|
||||
|
@@ -15,17 +15,18 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
private void FromDtoToModel()
|
||||
{
|
||||
CreateMap<PwGroup, GroupEntity>()
|
||||
//.ForMember(d => d.Parent, opts => opts.MapFrom(s => s.ParentGroup))
|
||||
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Uuid.ToHexString()))
|
||||
.ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name))
|
||||
.ForMember(d => d.Icon, opts => opts.MapFrom(s => IconMapper.MapPwIconToIcon(s.IconId)))
|
||||
.ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime))
|
||||
.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries))
|
||||
.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.Groups));
|
||||
//.MaxDepth(1);
|
||||
}
|
||||
|
||||
private void FromModelToDto()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,7 +20,6 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
{
|
||||
public class KeePassDatabaseClient: IDatabaseProxy
|
||||
{
|
||||
private readonly ISettingsProxy _settings;
|
||||
private readonly IFileProxy _fileService;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IDateTime _dateTime;
|
||||
@@ -77,9 +76,8 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
set { _pwDatabase.Compression = (PwCompressionAlgorithm) Enum.Parse(typeof(PwCompressionAlgorithm), value); }
|
||||
}
|
||||
|
||||
public KeePassDatabaseClient(ISettingsProxy settings, IFileProxy fileService, IMapper mapper, IDateTime dateTime)
|
||||
public KeePassDatabaseClient(IFileProxy fileService, IMapper mapper, IDateTime dateTime)
|
||||
{
|
||||
_settings = settings;
|
||||
_fileService = fileService;
|
||||
_mapper = mapper;
|
||||
_dateTime = dateTime;
|
||||
@@ -111,17 +109,16 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
return await Open(new FileInfo {Path = _fileAccessToken}, _credentials);
|
||||
}
|
||||
|
||||
public async Task<GroupEntity> Create(FileInfo fileInfo, Credentials credentials)
|
||||
public async Task<GroupEntity> Create(FileInfo fileInfo, Credentials credentials, DatabaseVersion version = DatabaseVersion.V2)
|
||||
{
|
||||
var compositeKey = await CreateCompositeKey(credentials);
|
||||
var ioConnection = await BuildConnectionInfo(fileInfo);
|
||||
|
||||
_pwDatabase.New(ioConnection, compositeKey);
|
||||
|
||||
var fileFormat = _settings.GetSetting<string>("DefaultFileFormat");
|
||||
switch (fileFormat)
|
||||
switch (version)
|
||||
{
|
||||
case "4":
|
||||
case DatabaseVersion.V4:
|
||||
_pwDatabase.KdfParameters = KdfPool.Get("Argon2").GetDefaultParameters();
|
||||
break;
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"supports": {},
|
||||
"dependencies": {
|
||||
"AutoMapper": "6.1.1",
|
||||
"AutoMapper": "6.0.2",
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "2.0.1",
|
||||
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
|
||||
"ModernKeePassLib": "2.44.1",
|
||||
"ModernKeePassLib": "2.44.2",
|
||||
"NETStandard.Library": "2.0.3"
|
||||
},
|
||||
"frameworks": {
|
||||
|
Reference in New Issue
Block a user