mirror of
https://github.com/bitwarden/mobile
synced 2025-12-10 13:23:39 +00:00
decrypt with org id
This commit is contained in:
@@ -31,13 +31,13 @@ namespace Bit.Android.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
var extension = MimeTypeMap.GetFileExtensionFromUrl(fileName);
|
||||
var extension = MimeTypeMap.GetFileExtensionFromUrl(fileName.Replace(' ', '_').ToLower());
|
||||
if(extension == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var mimeType = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension.ToLower());
|
||||
var mimeType = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);
|
||||
if(mimeType == null)
|
||||
{
|
||||
return false;
|
||||
@@ -69,13 +69,13 @@ namespace Bit.Android.Services
|
||||
|
||||
public bool CanOpenFile(string fileName)
|
||||
{
|
||||
var extension = MimeTypeMap.GetFileExtensionFromUrl(fileName);
|
||||
var extension = MimeTypeMap.GetFileExtensionFromUrl(fileName.Replace(' ', '_').ToLower());
|
||||
if(extension == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var mimeType = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension.ToLower());
|
||||
var mimeType = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);
|
||||
if(mimeType == null)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace Bit.App.Abstractions
|
||||
Task<Tuple<IEnumerable<Login>, IEnumerable<Login>>> GetAllAsync(string uriString);
|
||||
Task<ApiResult<LoginResponse>> SaveAsync(Login login);
|
||||
Task<ApiResult> DeleteAsync(string id);
|
||||
Task<byte[]> DownloadAndDecryptAttachmentAsync(SymmetricCryptoKey key, string url);
|
||||
Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, string orgId = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using XLabs.Ioc;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using Bit.App.Models;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -199,7 +200,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
var attachmentCell = new AttachmentViewCell(attachment, async () =>
|
||||
{
|
||||
await OpenAttachmentAsync(attachment);
|
||||
await OpenAttachmentAsync(login, attachment);
|
||||
});
|
||||
AttachmentCells.Add(attachmentCell);
|
||||
AttachmentsSection.Add(attachmentCell);
|
||||
@@ -229,7 +230,7 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenAttachmentAsync(VaultViewLoginPageModel.Attachment attachment)
|
||||
private async Task OpenAttachmentAsync(Login login, VaultViewLoginPageModel.Attachment attachment)
|
||||
{
|
||||
// 20 MB warning
|
||||
if(attachment.Size >= 20971520 && !(await _userDialogs.ConfirmAsync(
|
||||
@@ -246,7 +247,7 @@ namespace Bit.App.Pages
|
||||
}
|
||||
|
||||
_userDialogs.ShowLoading(AppResources.Downloading, MaskType.Black);
|
||||
var data = await _loginService.DownloadAndDecryptAttachmentAsync(null, attachment.Url);
|
||||
var data = await _loginService.DownloadAndDecryptAttachmentAsync(attachment.Url, login.OrganizationId);
|
||||
_userDialogs.HideLoading();
|
||||
if(data == null)
|
||||
{
|
||||
|
||||
2
src/App/Resources/AppResources.Designer.cs
generated
2
src/App/Resources/AppResources.Designer.cs
generated
@@ -2024,7 +2024,7 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Your device cannot open this type of tile..
|
||||
/// Looks up a localized string similar to Your device cannot open this type of file..
|
||||
/// </summary>
|
||||
public static string UnableToOpenFile {
|
||||
get {
|
||||
|
||||
@@ -912,7 +912,7 @@
|
||||
<value>Unable to download file.</value>
|
||||
</data>
|
||||
<data name="UnableToOpenFile" xml:space="preserve">
|
||||
<value>Your device cannot open this type of tile.</value>
|
||||
<value>Your device cannot open this type of file.</value>
|
||||
</data>
|
||||
<data name="Downloading" xml:space="preserve">
|
||||
<value>Downloading...</value>
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Bit.App.Services
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<byte[]> DownloadAndDecryptAttachmentAsync(SymmetricCryptoKey key, string url)
|
||||
public async Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, string orgId = null)
|
||||
{
|
||||
using(var client = new HttpClient())
|
||||
{
|
||||
@@ -239,7 +239,14 @@ namespace Bit.App.Services
|
||||
return null;
|
||||
}
|
||||
|
||||
return _cryptoService.DecryptToBytes(data, key);
|
||||
if(!string.IsNullOrWhiteSpace(orgId))
|
||||
{
|
||||
return _cryptoService.DecryptToBytes(data, _cryptoService.GetOrgKey(orgId));
|
||||
}
|
||||
else
|
||||
{
|
||||
return _cryptoService.DecryptToBytes(data, null);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user