public void Clear() { _logger.LogInformation("Clearing cache"); FileIOWithRetries.DeleteCacheFile(_cacheFilePath, _logger); _logger.LogInformation($"Before deleting secret from Linux keyring"); IntPtr error = IntPtr.Zero; Libsecret.secret_password_clear_sync( schema: GetLibsecretSchema(), cancellable: IntPtr.Zero, error: out error, attribute1Type: _attributeKey1, attribute1Value: _attributeValue1, attribute2Type: _attributeKey2, attribute2Value: _attributeValue2, end: IntPtr.Zero); if (error != IntPtr.Zero) { try { GError err = (GError)Marshal.PtrToStructure(error, typeof(GError)); _logger.LogError($"An error was encountered while clearing secret from keyring in the {nameof(MsalCacheStorage)} domain:'{err.Domain}' code:'{err.Code}' message:'{err.Message}'"); } catch (Exception e) { _logger.LogError($"An exception was encountered while processing libsecret error information during clearing secret in the {nameof(MsalCacheStorage)} ex:'{e}'"); } } _logger.LogInformation("After deleting secret from linux keyring"); }
public void Clear() { _logger.LogInformation("Clearing cache"); FileIOWithRetries.DeleteCacheFile(_cacheFilePath, _logger); _logger.LogInformation("Before delete mac keychain"); MacKeyChain.DeleteKey(_keyChainServiceName, _keyChainAccountName); _logger.LogInformation("After delete mac keychain"); }
public void Write(byte[] data) { _logger.LogInformation("Before write to mac keychain"); MacKeyChain.WriteKey(_keyChainServiceName, _keyChainAccountName, data); _logger.LogInformation("After write to mac keychain"); // Change the "last modified" attribute and trigger file changed events FileIOWithRetries.TouchFile(_cacheFilePath, _logger); }
public void Write(byte[] data) { _logger.LogInformation("Before write to mac keychain"); MacKeyChain.WriteKey(_keyChainServiceName, _keyChainAccountName, data); _logger.LogInformation("After write to mac keychain"); // Change data to 1 byte so we can write it to the cache file to update the last write time using the same write code used for windows. FileIOWithRetries.WriteDataToFile(_cacheFilePath, new byte[] { 1 }, _logger); }
public void Clear() { _logger.LogInformation("Clearing cache"); FileIOWithRetries.DeleteCacheFile(_cacheFilePath, _logger); _logger.LogInformation($"Before delete mac keychain service: {_service} account {_account}"); _keyChain.Remove(_service, _account); _logger.LogInformation($"After delete mac keychain service: {_service} account {_account}"); }
public void Write(byte[] data) { _logger.LogInformation($"Before write to mac keychain service: {_service} account {_account}"); _keyChain.AddOrUpdate(_service, _account, data); _logger.LogInformation($"After write to mac keychain service: {_service} account {_account}"); // Change the "last modified" attribute and trigger file changed events FileIOWithRetries.TouchFile(_cacheFilePath, _logger); }
public byte[] Read() { _logger.LogInformation("Reading from file"); byte[] fileData = null; bool cacheFileExists = File.Exists(_cacheFilePath); _logger.LogInformation($"Cache file exists? '{cacheFileExists}'"); if (cacheFileExists) { FileIOWithRetries.TryProcessFile(() => { fileData = File.ReadAllBytes(_cacheFilePath); _logger.LogInformation($"Read '{fileData.Length}' bytes from the file"); }, _logger); } return(fileData); }
public void Write(byte[] data) { _logger.LogInformation("Before saving to linux keyring"); IntPtr error = IntPtr.Zero; Libsecret.secret_password_store_sync( schema: GetLibsecretSchema(), collection: _keyringCollection, label: _keyringSecretLabel, password: Convert.ToBase64String(data), cancellable: IntPtr.Zero, error: out error, attribute1Type: _attributeKey1, attribute1Value: _attributeValue1, attribute2Type: _attributeKey2, attribute2Value: _attributeValue2, end: IntPtr.Zero); if (error != IntPtr.Zero) { try { GError err = (GError)Marshal.PtrToStructure(error, typeof(GError)); _logger.LogError($"An error was encountered while saving secret to keyring in the {nameof(MsalCacheStorage)} domain:'{err.Domain}' code:'{err.Code}' message:'{err.Message}'"); } catch (Exception e) { _logger.LogError($"An exception was encountered while processing libsecret error information during saving in the {nameof(MsalCacheStorage)} ex:'{e}'"); } } _logger.LogInformation("After saving to linux keyring"); // Change data to 1 byte so we can write it to the cache file to update the last write time using the same write code used for windows. FileIOWithRetries.WriteDataToFile(_cacheFilePath, new byte[] { 1 }, _logger); }
public void Write(byte[] data) { _logger.LogInformation("Before saving to linux keyring"); IntPtr error = IntPtr.Zero; Libsecret.secret_password_store_sync( schema: GetLibsecretSchema(), collection: _keyringCollection, label: _keyringSecretLabel, password: Convert.ToBase64String(data), cancellable: IntPtr.Zero, error: out error, attribute1Type: _attributeKey1, attribute1Value: _attributeValue1, attribute2Type: _attributeKey2, attribute2Value: _attributeValue2, end: IntPtr.Zero); if (error != IntPtr.Zero) { try { GError err = (GError)Marshal.PtrToStructure(error, typeof(GError)); _logger.LogError($"An error was encountered while saving secret to keyring in the {nameof(Storage)} domain:'{err.Domain}' code:'{err.Code}' message:'{err.Message}'"); } catch (Exception e) { _logger.LogError($"An exception was encountered while processing libsecret error information during saving in the {nameof(Storage)} ex:'{e}'"); } } _logger.LogInformation("After saving to linux keyring"); // Change the "last modified" attribute and trigger file changed events FileIOWithRetries.TouchFile(_cacheFilePath, _logger); }
public void Write(byte[] data) { FileIOWithRetries.CreateAndWriteToFile(_cacheFilePath, data, _setOwnerOnlyPermission, _logger); }
public void Clear() { _logger.LogInformation("Deleting cache file"); FileIOWithRetries.DeleteCacheFile(_cacheFilePath, _logger); }
public void Write(byte[] data) { FileIOWithRetries.WriteDataToFile(_cacheFilePath, data, _logger); }