api-defaultvalue: fix

This commit is contained in:
SuhorukovAnton 2020-06-30 16:56:38 +03:00
parent e1f7b7365a
commit 0ec331db76
34 changed files with 491 additions and 676 deletions

View File

@ -35,40 +35,28 @@ using ASC.Files.Core;
namespace ASC.Web.Files.Classes
{
[Serializable]
[DataContract]
public class FilesSettings : ISettings
{
[DataMember(Name = "EnableThirdpartySettings")]
public bool EnableThirdpartySetting { get; set; }
[DataMember(Name = "FastDelete")]
public bool FastDeleteSetting { get; set; }
[DataMember(Name = "StoreOriginalFiles")]
public bool StoreOriginalFilesSetting { get; set; }
[DataMember(Name = "UpdateIfExist")]
public bool UpdateIfExistSetting { get; set; }
[DataMember(Name = "ConvertNotify")]
public bool ConvertNotifySetting { get; set; }
[DataMember(Name = "SortedBy")]
public SortedByType DefaultSortedBySetting { get; set; }
[DataMember(Name = "SortedAsc")]
public bool DefaultSortedAscSetting { get; set; }
[DataMember(Name = "HideConfirmConvertSave")]
public bool HideConfirmConvertSaveSetting { get; set; }
[DataMember(Name = "HideConfirmConvertOpen")]
public bool HideConfirmConvertOpenSetting { get; set; }
[DataMember(Name = "Forcesave")]
public bool ForcesaveSetting { get; set; }
[DataMember(Name = "StoreForcesave")]
public bool StoreForcesaveSetting { get; set; }
public ISettings GetDefault(IServiceProvider serviceProvider)

View File

@ -429,7 +429,7 @@ namespace ASC.Files.Core.Data
ModifiedOn = TenantUtil.DateTimeToUtc(file.ModifiedOn),
ConvertedType = file.ConvertedType,
Comment = file.Comment,
Encrypted = file.Encrypted == null ? false : (bool)file.Encrypted,
Encrypted = file.Encrypted,
Forcesave = file.Forcesave,
TenantId = TenantID
};
@ -550,7 +550,7 @@ namespace ASC.Files.Core.Data
toUpdate.ModifiedOn = TenantUtil.DateTimeToUtc(file.ModifiedOn);
toUpdate.ConvertedType = file.ConvertedType;
toUpdate.Comment = file.Comment;
toUpdate.Encrypted = file.Encrypted == null ? false : (bool)file.Encrypted;
toUpdate.Encrypted = file.Encrypted;
toUpdate.Forcesave = file.Forcesave;
FilesDbContext.SaveChanges();
@ -1009,7 +1009,7 @@ namespace ASC.Files.Core.Data
file.ContentLength = uploadSession.BytesTotal;
file.ConvertedType = null;
file.Comment = FilesCommonResource.CommentUpload;
file.Encrypted = uploadSession.Encrypted ? (bool?)true : null;
file.Encrypted = uploadSession.Encrypted;
return file;
}
var result = ServiceProvider.GetService<File<int>>();
@ -1017,7 +1017,7 @@ namespace ASC.Files.Core.Data
result.Title = uploadSession.File.Title;
result.ContentLength = uploadSession.BytesTotal;
result.Comment = FilesCommonResource.CommentUpload;
result.Encrypted = uploadSession.Encrypted ? (bool?)true : null;
result.Encrypted = uploadSession.Encrypted;
return result;
}
@ -1382,7 +1382,7 @@ namespace ASC.Files.Core.Data
file.Shared = r.shared;
file.ConvertedType = r.file.ConvertedType;
file.Comment = r.file.Comment;
file.Encrypted = r.file.Encrypted ? (bool?)true : null;
file.Encrypted = r.file.Encrypted;
file.Forcesave = r.file.Forcesave;
return file;
}

View File

@ -43,7 +43,6 @@ using Newtonsoft.Json.Linq;
namespace ASC.Files.Core
{
[DataContract(Name = "editHistory", Namespace = "")]
[DebuggerDisplay("{ID} v{Version}")]
public class EditHistory
{
@ -62,15 +61,14 @@ namespace ASC.Files.Core
}
public int ID;
[DataMember(Name = "key")] public string Key;
[DataMember(Name = "version")] public int Version;
[DataMember(Name = "versionGroup")] public int VersionGroup;
public string Key;
public int Version;
public int VersionGroup;
[DataMember(Name = "user")] public EditHistoryAuthor ModifiedBy;
public EditHistoryAuthor ModifiedBy;
[DataMember(Name = "changeshistory")] public string ChangesString;
[DataMember(Name = "changes")]
public string ChangesString;
public List<EditHistoryChanges> Changes
{
get
@ -89,18 +87,18 @@ namespace ASC.Files.Core
changes = jChanges.Children()
.Select(jChange =>
{
var jUser = jChange.Value<JObject>("user");
return new EditHistoryChanges(TenantUtil)
{
Date = jChange.Value<string>("created"),
Author = new EditHistoryAuthor(AuthContext, UserManager, DisplayUserSettingsHelper)
var jUser = jChange.Value<JObject>("user");
return new EditHistoryChanges(TenantUtil)
{
Id = new Guid(jUser.Value<string>("id") ?? Guid.Empty.ToString()),
Name = jUser.Value<string>("name"),
},
};
})
Date = jChange.Value<string>("created"),
Author = new EditHistoryAuthor(AuthContext, UserManager, DisplayUserSettingsHelper)
{
Id = new Guid(jUser.Value<string>("id") ?? Guid.Empty.ToString()),
Name = jUser.Value<string>("name"),
},
};
})
.ToList();
return changes;
}
@ -141,7 +139,6 @@ namespace ASC.Files.Core
public DateTime ModifiedOn;
[DataMember(Name = "created")]
public string ModifiedOnString
{
get { return ModifiedOn.Equals(default) ? null : ModifiedOn.ToString("g"); }
@ -154,10 +151,9 @@ namespace ASC.Files.Core
public UserManager UserManager { get; }
public DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
[DataMember(Name = "serverVersion")] public string ServerVersion;
public string ServerVersion;
}
[DataContract(Name = "user", Namespace = "")]
[DebuggerDisplay("{Id} {Name}")]
public class EditHistoryAuthor
{
@ -171,11 +167,10 @@ namespace ASC.Files.Core
DisplayUserSettingsHelper = displayUserSettingsHelper;
}
[DataMember(Name = "id")] public Guid Id;
public Guid Id;
private string _name;
[DataMember(Name = "name")]
public string Name
{
get
@ -200,7 +195,6 @@ namespace ASC.Files.Core
public DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
}
[DataContract(Name = "change", Namespace = "")]
[DebuggerDisplay("{Author.Name}")]
public class EditHistoryChanges
{
@ -209,11 +203,10 @@ namespace ASC.Files.Core
TenantUtil = tenantUtil;
}
[DataMember(Name = "user")] public EditHistoryAuthor Author;
public EditHistoryAuthor Author;
private DateTime _date;
[DataMember(Name = "created")]
public string Date
{
get { return _date.Equals(default) ? null : _date.ToString("g"); }
@ -229,29 +222,27 @@ namespace ASC.Files.Core
public TenantUtil TenantUtil { get; }
}
[DataContract(Name = "data")]
[DebuggerDisplay("{Version}")]
public class EditHistoryData
{
[DataMember(Name = "changesUrl")] public string ChangesUrl;
public string ChangesUrl;
[DataMember(Name = "key")] public string Key;
public string Key;
[DataMember(Name = "previous")] public EditHistoryUrl Previous;
public EditHistoryUrl Previous;
[DataMember(Name = "token")] public string Token;
public string Token;
[DataMember(Name = "url")] public string Url;
public string Url;
[DataMember(Name = "version")] public int Version;
public int Version;
}
[DataContract(Name = "url")]
[DebuggerDisplay("{Key} - {Url}")]
public class EditHistoryUrl
{
[DataMember(Name = "key")] public string Key;
public string Key;
[DataMember(Name = "url")] public string Url;
public string Url;
}
}

