1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-26 21:23:46 +00:00

key chain storage service

This commit is contained in:
Kyle Spearrin
2019-04-08 21:23:16 -04:00
parent 8055de4f25
commit 8c6823c463
4 changed files with 132 additions and 7 deletions

View File

@@ -8,8 +8,7 @@ namespace Bit.Core.Services
{
public class PreferencesStorageService : IStorageService
{
private string _keyFormat = "bwPreferencesStorage:{0}";
private readonly string _keyFormat = "bwPreferencesStorage:{0}";
private readonly string _sharedName;
private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
{

View File

@@ -7,7 +7,7 @@ namespace Bit.Core.Services
{
public class SecureStorageService : IStorageService
{
private string _keyFormat = "bwSecureStorage:{0}";
private readonly string _keyFormat = "bwSecureStorage:{0}";
private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
@@ -17,8 +17,7 @@ namespace Bit.Core.Services
{
var formattedKey = string.Format(_keyFormat, key);
var val = await Xamarin.Essentials.SecureStorage.GetAsync(formattedKey);
var objType = typeof(T);
if(objType == typeof(string))
if(typeof(T) == typeof(string))
{
return (T)(object)val;
}
@@ -36,8 +35,7 @@ namespace Bit.Core.Services
return;
}
var formattedKey = string.Format(_keyFormat, key);
var objType = typeof(T);
if(objType == typeof(string))
if(typeof(T) == typeof(string))
{
await Xamarin.Essentials.SecureStorage.SetAsync(formattedKey, obj as string);
}