2020-01-27 11:15:18 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (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.Linq;
|
2020-02-06 13:06:36 +00:00
|
|
|
|
2020-02-17 08:58:14 +00:00
|
|
|
using ASC.Common;
|
2020-01-27 11:15:18 +00:00
|
|
|
using ASC.FederatedLogin.LoginProviders;
|
2020-02-06 13:06:36 +00:00
|
|
|
using ASC.Files.Core;
|
2020-02-13 12:19:25 +00:00
|
|
|
using ASC.Files.Core.Data;
|
2020-02-06 13:06:36 +00:00
|
|
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2020-01-27 11:15:18 +00:00
|
|
|
|
|
|
|
namespace ASC.Web.Files.Helpers
|
|
|
|
{
|
2020-02-06 13:06:36 +00:00
|
|
|
public class ThirdpartyConfiguration
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
2020-02-06 13:06:36 +00:00
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
public IDaoFactory DaoFactory { get; }
|
|
|
|
public BoxLoginProvider BoxLoginProvider { get; }
|
|
|
|
public DropboxLoginProvider DropboxLoginProvider { get; }
|
|
|
|
public OneDriveLoginProvider OneDriveLoginProvider { get; }
|
|
|
|
public DocuSignLoginProvider DocuSignLoginProvider { get; }
|
|
|
|
public GoogleLoginProvider GoogleLoginProvider { get; }
|
|
|
|
|
|
|
|
public ThirdpartyConfiguration(
|
|
|
|
IConfiguration configuration,
|
|
|
|
IDaoFactory daoFactory,
|
|
|
|
BoxLoginProvider boxLoginProvider,
|
|
|
|
DropboxLoginProvider dropboxLoginProvider,
|
|
|
|
OneDriveLoginProvider oneDriveLoginProvider,
|
|
|
|
DocuSignLoginProvider docuSignLoginProvider,
|
|
|
|
GoogleLoginProvider googleLoginProvider)
|
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
DaoFactory = daoFactory;
|
|
|
|
BoxLoginProvider = boxLoginProvider;
|
|
|
|
DropboxLoginProvider = dropboxLoginProvider;
|
|
|
|
OneDriveLoginProvider = oneDriveLoginProvider;
|
|
|
|
DocuSignLoginProvider = docuSignLoginProvider;
|
|
|
|
GoogleLoginProvider = googleLoginProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<string> ThirdPartyProviders
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
2020-02-06 13:06:36 +00:00
|
|
|
get { return (Configuration["files:thirdparty:enable"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries); }
|
2020-01-27 11:15:18 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2020-02-06 13:06:36 +00:00
|
|
|
var providerDao = DaoFactory.ProviderDao;
|
|
|
|
if (providerDao == null) return false;
|
2020-01-27 11:15:18 +00:00
|
|
|
|
|
|
|
return SupportBoxInclusion || SupportDropboxInclusion || SupportDocuSignInclusion || SupportGoogleDriveInclusion || SupportOneDriveInclusion || SupportSharePointInclusion || SupportWebDavInclusion || SupportNextcloudInclusion || SupportOwncloudInclusion || SupportYandexInclusion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportBoxInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return ThirdPartyProviders.Contains("box") && BoxLoginProvider.Instance.IsEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportDropboxInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return ThirdPartyProviders.Contains("dropboxv2") && DropboxLoginProvider.Instance.IsEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportOneDriveInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return ThirdPartyProviders.Contains("onedrive") && OneDriveLoginProvider.Instance.IsEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportSharePointInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return ThirdPartyProviders.Contains("sharepoint"); }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportWebDavInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return ThirdPartyProviders.Contains("webdav"); }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportNextcloudInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return ThirdPartyProviders.Contains("nextcloud"); }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportOwncloudInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return ThirdPartyProviders.Contains("owncloud"); }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportYandexInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return ThirdPartyProviders.Contains("yandex"); }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public string DropboxAppKey
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return DropboxLoginProvider.Instance["dropboxappkey"]; }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public string DropboxAppSecret
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get { return DropboxLoginProvider.Instance["dropboxappsecret"]; }
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportDocuSignInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return ThirdPartyProviders.Contains("docusign") && DocuSignLoginProvider.Instance.IsEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 13:06:36 +00:00
|
|
|
public bool SupportGoogleDriveInclusion
|
2020-01-27 11:15:18 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return ThirdPartyProviders.Contains("google") && GoogleLoginProvider.Instance.IsEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-13 12:19:25 +00:00
|
|
|
public static class ThirdpartyConfigurationExtension
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
public static DIHelper AddThirdpartyConfigurationService(this DIHelper services)
|
2020-02-13 12:19:25 +00:00
|
|
|
{
|
|
|
|
services.TryAddScoped<ThirdpartyConfiguration>();
|
|
|
|
return services
|
|
|
|
.AddDaoFactoryService()
|
|
|
|
.AddDocuSignLoginProviderService()
|
|
|
|
.AddBoxLoginProviderService()
|
|
|
|
.AddDropboxLoginProviderService()
|
|
|
|
.AddOneDriveLoginProviderService()
|
|
|
|
.AddGoogleLoginProviderService()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2020-01-27 11:15:18 +00:00
|
|
|
}
|