View File

@ -28,16 +28,12 @@ using System.Runtime.Serialization;
namespace ASC.Web.Files.Core.Entries
{
[DataContract(Name = "encrypted_data", Namespace = "")]
public class EncryptedData
{
[DataMember(Name = "publicKey")]
public string PublicKey;
[DataMember(Name = "fileHash")]
public string FileHash;
[DataMember(Name = "data")]
public string Data;
}
}

View File

@ -38,24 +38,22 @@ using ASC.Web.Studio.Core;
namespace ASC.Files.Core
{
[Flags]
[DataContract(Namespace = "")]
public enum FileStatus
{
[EnumMember] None = 0x0,
None = 0x0,
[EnumMember] IsEditing = 0x1,
IsEditing = 0x1,
[EnumMember] IsNew = 0x2,
IsNew = 0x2,
[EnumMember] IsConverting = 0x4,
IsConverting = 0x4,
[EnumMember] IsOriginal = 0x8,
IsOriginal = 0x8,
[EnumMember] IsEditingAlone = 0x10
IsEditingAlone = 0x10
}
[Serializable]
[DataContract(Name = "file", Namespace = "")]
[DebuggerDisplay("{Title} ({ID} v{Version})")]
public class File<T> : FileEntry<T>
{
@ -77,13 +75,10 @@ namespace ASC.Files.Core
public T FolderID { get; set; }
[DataMember(Name = "version")]
public int Version { get; set; }
[DataMember(Name = "version_group")]
public int VersionGroup { get; set; }
[DataMember(EmitDefaultValue = false, Name = "comment")]
public string Comment { get; set; }
public string PureTitle
@ -104,10 +99,8 @@ namespace ASC.Files.Core
set { base.Title = value; }
}
[DataMember(EmitDefaultValue = true, Name = "content_length", IsRequired = true)]
public long ContentLength { get; set; }
[DataMember(EmitDefaultValue = false, Name = "content_length_string", IsRequired = true)]
public string ContentLengthString
{
get { return FileSizeComment.FilesSizeToString(ContentLength); }
@ -139,7 +132,6 @@ namespace ASC.Files.Core
}
}
[DataMember(EmitDefaultValue = false, Name = "file_status")]
public FileStatus FileStatus
{
get
@ -164,10 +156,8 @@ namespace ASC.Files.Core
set { _status = value; }
}
[DataMember(EmitDefaultValue = false, Name = "locked")]
public bool? Locked { get; set; }
public bool Locked { get; set; }
[DataMember(EmitDefaultValue = false, Name = "locked_by")]
public string LockedBy { get; set; }
public override bool IsNew
@ -182,8 +172,7 @@ namespace ASC.Files.Core
}
}
[DataMember(EmitDefaultValue = false, Name = "encrypted")]
public bool? Encrypted { get; set; }
public bool Encrypted { get; set; }
public ForcesaveType Forcesave { get; set; }
@ -227,7 +216,6 @@ namespace ASC.Files.Core
private T _folderIdDisplay;
[DataMember(Name = "folder_id")]
public override T FolderIdDisplay
{
get

View File

@ -32,7 +32,6 @@ using ASC.Web.Files.Classes;
namespace ASC.Files.Core
{
[DataContract(Name = "entry", Namespace = "")]
[Serializable]
public abstract class FileEntry : ICloneable
{
@ -41,56 +40,44 @@ namespace ASC.Files.Core
Global = global;
}
[DataMember(Name = "title", IsRequired = true)]
public virtual string Title { get; set; }
[DataMember(Name = "create_by_id")]
public Guid CreateBy { get; set; }
[DataMember(Name = "create_by")]
public string CreateByString
{
get { return !CreateBy.Equals(Guid.Empty) ? Global.GetUserName(CreateBy) : _createByString; }
set { _createByString = value; }
}
[DataMember(Name = "create_on")]
public string CreateOnString
{
get { return CreateOn.Equals(default) ? null : CreateOn.ToString("g"); }
set { throw new NotImplementedException(); }
}
[DataMember(Name = "modified_on")]
public string ModifiedOnString
{
get { return ModifiedOn.Equals(default) ? null : ModifiedOn.ToString("g"); }
set { throw new NotImplementedException(); }
}
[DataMember(Name = "modified_by_id")]
public Guid ModifiedBy { get; set; }
[DataMember(Name = "modified_by")]
public string ModifiedByString
{
get { return !ModifiedBy.Equals(Guid.Empty) ? Global.GetUserName(ModifiedBy) : _modifiedByString; }
set { _modifiedByString = value; }
}
[DataMember(Name = "error", EmitDefaultValue = false)]
public string Error { get; set; }
[DataMember(Name = "access")]
public FileShare Access { get; set; }
[DataMember(Name = "shared")]
public bool Shared { get; set; }
[DataMember(Name = "provider_id", EmitDefaultValue = false)]
public int? ProviderId { get; set; }
public int ProviderId { get; set; }
[DataMember(Name = "provider_key", EmitDefaultValue = false)]
public string ProviderKey { get; set; }
public bool ProviderEntry
{
@ -127,7 +114,6 @@ namespace ASC.Files.Core
}
}
[DataContract(Name = "entry", Namespace = "")]
[Serializable]
public abstract class FileEntry<T> : FileEntry, ICloneable
{
@ -135,11 +121,8 @@ namespace ASC.Files.Core
{
}
[DataMember(Name = "id")]
public T ID { get; set; }
[DataMember(Name = "folder_id")]
public abstract T FolderIdDisplay
{
get;

View File

@ -29,33 +29,22 @@ using System.Diagnostics;
namespace ASC.Files.Core
{
[DataContract(Name = "sorted_by_type", Namespace = "")]
public enum SortedByType
{
[EnumMember] DateAndTime,
[EnumMember] AZ,
[EnumMember] Size,
[EnumMember] Author,
[EnumMember] Type,
[EnumMember] New,
[EnumMember] DateAndTimeCreation
DateAndTime,
AZ,
Size,
Author,
Type,
New,
DateAndTimeCreation
}
[DataContract(Name = "orderBy", IsReference = true, Namespace = "")]
[DebuggerDisplay("{SortedBy} {IsAsc}")]
public class OrderBy
{
[DataMember(Name = "is_asc")]
public bool IsAsc { get; set; }
[DataMember(Name = "property")]
public SortedByType SortedBy { get; set; }
public OrderBy(SortedByType sortedByType, bool isAsc)

View File

@ -1195,7 +1195,7 @@ namespace ASC.Web.Files.Services.WCFService
FileMarker.RemoveMarkAsNewForAll(folder);
}
providerDao.RemoveProviderInfo(folder.ProviderId == null ? 0 : (int) folder.ProviderId);
providerDao.RemoveProviderInfo(folder.ProviderId);
FilesMessageService.Send(folder, GetHttpHeaders(), MessageAction.ThirdPartyDeleted, folder.ID.ToString(), providerInfo.ProviderKey);
return folder.ID;
@ -1736,7 +1736,7 @@ namespace ASC.Web.Files.Services.WCFService
var changed = false;
bool? canShare = null;
if (file.Encrypted == null ? false : (bool)file.Encrypted) canShare = false;
if (file.Encrypted) canShare = false;
var recipients = new List<Guid>();
foreach (var email in mentionMessage.Emails)

View File

@ -150,7 +150,7 @@ namespace ASC.Files.Thirdparty
{
fileEntry.CreateBy = ProviderInfo.Owner;
fileEntry.ModifiedBy = ProviderInfo.Owner;
fileEntry.ProviderId = ProviderInfo.ID == 0 ? null :(int?)ProviderInfo.ID;
fileEntry.ProviderId = ProviderInfo.ID;
fileEntry.ProviderKey = ProviderInfo.ProviderKey;
fileEntry.RootFolderCreator = ProviderInfo.Owner;
fileEntry.RootFolderType = ProviderInfo.RootFolderType;

View File

@ -289,7 +289,7 @@ namespace ASC.Files.Thirdparty.SharePoint
result.CreateOn = DateTime.UtcNow;
result.ModifiedBy = Owner;
result.ModifiedOn = DateTime.UtcNow;
result.ProviderId = ID == 0 ? null : (int?)ID;
result.ProviderId = ID;
result.ProviderKey = ProviderKey;
result.RootFolderCreator = Owner;
result.RootFolderId = MakeId(RootFolder.ServerRelativeUrl);
@ -310,7 +310,7 @@ namespace ASC.Files.Thirdparty.SharePoint
result.ModifiedBy = Owner;
result.ModifiedOn = file.TimeLastModified.Kind == DateTimeKind.Utc ? TenantUtil.DateTimeFromUtc(file.TimeLastModified) : file.TimeLastModified;
result.NativeAccessor = file;
result.ProviderId = ID == 0 ? null : (int?)ID;
result.ProviderId = ID;
result.ProviderKey = ProviderKey;
result.Title = MakeTitle(file.Name);
result.RootFolderId = MakeId(SpRootFolderId);
@ -506,7 +506,7 @@ namespace ASC.Files.Thirdparty.SharePoint
result.FolderType = FolderType.DEFAULT;
result.ModifiedBy = Owner;
result.ModifiedOn = DateTime.UtcNow;
result.ProviderId = ID == 0 ? null : (int?)ID;
result.ProviderId = ID;
result.ProviderKey = ProviderKey;
result.RootFolderCreator = Owner;
result.RootFolderId = MakeId(SpRootFolderId);
@ -529,7 +529,7 @@ namespace ASC.Files.Thirdparty.SharePoint
result.FolderType = FolderType.DEFAULT;
result.ModifiedBy = Owner;
result.ModifiedOn = CreateOn;
result.ProviderId = ID == 0 ? null : (int?)ID;
result.ProviderId = ID;
result.ProviderKey = ProviderKey;
result.RootFolderCreator = Owner;
result.RootFolderId = MakeId(RootFolder.ServerRelativeUrl);

View File

@ -323,22 +323,22 @@ namespace ASC.Web.Files.Helpers
var signers = new List<Signer>();
docuSignData.Users.ForEach(uid =>
{
try
{
var user = UserManager.GetUsers(uid);
signers.Add(new Signer
try
{
Email = user.Email,
Name = user.DisplayUserName(false, DisplayUserSettingsHelper),
RecipientId = user.ID.ToString(),
});
}
catch (Exception ex)
{
Log.Error("Signer is undefined", ex);
}
});
var user = UserManager.GetUsers(uid);
signers.Add(new Signer
{
Email = user.Email,
Name = user.DisplayUserName(false, DisplayUserSettingsHelper),
RecipientId = user.ID.ToString(),
});
}
catch (Exception ex)
{
Log.Error("Signer is undefined", ex);
}
});
var envelopeDefinition = new EnvelopeDefinition
{
@ -428,39 +428,30 @@ namespace ASC.Web.Files.Helpers
}
[DataContract]
[DebuggerDisplay("{AccountId} {BaseUri}")]
private class DocuSignAccount
{
[DataMember(Name = "account_id")]
public string AccountId { get; set; }
[DataMember(Name = "base_uri")]
public string BaseUri { get; set; }
}
[DataContract]
private class DocuSignUserInfo
{
[DataMember(Name = "accounts")]
public List<DocuSignAccount> Accounts { get; set; }
}
}
[DataContract(Name = "docusign_data", Namespace = "")]
[DebuggerDisplay("{Name}")]
public class DocuSignData
{
[DataMember(Name = "folderId")]
public string FolderId { get; set; }
[DataMember(Name = "message")]
public string Message { get; set; }
[DataMember(Name = "name", IsRequired = true)]
public string Name { get; set; }
[DataMember(Name = "users")]
public ItemList<Guid> Users { get; set; }
}

View File

@ -118,9 +118,9 @@ namespace ASC.Api.Documents
Updated = apiDateTimeHelper.Get(entry.ModifiedOn);
UpdatedBy = employeeWraperHelper.Get(entry.ModifiedBy);
RootFolderType = entry.RootFolderType;
ProviderItem = entry.ProviderEntry == false ? null : (bool?)true;
ProviderItem = entry.ProviderEntry ? (bool?)true : null;
ProviderKey = entry.ProviderKey;
ProviderId = entry.ProviderId;
ProviderId = entry.ProviderId == 0 ? null : (int?) entry.ProviderId;
}
/// <summary>
@ -189,10 +189,10 @@ namespace ASC.Api.Documents
Updated = ApiDateTimeHelper.Get(entry.ModifiedOn),
UpdatedBy = EmployeeWraperHelper.Get(entry.ModifiedBy),
RootFolderType = entry.RootFolderType,
ProviderItem = entry.ProviderEntry == false ? null : (bool?)true,
ProviderItem = entry.ProviderEntry ? (bool?)true : null,
ProviderKey = entry.ProviderKey,
ProviderId = entry.ProviderId
};
ProviderId = entry.ProviderId == 0 ? null : (int?)entry.ProviderId
};
}
}

