Mass rename to align planned codename

This commit is contained in:
TheXamlGuy
2024-05-27 16:08:18 +01:00
parent 2c066097f6
commit 3631d666f5
98 changed files with 550 additions and 432 deletions
+33
View File
@@ -0,0 +1,33 @@
using System.Text;
using Toolkit.Foundation;
namespace Bitvault;
public class OpenLockerHandler(LockerConfiguration configuration,
ISecurityKeyFactory securityKeyFactory,
ILockerStorageFactory lockerStorageFactory) :
IHandler<ActivateEventArgs<Locker>, bool>
{
public async Task<bool> Handle(ActivateEventArgs<Locker> args,
CancellationToken cancellationToken)
{
if (args.Value is Locker locker && configuration.Name is { Length: > 0 } name && locker.Password is { Length: > 0 } password)
{
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
{
byte[]? salt = Convert.FromBase64String(keyPart[0]);
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
{
if (await lockerStorageFactory.Create(name, key))
{
return true;
}
}
}
}
return false;
}
}