View File

@ -36,17 +36,14 @@ namespace ASC.Api.Documents
{
/// <summary>
/// </summary>
[DataContract(Name = "share", Namespace = "")]
public class FileShareParams
{
/// <summary>
/// </summary>
[DataMember(Name = "shareTo", Order = 0)]
public Guid ShareTo { get; set; }
/// <summary>
/// </summary>
[DataMember(Name = "access", Order = 1)]
public FileShare Access { get; set; }
/// <summary>

View File

@ -56,7 +56,7 @@ namespace ASC.Api.Documents
/// <summary>
/// </summary>
[DataMember(EmitDefaultValue = true, IsRequired = false)]
public int? Version { get; set; }
public int Version { get; set; }
/// <summary>
/// </summary>
@ -194,13 +194,13 @@ namespace ASC.Api.Documents
result.FileExst = FileUtility.GetFileExtension(file.Title);
result.FileType = FileUtility.GetFileTypeByExtention(result.FileExst);
result.Version = file.Version == 0 ? null : (int?)file.Version;
result.Version = file.Version;
result.VersionGroup = file.VersionGroup;
result.ContentLength = file.ContentLengthString;
result.FileStatus = file.FileStatus;
result.PureContentLength = file.ContentLength == 0 ? null : (long?)file.ContentLength;
result.Comment = file.Comment;
result.Encrypted = file.Encrypted;
result.Encrypted = file.Encrypted ? (bool?)true : null;
try
{
result.ViewUrl = CommonLinkUtility.GetFullAbsolutePath(file.DownloadUrl);

View File

@ -685,10 +685,10 @@ namespace ASC.Web.Files.Services.DocumentService
set { }
get
{
return FileUtility.CanForcesave
return (FileUtility.CanForcesave
&& !_configuration.Document.Info.File.ProviderEntry
&& ThirdPartySelector.GetAppByFileId(_configuration.Document.Info.File.ID.ToString()) == null
&& FilesSettingsHelper.Forcesave;
&& FilesSettingsHelper.Forcesave) ? (bool?)true : null;
}
}

View File

@ -1,94 +1,78 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
namespace ASC.Web.Files.Services.DocumentService
{
[DataContract(Name = "docServiceParams", Namespace = "")]
public class DocumentServiceParams
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
namespace ASC.Web.Files.Services.DocumentService
{
public class DocumentServiceParams
{
[DataMember(Name = "displayName")]
public string DisplayName;
[DataMember(Name = "docKeyForTrack")]
public string DocKeyForTrack;
[DataMember(Name = "editByUrl")]
public string DisplayName;
public string DocKeyForTrack;
public bool EditByUrl;
[DataMember(Name = "email")]
public string Email;
[DataMember(Name = "fileId", EmitDefaultValue = false)]
public string FileId;
[DataMember(Name = "fileProviderKey", EmitDefaultValue = false)]
public string FileProviderKey;
[DataMember(Name = "fileVersion", EmitDefaultValue = false)]
public int? FileVersion;
[DataMember(Name = "linkToEdit")]
public string LinkToEdit;
[DataMember(Name = "openHistory", EmitDefaultValue = false)]
public bool? OpenHistory;
[DataMember(Name = "openinigDate")]
public string OpeninigDate;
[DataMember(Name = "serverErrorMessage")]
public string ServerErrorMessage;
[DataMember(Name = "shareLinkParam")]
public string ShareLinkParam;
[DataMember(Name = "tabId")]
public string TabId;
[DataMember(Name = "thirdPartyApp")]
public bool ThirdPartyApp;
[DataMember(Name = "canGetUsers")]
public bool CanGetUsers;
public static string Serialize(DocumentServiceParams docServiceParams)
{
using (var ms = new MemoryStream())
{
var serializer = new DataContractJsonSerializer(typeof (DocumentServiceParams));
serializer.WriteObject(ms, docServiceParams);
ms.Seek(0, SeekOrigin.Begin);
return Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Length);
}
}
}
public string Email;
public string FileId;
public string FileProviderKey;
public int FileVersion;
public string LinkToEdit;
public bool OpenHistory;
public string OpeninigDate;
public string ServerErrorMessage;
public string ShareLinkParam;
public string TabId;
public bool ThirdPartyApp;
public bool CanGetUsers;
public static string Serialize(DocumentServiceParams docServiceParams)
{
using (var ms = new MemoryStream())
{
var serializer = new DataContractJsonSerializer(typeof (DocumentServiceParams));
serializer.WriteObject(ms, docServiceParams);
ms.Seek(0, SeekOrigin.Begin);
return Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Length);
}
}
}
}

View File

@ -136,10 +136,8 @@ namespace ASC.Web.Files.Services.DocumentService
}
[Serializable]
[DataContract(Name = "response", Namespace = "")]
public class TrackResponse
{
[DataMember(Name = "error")]
public int Error
{
set { }
@ -151,10 +149,8 @@ namespace ASC.Web.Files.Services.DocumentService
}
}
[DataMember(Name = "message", EmitDefaultValue = false)]
public string Message = null;
[DataMember(Name = "addresses", EmitDefaultValue = false)]
public string[] Addresses = null;
public static string Serialize(TrackResponse response)
@ -472,7 +468,7 @@ namespace ASC.Web.Files.Services.DocumentService
SocketManager.FilesChangeEditors(fileId, !forcesave);
var result = new TrackResponse { Message = saveMessage };
if (string.IsNullOrEmpty(saveMessage) && file != null && (file.Encrypted != null && (bool)file.Encrypted))
if (string.IsNullOrEmpty(saveMessage) && file != null && file.Encrypted)
{
result.Addresses = EncryptionAddressHelper.GetAddresses(file.ID.ToString()).ToArray();
}

View File

@ -74,31 +74,22 @@ namespace ASC.Web.Files.Services.WCFService
}
[DataContract(Name = "error", Namespace = "")]
class FileError
{
[DataMember(Name = "Detail")]
public string Detail { get; set; }
[DataMember(Name = "message")]
public string Message { get; set; }
[DataMember(Name = "inner")]
public FileErrorInner Inner { get; set; }
[DataContract(Name = "error", Namespace = "")]
internal class FileErrorInner
{
[DataMember(Name = "message")]
public string Message { get; set; }
[DataMember(Name = "type")]
public string Type { get; set; }
[DataMember(Name = "source")]
public string Source { get; set; }
[DataMember(Name = "stack")]
public string Stack { get; set; }
}

View File

@ -155,7 +155,7 @@ namespace ASC.Web.Files.Services.WCFService.FileOperations
{
if (ProviderDao != null)
{
ProviderDao.RemoveProviderInfo(folder.ProviderId == null ? 0 : (int) folder.ProviderId);
ProviderDao.RemoveProviderInfo(folder.ProviderId);
filesMessageService.Send(folder, _headers, MessageAction.ThirdPartyDeleted, folder.ID.ToString(), folder.ProviderKey);
}

View File

@ -28,31 +28,22 @@ using System.Runtime.Serialization;
namespace ASC.Web.Files.Services.WCFService.FileOperations
{
[DataContract(Name = "operation_result", Namespace = "")]
public class FileOperationResult
{
[DataMember(Name = "id")]
public string Id { get; set; }
[DataMember(Name = "operation")]
public FileOperationType OperationType { get; set; }
[DataMember(Name = "progress")]
public int Progress { get; set; }
[DataMember(Name = "source")]
public string Source { get; set; }
[DataMember(Name = "result")]
public string Result { get; set; }
[DataMember(Name = "error")]
public string Error { get; set; }
[DataMember(Name = "processed")]
public string Processed { get; set; }
[DataMember(Name = "finished")]
public bool Finished { get; set; }
}
}

View File

@ -30,19 +30,14 @@ using ASC.Files.Core;
namespace ASC.Web.Files.Services.WCFService
{
[DataContract(Name = "composite_data", Namespace = "")]
public class DataWrapper<T>
{
[DataMember(IsRequired = false, Name = "entries", EmitDefaultValue = false)]
public ItemList<FileEntry> Entries { get; set; }
[DataMember(IsRequired = false, Name = "total")]
public int Total { get; set; }
[DataMember(IsRequired = false, Name = "path_parts")]
public ItemList<T> FolderPathParts { get; set; }
[DataMember(IsRequired = false, Name = "folder_info")]
public Folder<T> FolderInfo { get; set; }
public int New { get; set; }

View File

@ -33,27 +33,22 @@ using ASC.Web.Files.Services.DocumentService;
namespace ASC.Web.Files.Services.WCFService
{
[DataContract(Name = "mention", Namespace = "")]
public class MentionWrapper
{
[DataMember(Name = "email")]
public string Email
{
get { return User.Email; }
set { }
}
[DataMember(Name = "id")]
public string Id
{
get { return User.ID.ToString(); }
set { }
}
[DataMember(Name = "hasAccess")]
public bool HasAccess { get; set; }
[DataMember(Name = "name")]
public string Name
{
get { return User.DisplayUserName(false, DisplayUserSettingsHelper); }
@ -71,17 +66,12 @@ namespace ASC.Web.Files.Services.WCFService
}
}
[DataContract(Name = "message", Namespace = "")]
public class MentionMessageWrapper
{
[DataMember(Name = "actionLink")]
public ActionLinkConfig ActionLink { get; set; }
[DataMember(Name = "emails")]
public List<string> Emails { get; set; }
[DataMember(Name = "message")]
public string Message { get; set; }
}
}

View File

@ -32,6 +32,7 @@ using System.Net;
using System.Security;
using System.Text;
using System.Threading;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
@ -596,7 +597,7 @@ namespace ASC.Web.Files.Utils
folder.FolderType = FolderType.DEFAULT;
folder.ModifiedBy = providerInfo.Owner;
folder.ModifiedOn = providerInfo.CreateOn;
folder.ProviderId = providerInfo.ID == 0 ? null : (int?)providerInfo.ID;
folder.ProviderId = providerInfo.ID;
folder.ProviderKey = providerInfo.ProviderKey;
folder.RootFolderCreator = providerInfo.Owner;
folder.RootFolderId = providerInfo.RootFolderId;
@ -645,7 +646,7 @@ namespace ASC.Web.Files.Utils
var tagLocked = tagsLocked.FirstOrDefault(t => t.EntryId.Equals(file.ID));
var lockedBy = tagLocked != null ? tagLocked.Owner : Guid.Empty;
file.Locked = (lockedBy != Guid.Empty) == false? null : (bool?)(lockedBy != Guid.Empty);
file.Locked = lockedBy != Guid.Empty;
file.LockedBy = lockedBy != Guid.Empty && lockedBy != AuthContext.CurrentAccount.ID
? Global.GetUserName(lockedBy)
: null;

View File

@ -513,7 +513,7 @@ namespace ASC.Web.Files.Utils
return false;
}
if (file.Encrypted == null ? false : (bool)file.Encrypted)
if (file.Encrypted)
{
return false;
}

View File

@ -344,10 +344,10 @@ namespace ASC.Web.Files.Utils
};
result.Add(w);
}
if (entry.FileEntryType == FileEntryType.File && result.All(w => w.SubjectId != FileConstant.ShareLinkId)
&& entry.FileEntryType == FileEntryType.File
&& !((File<T>)entry).Encrypted == null ? false : (bool)((File<T>)entry).Encrypted)
&& !((File<T>)entry).Encrypted)
{
var w = new AceWrapper
{

View File

@ -33,7 +33,6 @@ using ASC.Common.Caching;
namespace ASC.Web.Files.Utils
{
[DataContract]
public class FileTracker
{
private const string TRACKER = "filesTracker";
@ -43,7 +42,7 @@ namespace ASC.Web.Files.Utils
public static readonly TimeSpan CacheTimeout = TimeSpan.FromSeconds(60);
public static readonly TimeSpan CheckRightTimeout = TimeSpan.FromMinutes(1);
[DataMember] private readonly Dictionary<Guid, TrackInfo> _editingBy;
private readonly Dictionary<Guid, TrackInfo> _editingBy;
private FileTracker()
@ -223,18 +222,18 @@ namespace ASC.Web.Files.Utils
}
[DataContract]
internal class TrackInfo
{
[DataMember] public DateTime CheckRightTime;
public DateTime CheckRightTime;
[DataMember] public DateTime TrackTime;
public DateTime TrackTime;
[DataMember] public Guid UserId;
public Guid UserId;
[DataMember] public bool NewScheme;
public bool NewScheme;
[DataMember] public bool EditingAlone;
public bool EditingAlone;
public TrackInfo()
{

View File

@ -153,7 +153,7 @@ namespace ASC.Web.Files.Utils
file.Comment = FilesCommonResource.CommentUpload;
file.Version++;
file.VersionGroup++;
file.Encrypted = null;
file.Encrypted = false;
return file;
}
@ -187,7 +187,7 @@ namespace ASC.Web.Files.Utils
&& !EntryManager.FileLockedForMe(file.ID)
&& !FileTracker.IsEditing(file.ID)
&& file.RootFolderType != FolderType.TRASH
&& !file.Encrypted == null ? false : (bool) file.Encrypted;
&& !file.Encrypted;
}
private T GetFolderId<T>(T folderId, IList<string> relativePath)

View File

@ -437,100 +437,74 @@ namespace ASC.Web.Core.Files
{
public CommandMethod Command { get; set; }
[DataMember(Name = "c", IsRequired = true)]
public string C
{
get { return Command.ToString().ToLower(CultureInfo.InvariantCulture); }
}
[DataMember(Name = "callback", IsRequired = false, EmitDefaultValue = false)]
public string Callback { get; set; }
[DataMember(Name = "key", IsRequired = true)]
public string Key { get; set; }
[DataMember(Name = "meta", IsRequired = false, EmitDefaultValue = false)]
public MetaData Meta { get; set; }
[DataMember(Name = "users", IsRequired = false, EmitDefaultValue = false)]
public string[] Users { get; set; }
[DataMember(Name = "token", EmitDefaultValue = false)]
public string Token { get; set; }
//not used
[DataMember(Name = "userdata", IsRequired = false, EmitDefaultValue = false)]
public string UserData { get; set; }
}
[Serializable]
[DataContract(Name = "meta", Namespace = "")]
[DebuggerDisplay("{Title}")]
public class MetaData
{
[DataMember(Name = "title")]
public string Title;
}
[Serializable]
[DataContract(Name = "Converion", Namespace = "")]
[DebuggerDisplay("{Title} from {FileType} to {OutputType} ({Key})")]
private class ConvertionBody
{
[DataMember(Name = "async")]
public bool Async { get; set; }
[DataMember(Name = "filetype", IsRequired = true)]
public string FileType { get; set; }
[DataMember(Name = "key", IsRequired = true)]
public string Key { get; set; }
[DataMember(Name = "outputtype", IsRequired = true)]
public string OutputType { get; set; }
[DataMember(Name = "password", EmitDefaultValue = false)]
public string Password { get; set; }
[DataMember(Name = "title")]
public string Title { get; set; }
[DataMember(Name = "url", IsRequired = true)]
public string Url { get; set; }
[DataMember(Name = "token", EmitDefaultValue = false)]
public string Token { get; set; }
}
[Serializable]
[DataContract(Name = "Builder", Namespace = "")]
[DebuggerDisplay("{Key}")]
private class BuilderBody
{
[DataMember(Name = "async")]
public bool Async { get; set; }
[DataMember(Name = "key", IsRequired = true)]
public string Key { get; set; }
[DataMember(Name = "url", IsRequired = true)]
public string Url { get; set; }
[DataMember(Name = "token", EmitDefaultValue = false)]
public string Token { get; set; }
}
[Serializable]
[DataContract(Name = "file", Namespace = "")]
public class FileLink
{
[DataMember(Name = "fileType")]
public string FileType;
[DataMember(Name = "token", EmitDefaultValue = false)]
public string Token;
[DataMember(Name = "url")]
public string Url;
}

View File

@ -1,26 +1,26 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
@ -32,13 +32,10 @@ using ASC.Core.Common.Settings;
namespace ASC.Web.Studio.Core.Notify
{
[Serializable]
[DataContract]
public class SpamEmailSettings : ISettings
{
[DataMember(Name = "MailsSendedCount")]
public int MailsSendedCount { get; set; }
[DataMember(Name = "MailsSendedDate")]
public DateTime MailsSendedDate { get; set; }
public Guid ID

View File

@ -36,7 +36,6 @@ using ASC.Web.Studio.Utility;
namespace ASC.Web.Studio.Core.SMS
{
[Serializable]
[DataContract]
public class StudioSmsNotificationSettings : ISettings
{
public Guid ID
@ -49,7 +48,6 @@ namespace ASC.Web.Studio.Core.SMS
return new StudioSmsNotificationSettings { EnableSetting = false, };
}
[DataMember(Name = "Enable")]
public bool EnableSetting { get; set; }
}

View File

@ -1,37 +1,36 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using System.Runtime.Serialization;
using ASC.Core.Common.Settings;
namespace ASC.Web.Studio.Core.TFA
{
[Serializable]
[DataContract]
public class TfaAppAuthSettings : ISettings
{
public Guid ID
@ -44,7 +43,6 @@ namespace ASC.Web.Studio.Core.TFA
return new TfaAppAuthSettings { EnableSetting = false, };
}
[DataMember(Name = "Enable")]
public bool EnableSetting { get; set; }

View File

@ -1,26 +1,26 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
@ -30,21 +30,18 @@ using System.Linq;
using System.Runtime.Serialization;
using ASC.Core.Common.Settings;
namespace ASC.Web.Studio.Core.TFA
{
[Serializable]
[DataContract]
public class TfaAppUserSettings : ISettings
{
[DataMember(Name = "BackupCodes")]
namespace ASC.Web.Studio.Core.TFA
{
[Serializable]
public class TfaAppUserSettings : ISettings
{
public IEnumerable<BackupCode> CodesSetting { get; set; }
[DataMember(Name = "Salt")]
public long SaltSetting { get; set; }
public Guid ID
{
get { return new Guid("{EAF10611-BE1E-4634-B7A1-57F913042F78}"); }
public long SaltSetting { get; set; }
public Guid ID
{
get { return new Guid("{EAF10611-BE1E-4634-B7A1-57F913042F78}"); }
}
public ISettings GetDefault(IServiceProvider serviceProvider)
@ -70,35 +67,35 @@ namespace ASC.Web.Studio.Core.TFA
return salt;
}
public static IEnumerable<BackupCode> BackupCodesForUser(SettingsManager settingsManager, Guid userId)
{
return settingsManager.LoadForUser<TfaAppUserSettings>(userId).CodesSetting;
}
public static void DisableCodeForUser(SettingsManager settingsManager, Guid userId, string code)
{
var settings = settingsManager.LoadForUser<TfaAppUserSettings>(userId);
var query = settings.CodesSetting.Where(x => x.Code == code).ToList();
if (query.Any())
query.First().IsUsed = true;
settingsManager.SaveForUser(settings, userId);
}
public static bool EnableForUser(SettingsManager settingsManager, Guid guid)
{
return settingsManager.LoadForUser<TfaAppUserSettings>(guid).CodesSetting.Any();
}
public static void DisableForUser(IServiceProvider serviceProvider, SettingsManager settingsManager, Guid guid)
{
if (new TfaAppUserSettings().GetDefault(serviceProvider) is TfaAppUserSettings defaultSettings)
{
settingsManager.SaveForUser(defaultSettings, guid);
}
}
}
public static IEnumerable<BackupCode> BackupCodesForUser(SettingsManager settingsManager, Guid userId)
{
return settingsManager.LoadForUser<TfaAppUserSettings>(userId).CodesSetting;
}
public static void DisableCodeForUser(SettingsManager settingsManager, Guid userId, string code)
{
var settings = settingsManager.LoadForUser<TfaAppUserSettings>(userId);
var query = settings.CodesSetting.Where(x => x.Code == code).ToList();
if (query.Any())
query.First().IsUsed = true;
settingsManager.SaveForUser(settings, userId);
}
public static bool EnableForUser(SettingsManager settingsManager, Guid guid)
{
return settingsManager.LoadForUser<TfaAppUserSettings>(guid).CodesSetting.Any();
}
public static void DisableForUser(IServiceProvider serviceProvider, SettingsManager settingsManager, Guid guid)
{
if (new TfaAppUserSettings().GetDefault(serviceProvider) is TfaAppUserSettings defaultSettings)
{
settingsManager.SaveForUser(defaultSettings, guid);
}
}
}
}

View File

@ -1,208 +1,205 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Core.Common.Security;
using ASC.Core.Common.Settings;
using ASC.Core.Users;
using ASC.Web.Core;
using ASC.Web.Core.PublicResources;
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using Google.Authenticator;
namespace ASC.Web.Studio.Core.TFA
{
[Serializable]
[DataContract]
public class BackupCode
{
[DataMember(Name = "Code")]
private string code;
public Signature Signature { get; }
public string Code
{
get { return Signature.Read<string>(code); }
set { code = Signature.Create(value); }
}
[DataMember(Name = "IsUsed")]
public bool IsUsed { get; set; }
public BackupCode(Signature signature, string code)
{
Signature = signature;
Code = code;
IsUsed = false;
}
}
public class TfaManager
{
private static readonly TwoFactorAuthenticator Tfa = new TwoFactorAuthenticator();
private static readonly ICache Cache = AscCache.Memory;
public SettingsManager SettingsManager { get; }
public SecurityContext SecurityContext { get; }
public CookiesManager CookiesManager { get; }
public SetupInfo SetupInfo { get; }
public Signature Signature { get; }
public TfaManager(
SettingsManager settingsManager,
SecurityContext securityContext,
CookiesManager cookiesManager,
SetupInfo setupInfo,
Signature signature)
{
SettingsManager = settingsManager;
SecurityContext = securityContext;
CookiesManager = cookiesManager;
SetupInfo = setupInfo;
Signature = signature;
}
public SetupCode GenerateSetupCode(UserInfo user, int size)
{
return Tfa.GenerateSetupCode(SetupInfo.TfaAppSender, user.Email, Encoding.UTF8.GetBytes(GenerateAccessToken(user)), size, true);
}
public bool ValidateAuthCode(UserInfo user, int tenantId, string code, bool checkBackup = true)
{
if (!TfaAppAuthSettings.IsVisibleSettings
|| !SettingsManager.Load<TfaAppAuthSettings>().EnableSetting)
{
return false;
}
if (user == null || Equals(user, Constants.LostUser)) throw new Exception(Resource.ErrorUserNotFound);
code = (code ?? "").Trim();
if (string.IsNullOrEmpty(code)) throw new Exception(Resource.ActivateTfaAppEmptyCode);
int.TryParse(Cache.Get<string>("tfa/" + user.ID), out var counter);
if (++counter > SetupInfo.LoginThreshold)
{
throw new BruteForceCredentialException(Resource.TfaTooMuchError);
}
Cache.Insert("tfa/" + user.ID, counter.ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
if (!Tfa.ValidateTwoFactorPIN(GenerateAccessToken(user), code))
{
if (checkBackup && TfaAppUserSettings.BackupCodesForUser(SettingsManager, user.ID).Any(x => x.Code == code && !x.IsUsed))
{
TfaAppUserSettings.DisableCodeForUser(SettingsManager, user.ID, code);
}
else
{
throw new ArgumentException(Resource.TfaAppAuthMessageError);
}
}
Cache.Insert("tfa/" + user.ID, (--counter).ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
if (!SecurityContext.IsAuthenticated)
{
var cookiesKey = SecurityContext.AuthenticateMe(user.ID);
CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey);
}
if (!TfaAppUserSettings.EnableForUser(SettingsManager, user.ID))
{
GenerateBackupCodes(user);
return true;
}
return false;
}
public IEnumerable<BackupCode> GenerateBackupCodes(UserInfo user)
{
var count = SetupInfo.TfaAppBackupCodeCount;
var length = SetupInfo.TfaAppBackupCodeLength;
const string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";
var data = new byte[length];
var list = new List<BackupCode>();
using (var rngCrypto = new RNGCryptoServiceProvider())
{
for (var i = 0; i < count; i++)
{
rngCrypto.GetBytes(data);
var result = new StringBuilder(length);
foreach (var b in data)
{
result.Append(alphabet[b % (alphabet.Length)]);
}
list.Add(new BackupCode(Signature, result.ToString()));
}
}
var settings = SettingsManager.LoadForCurrentUser<TfaAppUserSettings>();
settings.CodesSetting = list;
SettingsManager.SaveForCurrentUser(settings);
return list;
}
private string GenerateAccessToken(UserInfo user)
{
return Signature.Create(TfaAppUserSettings.GetSalt(SettingsManager, user.ID)).Substring(0, 10);
}
}
public static class TfaManagerExtension
{
public static DIHelper AddTfaManagerService(this DIHelper services)
{
services.TryAddScoped<TfaManager>();
return services
.AddSettingsManagerService()
.AddSetupInfo()
.AddSignatureService()
.AddCookiesManagerService()
.AddSecurityContextService();
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Core.Common.Security;
using ASC.Core.Common.Settings;
using ASC.Core.Users;
using ASC.Web.Core;
using ASC.Web.Core.PublicResources;
using Google.Authenticator;
namespace ASC.Web.Studio.Core.TFA
{
[Serializable]
public class BackupCode
{
private string code;
public Signature Signature { get; }
public string Code
{
get { return Signature.Read<string>(code); }
set { code = Signature.Create(value); }
}
public bool IsUsed { get; set; }
public BackupCode(Signature signature, string code)
{
Signature = signature;
Code = code;
IsUsed = false;
}
}
public class TfaManager
{
private static readonly TwoFactorAuthenticator Tfa = new TwoFactorAuthenticator();
private static readonly ICache Cache = AscCache.Memory;
public SettingsManager SettingsManager { get; }
public SecurityContext SecurityContext { get; }
public CookiesManager CookiesManager { get; }
public SetupInfo SetupInfo { get; }
public Signature Signature { get; }
public TfaManager(
SettingsManager settingsManager,
SecurityContext securityContext,
CookiesManager cookiesManager,
SetupInfo setupInfo,
Signature signature)
{
SettingsManager = settingsManager;
SecurityContext = securityContext;
CookiesManager = cookiesManager;
SetupInfo = setupInfo;
Signature = signature;
}
public SetupCode GenerateSetupCode(UserInfo user, int size)
{
return Tfa.GenerateSetupCode(SetupInfo.TfaAppSender, user.Email, Encoding.UTF8.GetBytes(GenerateAccessToken(user)), size, true);
}
public bool ValidateAuthCode(UserInfo user, int tenantId, string code, bool checkBackup = true)
{
if (!TfaAppAuthSettings.IsVisibleSettings
|| !SettingsManager.Load<TfaAppAuthSettings>().EnableSetting)
{
return false;
}
if (user == null || Equals(user, Constants.LostUser)) throw new Exception(Resource.ErrorUserNotFound);
code = (code ?? "").Trim();
if (string.IsNullOrEmpty(code)) throw new Exception(Resource.ActivateTfaAppEmptyCode);
int.TryParse(Cache.Get<string>("tfa/" + user.ID), out var counter);
if (++counter > SetupInfo.LoginThreshold)
{
throw new BruteForceCredentialException(Resource.TfaTooMuchError);
}
Cache.Insert("tfa/" + user.ID, counter.ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
if (!Tfa.ValidateTwoFactorPIN(GenerateAccessToken(user), code))
{
if (checkBackup && TfaAppUserSettings.BackupCodesForUser(SettingsManager, user.ID).Any(x => x.Code == code && !x.IsUsed))
{
TfaAppUserSettings.DisableCodeForUser(SettingsManager, user.ID, code);
}
else
{
throw new ArgumentException(Resource.TfaAppAuthMessageError);
}
}
Cache.Insert("tfa/" + user.ID, (--counter).ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
if (!SecurityContext.IsAuthenticated)
{
var cookiesKey = SecurityContext.AuthenticateMe(user.ID);
CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey);
}
if (!TfaAppUserSettings.EnableForUser(SettingsManager, user.ID))
{
GenerateBackupCodes(user);
return true;
}
return false;
}
public IEnumerable<BackupCode> GenerateBackupCodes(UserInfo user)
{
var count = SetupInfo.TfaAppBackupCodeCount;
var length = SetupInfo.TfaAppBackupCodeLength;
const string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";
var data = new byte[length];
var list = new List<BackupCode>();
using (var rngCrypto = new RNGCryptoServiceProvider())
{
for (var i = 0; i < count; i++)
{
rngCrypto.GetBytes(data);
var result = new StringBuilder(length);
foreach (var b in data)
{
result.Append(alphabet[b % (alphabet.Length)]);
}
list.Add(new BackupCode(Signature, result.ToString()));
}
}
var settings = SettingsManager.LoadForCurrentUser<TfaAppUserSettings>();
settings.CodesSetting = list;
SettingsManager.SaveForCurrentUser(settings);
return list;
}
private string GenerateAccessToken(UserInfo user)
{
return Signature.Create(TfaAppUserSettings.GetSalt(SettingsManager, user.ID)).Substring(0, 10);
}
}
public static class TfaManagerExtension
{
public static DIHelper AddTfaManagerService(this DIHelper services)
{
services.TryAddScoped<TfaManager>();
return services
.AddSettingsManagerService()
.AddSetupInfo()
.AddSignatureService()
.AddCookiesManagerService()
.AddSecurityContextService();
}
}
}

View File

@ -38,7 +38,6 @@ using ASC.Web.Core.PublicResources;
namespace ASC.Web.Core.Users
{
[Serializable]
[DataContract]
public class PeopleNamesSettings : ISettings
{
public Guid ID
@ -46,11 +45,8 @@ namespace ASC.Web.Core.Users
get { return new Guid("47F34957-6A70-4236-9681-C8281FB762FA"); }
}
[DataMember(Name = "Item")]
public PeopleNamesItem Item { get; set; }
[DataMember(Name = "ItemId")]
public string ItemID { get; set; }
public ISettings GetDefault(IServiceProvider serviceProvider)
@ -59,39 +55,28 @@ namespace ASC.Web.Core.Users
}
}
[DataContract]
public class PeopleNamesItem
{
private static readonly StringComparison cmp = StringComparison.InvariantCultureIgnoreCase;
[DataMember(Name = "SchemaName")]
private string schemaName;
[DataMember(Name = "UserCaption")]
private string userCaption;
[DataMember(Name = "UsersCaption")]
private string usersCaption;
[DataMember(Name = "GroupCaption")]
private string groupCaption;
[DataMember(Name = "GroupsCaption")]
private string groupsCaption;
[DataMember(Name = "UserPostCaption")]
private string userPostCaption;
[DataMember(Name = "GroupHeadCaption")]
private string groupHeadCaption;
[DataMember(Name = "RegDateCaption")]
private string regDateCaption;
[DataMember(Name = "GuestCaption")]
private string guestCaption;
[DataMember(Name = "GuestsCaption")]
private string guestsCaption;
@ -105,7 +90,6 @@ namespace ASC.Web.Core.Users
get { return "custom"; }
}
[DataMember(Name = "Id")]
public string Id { get; set; }
public string SchemaName