Merge
This commit is contained in:
commit
78538887bd
27 changed files with 466 additions and 80 deletions
|
@ -5,21 +5,21 @@ using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||||
{
|
{
|
||||||
public class OfficeOnlineCollection : AbstractConfigCollection, IReadOnlyCollection<string>
|
public class OfficeOnlineCollection : AbstractConfigCollection, IReadOnlyCollection<OfficeOnlineElement>
|
||||||
{
|
{
|
||||||
private readonly IList<string> _officeExtensions;
|
private readonly IList<OfficeOnlineElement> _officeExtensions;
|
||||||
|
|
||||||
public OfficeOnlineCollection()
|
public OfficeOnlineCollection()
|
||||||
{
|
{
|
||||||
IsEnabled = ConfigSection.OfficeOnline.IsEnabled;
|
IsEnabled = ConfigSection.OfficeOnline.IsEnabled;
|
||||||
Url = ConfigSection.OfficeOnline.Url;
|
Url = ConfigSection.OfficeOnline.Url;
|
||||||
_officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().Select(x => x.Extension).ToList();
|
_officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnabled { get; private set; }
|
public bool IsEnabled { get; private set; }
|
||||||
public string Url { get; private set; }
|
public string Url { get; private set; }
|
||||||
|
|
||||||
public IEnumerator<string> GetEnumerator()
|
public IEnumerator<OfficeOnlineElement> GetEnumerator()
|
||||||
{
|
{
|
||||||
return _officeExtensions.GetEnumerator();
|
return _officeExtensions.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||||
|
|
||||||
public bool Contains(string extension)
|
public bool Contains(string extension)
|
||||||
{
|
{
|
||||||
return _officeExtensions.Contains(extension);
|
return _officeExtensions.Any(x=>x.Extension == extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
public class OfficeOnlineElement : ConfigurationElement
|
public class OfficeOnlineElement : ConfigurationElement
|
||||||
{
|
{
|
||||||
private const string ExtensionKey = "extension";
|
private const string ExtensionKey = "extension";
|
||||||
|
private const string OwaOpenerKey = "owaOpener";
|
||||||
|
|
||||||
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
|
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
|
||||||
public string Extension
|
public string Extension
|
||||||
|
@ -12,5 +13,12 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
get { return this[ExtensionKey].ToString(); }
|
get { return this[ExtensionKey].ToString(); }
|
||||||
set { this[ExtensionKey] = value; }
|
set { this[ExtensionKey] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConfigurationProperty(OwaOpenerKey, IsKey = true, IsRequired = true)]
|
||||||
|
public string OwaOpener
|
||||||
|
{
|
||||||
|
get { return this[OwaOpenerKey].ToString(); }
|
||||||
|
set { this[OwaOpenerKey] = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Entities.Owa
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class CheckFileInfo
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public string BaseFileName { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public string OwnerId { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public long Size { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public string Version { get; set; }
|
||||||
|
|
||||||
|
//[DataMember]
|
||||||
|
//public string SHA256 { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool AllowExternalMarketplace { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string BreadcrumbBrandName { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string BreadcrumbBrandUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string BreadcrumbDocName { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string BreadcrumbDocUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string BreadcrumbFolderName { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string BreadcrumbFolderUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string ClientUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool CloseButtonClosesWindow { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string CloseUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool DisableBrowserCachingOfUserContent { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool DisablePrint { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool DisableTranslation { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string DownloadUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string FileSharingUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string FileUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostAuthenticationId { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostEditUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostEmbeddedEditUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostEmbeddedViewUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostName { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostNotes { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostRestUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string HostViewUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string IrmPolicyDescription { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string IrmPolicyTitle { get; set; }
|
||||||
|
|
||||||
|
//[DataMember]
|
||||||
|
//public string PresenceProvider { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string PresenceUserId { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string PrivacyUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool ProtectInClient { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool ReadOnly { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool RestrictedWebViewOnly { get; set; }
|
||||||
|
|
||||||
|
//[DataMember]
|
||||||
|
//public string SignoutUrl { get; set; }
|
||||||
|
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsCoauth { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsCobalt { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsFolders { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsLocks { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsScenarioLinks { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsSecureStore { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool SupportsUpdate { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string TenantId { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string TermsOfUseUrl { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string TimeZone { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool UserCanAttend { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool UserCanNotWriteRelative { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool UserCanPresent { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public bool UserCanWrite { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string UserFriendlyName { get; set; }
|
||||||
|
//[DataMember]
|
||||||
|
//public string UserId { get; set; }
|
||||||
|
|
||||||
|
//[DataMember]
|
||||||
|
//public bool WebEditingDisabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Exceptions
|
namespace WebsitePanel.WebDav.Core.Exceptions
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ConnectToWebDavServerException : Exception
|
public class ConnectToWebDavServerException : Exception
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Exceptions
|
namespace WebsitePanel.WebDav.Core.Exceptions
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ResourceNotFoundException : Exception
|
public class ResourceNotFoundException : Exception
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.DirectoryServices.AccountManagement;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -6,6 +7,7 @@ using System.Net.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
using WebsitePanel.WebDav.Core.Exceptions;
|
using WebsitePanel.WebDav.Core.Exceptions;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDav.Core
|
namespace WebsitePanel.WebDav.Core
|
||||||
|
@ -18,6 +20,7 @@ namespace WebsitePanel.WebDav.Core
|
||||||
IFolder CreateFolder(string name);
|
IFolder CreateFolder(string name);
|
||||||
IHierarchyItem[] GetChildren();
|
IHierarchyItem[] GetChildren();
|
||||||
IResource GetResource(string name);
|
IResource GetResource(string name);
|
||||||
|
Uri Path { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WebDavFolder : WebDavHierarchyItem, IFolder
|
public class WebDavFolder : WebDavHierarchyItem, IFolder
|
||||||
|
@ -25,6 +28,8 @@ namespace WebsitePanel.WebDav.Core
|
||||||
private IHierarchyItem[] _children = new IHierarchyItem[0];
|
private IHierarchyItem[] _children = new IHierarchyItem[0];
|
||||||
private Uri _path;
|
private Uri _path;
|
||||||
|
|
||||||
|
public Uri Path { get { return _path; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The constructor
|
/// The constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -166,7 +171,7 @@ namespace WebsitePanel.WebDav.Core
|
||||||
var credentials = (NetworkCredential)_credentials;
|
var credentials = (NetworkCredential)_credentials;
|
||||||
if (credentials != null && credentials.UserName != null)
|
if (credentials != null && credentials.UserName != null)
|
||||||
{
|
{
|
||||||
request.Credentials = credentials;
|
//request.Credentials = credentials;
|
||||||
string auth = "Basic " +
|
string auth = "Basic " +
|
||||||
Convert.ToBase64String(
|
Convert.ToBase64String(
|
||||||
Encoding.Default.GetBytes(credentials.UserName + ":" + credentials.Password));
|
Encoding.Default.GetBytes(credentials.UserName + ":" + credentials.Password));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using WebsitePanel.WebDav.Core.Client;
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Models
|
namespace WebsitePanel.WebDav.Core.Interfaces.Managers
|
||||||
{
|
{
|
||||||
public interface IWebDavManager
|
public interface IWebDavManager
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,10 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
IEnumerable<IHierarchyItem> GetChildren();
|
IEnumerable<IHierarchyItem> GetChildren();
|
||||||
bool IsFile(string fileName);
|
bool IsFile(string fileName);
|
||||||
byte[] GetFileBytes(string fileName);
|
byte[] GetFileBytes(string fileName);
|
||||||
|
IResource GetResource( string fileName);
|
||||||
string GetFileUrl(string fileName);
|
string GetFileUrl(string fileName);
|
||||||
|
|
||||||
|
string CreateFileId(string path);
|
||||||
|
string FilePathFromId(string id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
|
using WebsitePanel.WebDav.Core.Entities.Owa;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Interfaces.Owa
|
||||||
|
{
|
||||||
|
public interface IWopiServer
|
||||||
|
{
|
||||||
|
CheckFileInfo GetCheckFileInfo(string path);
|
||||||
|
FileResult GetFile(string path);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Security;
|
||||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDav.Core.Interfaces.Security
|
namespace WebsitePanel.WebDav.Core.Interfaces.Security
|
||||||
|
@ -10,7 +11,9 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Security
|
||||||
public interface IAuthenticationService
|
public interface IAuthenticationService
|
||||||
{
|
{
|
||||||
WspPrincipal LogIn(string login, string password);
|
WspPrincipal LogIn(string login, string password);
|
||||||
|
WspPrincipal LogIn(string accessToken);
|
||||||
void CreateAuthenticationTicket(WspPrincipal principal);
|
void CreateAuthenticationTicket(WspPrincipal principal);
|
||||||
|
string CreateAccessToken(WspPrincipal principal);
|
||||||
void LogOut();
|
void LogOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,16 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using log4net;
|
||||||
using WebsitePanel.WebDav.Core;
|
using WebsitePanel.Providers.OS;
|
||||||
using WebsitePanel.WebDav.Core.Client;
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
|
using WebsitePanel.WebDav.Core.Exceptions;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
using WebsitePanel.WebDav.Core.Wsp.Framework;
|
using WebsitePanel.WebDav.Core.Wsp.Framework;
|
||||||
using WebsitePanel.WebDavPortal.Exceptions;
|
|
||||||
using WebsitePanel.Providers.OS;
|
|
||||||
using Ninject;
|
|
||||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Models
|
namespace WebsitePanel.WebDav.Core.Managers
|
||||||
{
|
{
|
||||||
public class WebDavManager : IWebDavManager
|
public class WebDavManager : IWebDavManager
|
||||||
{
|
{
|
||||||
|
@ -25,15 +21,15 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
|
|
||||||
private readonly ILog Log;
|
private readonly ILog Log;
|
||||||
|
|
||||||
private IList<SystemFile> _rootFolders;
|
|
||||||
private int _itemId;
|
|
||||||
private IFolder _currentFolder;
|
private IFolder _currentFolder;
|
||||||
private string _webDavRootPath;
|
|
||||||
private bool _isRoot = true;
|
private bool _isRoot = true;
|
||||||
|
|
||||||
|
private Lazy<IList<SystemFile>> _rootFolders;
|
||||||
|
private Lazy<string> _webDavRootPath;
|
||||||
|
|
||||||
public string RootPath
|
public string RootPath
|
||||||
{
|
{
|
||||||
get { return _webDavRootPath; }
|
get { return _webDavRootPath.Value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebDavManager(ICryptography cryptography)
|
public WebDavManager(ICryptography cryptography)
|
||||||
|
@ -41,20 +37,21 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
_cryptography = cryptography;
|
_cryptography = cryptography;
|
||||||
Log = LogManager.GetLogger(this.GetType());
|
Log = LogManager.GetLogger(this.GetType());
|
||||||
|
|
||||||
var credential = new NetworkCredential(WspContext.User.Login, _cryptography.Decrypt(WspContext.User.EncryptedPassword), WebDavAppConfigManager.Instance.UserDomain);
|
|
||||||
|
|
||||||
_webDavSession = new WebDavSession();
|
_webDavSession = new WebDavSession();
|
||||||
|
|
||||||
_webDavSession.Credentials = credential;
|
_rootFolders = new Lazy<IList<SystemFile>>(ConnectToWebDavServer);
|
||||||
_itemId = WspContext.User.ItemId;
|
_webDavRootPath = new Lazy<string>(() =>
|
||||||
_rootFolders = ConnectToWebDavServer();
|
|
||||||
|
|
||||||
if (_rootFolders.Any())
|
|
||||||
{
|
{
|
||||||
var folder = _rootFolders.First();
|
if (_rootFolders.Value.Any())
|
||||||
|
{
|
||||||
|
var folder = _rootFolders.Value.First();
|
||||||
var uri = new Uri(folder.Url);
|
var uri = new Uri(folder.Url);
|
||||||
_webDavRootPath = uri.Scheme + "://" + uri.Host + uri.Segments[0] + uri.Segments[1];
|
return uri.Scheme + "://" + uri.Host + uri.Segments[0] + uri.Segments[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenFolder(string pathPart)
|
public void OpenFolder(string pathPart)
|
||||||
|
@ -64,8 +61,12 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
_isRoot = true;
|
_isRoot = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isRoot = false;
|
_isRoot = false;
|
||||||
_currentFolder = _webDavSession.OpenFolder(_webDavRootPath + pathPart);
|
|
||||||
|
_webDavSession.Credentials = new NetworkCredential(WspContext.User.Login, _cryptography.Decrypt(WspContext.User.EncryptedPassword), WebDavAppConfigManager.Instance.UserDomain);
|
||||||
|
|
||||||
|
_currentFolder = _webDavSession.OpenFolder(_webDavRootPath.Value + pathPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IHierarchyItem> GetChildren()
|
public IEnumerable<IHierarchyItem> GetChildren()
|
||||||
|
@ -74,7 +75,7 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
|
|
||||||
if (_isRoot)
|
if (_isRoot)
|
||||||
{
|
{
|
||||||
children = _rootFolders.Select(x => new WebDavHierarchyItem {Href = new Uri(x.Url), ItemType = ItemType.Folder}).ToArray();
|
children = _rootFolders.Value.Select(x => new WebDavHierarchyItem {Href = new Uri(x.Url), ItemType = ItemType.Folder}).ToArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -119,6 +120,19 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IResource GetResource(string fileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IResource resource = _currentFolder.GetResource(fileName);
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException exception)
|
||||||
|
{
|
||||||
|
throw new ResourceNotFoundException("Resource not found", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GetFileUrl(string fileName)
|
public string GetFileUrl(string fileName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -139,9 +153,9 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
|
|
||||||
var userGroups = WSP.Services.Organizations.GetSecurityGroupsByMember(user.ItemId, user.AccountId);
|
var userGroups = WSP.Services.Organizations.GetSecurityGroupsByMember(user.ItemId, user.AccountId);
|
||||||
|
|
||||||
foreach (var folder in WSP.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
foreach (var folder in WSP.Services.EnterpriseStorage.GetEnterpriseFolders(WspContext.User.ItemId))
|
||||||
{
|
{
|
||||||
var permissions = WSP.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
var permissions = WSP.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(WspContext.User.ItemId, folder.Name);
|
||||||
|
|
||||||
foreach (var permission in permissions)
|
foreach (var permission in permissions)
|
||||||
{
|
{
|
||||||
|
@ -168,5 +182,16 @@ namespace WebsitePanel.WebDavPortal.Models
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string CreateFileId(string path)
|
||||||
|
{
|
||||||
|
return _cryptography.Encrypt(path).Replace("/", "AAAAA");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FilePathFromId(string id)
|
||||||
|
{
|
||||||
|
return _cryptography.Decrypt(id.Replace("AAAAA", "/"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
|
using WebsitePanel.WebDav.Core.Entities.Owa;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Owa
|
||||||
|
{
|
||||||
|
public class WopiServer : IWopiServer
|
||||||
|
{
|
||||||
|
private readonly IWebDavManager _webDavManager;
|
||||||
|
|
||||||
|
public WopiServer(IWebDavManager webDavManager)
|
||||||
|
{
|
||||||
|
_webDavManager = webDavManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckFileInfo GetCheckFileInfo(string path)
|
||||||
|
{
|
||||||
|
string fileName = path.Split('/').Last();
|
||||||
|
int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
string folder = path.Remove(index - 1, fileName.Length + 1);
|
||||||
|
|
||||||
|
_webDavManager.OpenFolder(folder);
|
||||||
|
|
||||||
|
var resource = _webDavManager.GetResource(fileName);
|
||||||
|
|
||||||
|
var cFileInfo = new CheckFileInfo
|
||||||
|
{
|
||||||
|
BaseFileName = resource.DisplayName,
|
||||||
|
OwnerId = @"4257508bfe174aa28b461536d8b6b648",
|
||||||
|
Size = resource.ContentLength,
|
||||||
|
Version = @"%22%7B59CCD75F%2D0687%2D4F86%2DBBCF%2D059126640640%7D%2C1%22"
|
||||||
|
};
|
||||||
|
|
||||||
|
return cFileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileResult GetFile(string path)
|
||||||
|
{
|
||||||
|
string fileName = path.Split('/').Last();
|
||||||
|
int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
string folder = path.Remove(index - 1, fileName.Length + 1);
|
||||||
|
|
||||||
|
_webDavManager.OpenFolder(folder);
|
||||||
|
|
||||||
|
var fileBytes = _webDavManager.GetFileBytes(fileName);
|
||||||
|
|
||||||
|
return new FileContentResult(fileBytes, MediaTypeNames.Application.Octet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.DirectoryServices.AccountManagement;
|
using System.DirectoryServices.AccountManagement;
|
||||||
|
using System.Threading;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Script.Serialization;
|
using System.Web.Script.Serialization;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
|
@ -29,6 +30,8 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.UserPrincipalName, login);
|
||||||
|
|
||||||
var principal = new WspPrincipal(login);
|
var principal = new WspPrincipal(login);
|
||||||
|
|
||||||
var exchangeAccount = WSP.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(login);
|
var exchangeAccount = WSP.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(login);
|
||||||
|
@ -40,13 +43,34 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
|
||||||
principal.DisplayName = exchangeAccount.DisplayName;
|
principal.DisplayName = exchangeAccount.DisplayName;
|
||||||
principal.EncryptedPassword = _cryptography.Encrypt(password);
|
principal.EncryptedPassword = _cryptography.Encrypt(password);
|
||||||
|
|
||||||
CreateAuthenticationTicket(principal);
|
if (HttpContext.Current != null)
|
||||||
|
{
|
||||||
HttpContext.Current.User = principal;
|
HttpContext.Current.User = principal;
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.CurrentPrincipal = principal;
|
||||||
|
|
||||||
return principal;
|
return principal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WspPrincipal LogIn(string accessToken)
|
||||||
|
{
|
||||||
|
var token = _cryptography.Decrypt(accessToken.Replace("AAAAA", "/"));
|
||||||
|
|
||||||
|
var splitResult = token.Split(':');
|
||||||
|
|
||||||
|
var login = splitResult[0];
|
||||||
|
var password = _cryptography.Decrypt(splitResult[1]);
|
||||||
|
var expiration = DateTime.Parse(splitResult[2]);
|
||||||
|
|
||||||
|
if (expiration < DateTime.Today)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LogIn(login, password);
|
||||||
|
}
|
||||||
|
|
||||||
public void CreateAuthenticationTicket(WspPrincipal principal)
|
public void CreateAuthenticationTicket(WspPrincipal principal)
|
||||||
{
|
{
|
||||||
var serializer = new JavaScriptSerializer();
|
var serializer = new JavaScriptSerializer();
|
||||||
|
@ -67,6 +91,13 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
|
||||||
HttpContext.Current.Response.Cookies.Add(cookie);
|
HttpContext.Current.Response.Cookies.Add(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string CreateAccessToken(WspPrincipal principal)
|
||||||
|
{
|
||||||
|
var token = string.Format("{0}:{1}:{2}", principal.Login, principal.EncryptedPassword, DateTime.Now.ToShortDateString());
|
||||||
|
|
||||||
|
return _cryptography.Encrypt(token).Replace("/", "AAAAA");
|
||||||
|
}
|
||||||
|
|
||||||
public void LogOut()
|
public void LogOut()
|
||||||
{
|
{
|
||||||
FormsAuthentication.SignOut();
|
FormsAuthentication.SignOut();
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
|
||||||
|
|
||||||
public WspPrincipal(string username)
|
public WspPrincipal(string username)
|
||||||
{
|
{
|
||||||
Identity = new GenericIdentity(username);
|
Identity = new GenericIdentity(username);//new WindowsIdentity(username, "WindowsAuthentication");
|
||||||
Login = username;
|
Login = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="log4net">
|
||||||
|
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||||
|
@ -45,6 +48,7 @@
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.DirectoryServices.AccountManagement" />
|
<Reference Include="System.DirectoryServices.AccountManagement" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Web">
|
<Reference Include="System.Web">
|
||||||
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll</HintPath>
|
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -79,6 +83,10 @@
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="WebsitePanel.EnterpriseServer.Base, Version=2.1.0.1, Culture=neutral, PublicKeyToken=da8782a6fc4d0081, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\Scheduler Domains\WebsitePanel\Bin\WebsitePanel.EnterpriseServer.Base.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="WebsitePanel.EnterpriseServer.Client">
|
<Reference Include="WebsitePanel.EnterpriseServer.Client">
|
||||||
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
|
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -108,6 +116,9 @@
|
||||||
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
||||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||||
|
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
|
||||||
|
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
||||||
|
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
||||||
<Compile Include="Exceptions\UnauthorizedException.cs" />
|
<Compile Include="Exceptions\UnauthorizedException.cs" />
|
||||||
<Compile Include="Exceptions\WebDavException.cs" />
|
<Compile Include="Exceptions\WebDavException.cs" />
|
||||||
<Compile Include="Exceptions\WebDavHttpException.cs" />
|
<Compile Include="Exceptions\WebDavHttpException.cs" />
|
||||||
|
@ -115,11 +126,14 @@
|
||||||
<Compile Include="IFolder.cs" />
|
<Compile Include="IFolder.cs" />
|
||||||
<Compile Include="IHierarchyItem.cs" />
|
<Compile Include="IHierarchyItem.cs" />
|
||||||
<Compile Include="IItemContent.cs" />
|
<Compile Include="IItemContent.cs" />
|
||||||
|
<Compile Include="Interfaces\Managers\IWebDavManager.cs" />
|
||||||
|
<Compile Include="Interfaces\Owa\IWopiServer.cs" />
|
||||||
<Compile Include="Interfaces\Security\IAuthenticationService.cs" />
|
<Compile Include="Interfaces\Security\IAuthenticationService.cs" />
|
||||||
<Compile Include="IResource.cs" />
|
<Compile Include="IResource.cs" />
|
||||||
<Compile Include="IResumableUpload.cs" />
|
<Compile Include="IResumableUpload.cs" />
|
||||||
<Compile Include="ItemType.cs" />
|
<Compile Include="ItemType.cs" />
|
||||||
<Compile Include="LockUriTokenPair.cs" />
|
<Compile Include="LockUriTokenPair.cs" />
|
||||||
|
<Compile Include="Managers\WebDavManager.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Property.cs" />
|
<Compile Include="Property.cs" />
|
||||||
<Compile Include="PropertyName.cs" />
|
<Compile Include="PropertyName.cs" />
|
||||||
|
@ -132,6 +146,7 @@
|
||||||
<Compile Include="Security\Cryptography\ICryptography.cs" />
|
<Compile Include="Security\Cryptography\ICryptography.cs" />
|
||||||
<Compile Include="Security\Authentication\FormsAuthenticationService.cs" />
|
<Compile Include="Security\Authentication\FormsAuthenticationService.cs" />
|
||||||
<Compile Include="Security\Authentication\Principals\WspPrincipal.cs" />
|
<Compile Include="Security\Authentication\Principals\WspPrincipal.cs" />
|
||||||
|
<Compile Include="Owa\WopiServer.cs" />
|
||||||
<Compile Include="WebDavSession.cs" />
|
<Compile Include="WebDavSession.cs" />
|
||||||
<Compile Include="WspContext.cs" />
|
<Compile Include="WspContext.cs" />
|
||||||
<Compile Include="Wsp\Framework\WSP.cs" />
|
<Compile Include="Wsp\Framework\WSP.cs" />
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="log4net" version="2.0.0" targetFramework="net45" />
|
||||||
<package id="Microsoft.AspNet.Mvc" version="5.2.2" targetFramework="net45" />
|
<package id="Microsoft.AspNet.Mvc" version="5.2.2" targetFramework="net45" />
|
||||||
<package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
|
<package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
|
||||||
<package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45" />
|
<package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45" />
|
||||||
|
|
|
@ -26,6 +26,22 @@ namespace WebsitePanel.WebDavPortal
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Owa
|
||||||
|
|
||||||
|
routes.MapRoute(
|
||||||
|
name: OwaRouteNames.GetFile,
|
||||||
|
url: "owa/wopi*/files/{encodedPath}/contents",
|
||||||
|
defaults: new { controller = "Owa", action = "GetFile" }
|
||||||
|
);
|
||||||
|
|
||||||
|
routes.MapRoute(
|
||||||
|
name: OwaRouteNames.CheckFileInfo,
|
||||||
|
url: "owa/wopi*/files/{encodedPath}",
|
||||||
|
defaults: new { controller = "Owa", action = "CheckFileInfo" }
|
||||||
|
);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: "Office365DocumentRoute",
|
name: "Office365DocumentRoute",
|
||||||
url: "office365/{org}/{*pathPart}",
|
url: "office365/{org}/{*pathPart}",
|
||||||
|
|
|
@ -3,8 +3,8 @@ using System.Net;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
|
using WebsitePanel.WebDav.Core.Security.Authentication;
|
||||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
using WebsitePanel.WebDavPortal.Exceptions;
|
|
||||||
using WebsitePanel.WebDavPortal.Models;
|
using WebsitePanel.WebDavPortal.Models;
|
||||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
|
@ -44,6 +44,8 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
|
|
||||||
if (user.Identity.IsAuthenticated)
|
if (user.Identity.IsAuthenticated)
|
||||||
{
|
{
|
||||||
|
_authenticationService.CreateAuthenticationTicket(user);
|
||||||
|
|
||||||
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = null;
|
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = null;
|
||||||
|
|
||||||
return RedirectToRoute(FileSystemRouteNames.FilePath, new { org = WspContext.User.OrganizationId });
|
return RedirectToRoute(FileSystemRouteNames.FilePath, new { org = WspContext.User.OrganizationId });
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Routing;
|
||||||
using WebsitePanel.WebDav.Core;
|
using WebsitePanel.WebDav.Core;
|
||||||
using WebsitePanel.WebDav.Core.Client;
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
using WebsitePanel.WebDav.Core.Exceptions;
|
using WebsitePanel.WebDav.Core.Exceptions;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
using WebsitePanel.WebDavPortal.CustomAttributes;
|
using WebsitePanel.WebDavPortal.CustomAttributes;
|
||||||
using WebsitePanel.WebDavPortal.Extensions;
|
using WebsitePanel.WebDavPortal.Extensions;
|
||||||
using WebsitePanel.WebDavPortal.Models;
|
using WebsitePanel.WebDavPortal.Models;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Controllers
|
namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
|
|
||||||
|
@ -20,11 +26,15 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
[LdapAuthorization]
|
[LdapAuthorization]
|
||||||
public class FileSystemController : Controller
|
public class FileSystemController : Controller
|
||||||
{
|
{
|
||||||
|
private readonly ICryptography _cryptography;
|
||||||
private readonly IWebDavManager _webdavManager;
|
private readonly IWebDavManager _webdavManager;
|
||||||
|
private readonly IAuthenticationService _authenticationService;
|
||||||
|
|
||||||
public FileSystemController(IWebDavManager webdavManager)
|
public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService)
|
||||||
{
|
{
|
||||||
|
_cryptography = cryptography;
|
||||||
_webdavManager = webdavManager;
|
_webdavManager = webdavManager;
|
||||||
|
_authenticationService = authenticationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
@ -58,8 +68,14 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
|
|
||||||
public ActionResult ShowOfficeDocument(string org, string pathPart = "")
|
public ActionResult ShowOfficeDocument(string org, string pathPart = "")
|
||||||
{
|
{
|
||||||
|
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||||
|
|
||||||
string fileUrl = _webdavManager.RootPath.TrimEnd('/') + "/" + pathPart.TrimStart('/');
|
string fileUrl = _webdavManager.RootPath.TrimEnd('/') + "/" + pathPart.TrimStart('/');
|
||||||
var uri = new Uri(WebDavAppConfigManager.Instance.OfficeOnline.Url).AddParameter("src", fileUrl).ToString();
|
string accessToken = _authenticationService.CreateAccessToken(WspContext.User);
|
||||||
|
|
||||||
|
string wopiSrc = Server.UrlDecode(Url.RouteUrl(OwaRouteNames.CheckFileInfo, new { encodedPath = _webdavManager.CreateFileId(pathPart) }, Request.Url.Scheme));
|
||||||
|
|
||||||
|
var uri = string.Format("{0}/{1}?WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpener.OwaOpener, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken));
|
||||||
|
|
||||||
return View(new OfficeOnlineModel(uri, new Uri(fileUrl).Segments.Last()));
|
return View(new OfficeOnlineModel(uri, new Uri(fileUrl).Segments.Last()));
|
||||||
}
|
}
|
||||||
|
@ -80,7 +96,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
return PartialView("_ResourseCollectionPartial", result);
|
return PartialView("_ResourseCollectionPartial", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent); ;
|
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
|
{
|
||||||
|
[AllowAnonymous]
|
||||||
|
public class OwaController : Controller
|
||||||
|
{
|
||||||
|
private readonly IWopiServer _wopiServer;
|
||||||
|
private readonly IWebDavManager _webDavManager;
|
||||||
|
private readonly IAuthenticationService _authenticationService;
|
||||||
|
|
||||||
|
public OwaController(IWopiServer wopiServer, IWebDavManager webDavManager, IAuthenticationService authenticationService)
|
||||||
|
{
|
||||||
|
_wopiServer = wopiServer;
|
||||||
|
_webDavManager = webDavManager;
|
||||||
|
_authenticationService = authenticationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonResult CheckFileInfo( string encodedPath)
|
||||||
|
{
|
||||||
|
var path = _webDavManager.FilePathFromId(encodedPath);
|
||||||
|
|
||||||
|
var fileInfo = _wopiServer.GetCheckFileInfo(path);
|
||||||
|
|
||||||
|
return Json(fileInfo, JsonRequestBehavior.AllowGet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileResult GetFile(string encodedPath)
|
||||||
|
{
|
||||||
|
var path = _webDavManager.FilePathFromId(encodedPath);
|
||||||
|
|
||||||
|
return _wopiServer.GetFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||||
|
{
|
||||||
|
base.OnActionExecuting(filterContext);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Request["access_token"]))
|
||||||
|
{
|
||||||
|
_authenticationService.LogIn(Request["access_token"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,10 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.SessionState;
|
using System.Web.SessionState;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
|
using WebsitePanel.WebDav.Core.Owa;
|
||||||
using WebsitePanel.WebDav.Core.Security;
|
using WebsitePanel.WebDav.Core.Security;
|
||||||
using WebsitePanel.WebDav.Core.Security.Authentication;
|
using WebsitePanel.WebDav.Core.Security.Authentication;
|
||||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
|
@ -21,6 +24,7 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||||
kernel.Bind<ICryptography>().To<CryptoUtils>();
|
kernel.Bind<ICryptography>().To<CryptoUtils>();
|
||||||
kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>();
|
kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>();
|
||||||
kernel.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
kernel.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
||||||
|
kernel.Bind<IWopiServer>().To<WopiServer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,8 +4,8 @@ using Ninject;
|
||||||
using Ninject.Activation;
|
using Ninject.Activation;
|
||||||
using WebsitePanel.WebDav.Core;
|
using WebsitePanel.WebDav.Core;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
|
using WebsitePanel.WebDav.Core.Managers;
|
||||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
using WebsitePanel.WebDavPortal.Exceptions;
|
|
||||||
using WebsitePanel.WebDavPortal.Models;
|
using WebsitePanel.WebDavPortal.Models;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace WebsitePanel.WebDavPortal.FileOperations
|
||||||
public FileOpenerManager()
|
public FileOpenerManager()
|
||||||
{
|
{
|
||||||
if (WebDavAppConfigManager.Instance.OfficeOnline.IsEnabled)
|
if (WebDavAppConfigManager.Instance.OfficeOnline.IsEnabled)
|
||||||
_operationTypes.AddRange(WebDavAppConfigManager.Instance.OfficeOnline.ToDictionary(x => x, y => FileOpenerType.OfficeOnline));
|
_operationTypes.AddRange(WebDavAppConfigManager.Instance.OfficeOnline.ToDictionary(x => x.Extension, y => FileOpenerType.OfficeOnline));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileOpenerType this[string fileExtension]
|
public FileOpenerType this[string fileExtension]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Optimization;
|
using System.Web.Optimization;
|
||||||
|
@ -6,9 +7,12 @@ using System.Web.Routing;
|
||||||
using System.Web.Script.Serialization;
|
using System.Web.Script.Serialization;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||||
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
using WebsitePanel.WebDavPortal.Controllers;
|
using WebsitePanel.WebDavPortal.Controllers;
|
||||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||||
|
using WebsitePanel.WebDavPortal.HttpHandlers;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal
|
namespace WebsitePanel.WebDavPortal
|
||||||
{
|
{
|
||||||
|
@ -55,8 +59,11 @@ namespace WebsitePanel.WebDavPortal
|
||||||
|
|
||||||
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
|
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
|
|
||||||
var contextWrapper = new HttpContextWrapper(Context);
|
var contextWrapper = new HttpContextWrapper(Context);
|
||||||
|
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
|
||||||
|
|
||||||
|
var authService = DependencyResolver.Current.GetService<IAuthenticationService>();
|
||||||
|
var cryptography = DependencyResolver.Current.GetService<ICryptography>();
|
||||||
|
|
||||||
if (authCookie != null)
|
if (authCookie != null)
|
||||||
{
|
{
|
||||||
|
@ -66,15 +73,7 @@ namespace WebsitePanel.WebDavPortal
|
||||||
|
|
||||||
var principalSerialized = serializer.Deserialize<WspPrincipal>(authTicket.UserData);
|
var principalSerialized = serializer.Deserialize<WspPrincipal>(authTicket.UserData);
|
||||||
|
|
||||||
var principal = new WspPrincipal(principalSerialized.Login);
|
authService.LogIn(principalSerialized.Login, cryptography.Decrypt(principalSerialized.EncryptedPassword));
|
||||||
|
|
||||||
principal.AccountId = principalSerialized.AccountId;
|
|
||||||
principal.ItemId = principalSerialized.ItemId;
|
|
||||||
principal.OrganizationId = principalSerialized.OrganizationId;
|
|
||||||
principal.DisplayName = principalSerialized.DisplayName;
|
|
||||||
principal.EncryptedPassword = principalSerialized.EncryptedPassword;
|
|
||||||
|
|
||||||
HttpContext.Current.User = principal;
|
|
||||||
|
|
||||||
if (!contextWrapper.Request.IsAjaxRequest())
|
if (!contextWrapper.Request.IsAjaxRequest())
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace WebsitePanel.WebDavPortal.UI.Routes
|
||||||
|
{
|
||||||
|
public class OwaRouteNames
|
||||||
|
{
|
||||||
|
public const string CheckFileInfo = "OwaCheckFileInfoPath";
|
||||||
|
public const string GetFile = "OwaGetFilePath";
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,10 +2,11 @@
|
||||||
@using WebsitePanel.WebDav.Core.Client
|
@using WebsitePanel.WebDav.Core.Client
|
||||||
@using Ninject
|
@using Ninject
|
||||||
@using WebsitePanel.WebDav.Core.Config
|
@using WebsitePanel.WebDav.Core.Config
|
||||||
|
@using WebsitePanel.WebDav.Core.Interfaces.Managers
|
||||||
|
|
||||||
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
|
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
|
||||||
@{
|
@{
|
||||||
var webDavManager = DependencyResolver.Current.GetService<WebsitePanel.WebDavPortal.Models.IWebDavManager>();
|
var webDavManager = DependencyResolver.Current.GetService<IWebDavManager>();
|
||||||
ViewBag.Title = WebDavAppConfigManager.Instance.ApplicationName;
|
ViewBag.Title = WebDavAppConfigManager.Instance.ApplicationName;
|
||||||
}
|
}
|
||||||
@Scripts.Render("~/bundles/jquery")
|
@Scripts.Render("~/bundles/jquery")
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<add key="WebsitePanel.AltCryptoKey" value="CryptoKey" />
|
<add key="WebsitePanel.AltCryptoKey" value="CryptoKey" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<webDavExplorerConfigurationSettings>
|
<webDavExplorerConfigurationSettings>
|
||||||
<!--<userDomain value=""/>-->
|
<userDomain value="websitepanel.net" />
|
||||||
<applicationName value="WebDAV Explorer" />
|
<applicationName value="WebDAV Explorer" />
|
||||||
<authTimeoutCookieName value=".auth-logout-timeout" />
|
<authTimeoutCookieName value=".auth-logout-timeout" />
|
||||||
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config" />
|
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config" />
|
||||||
|
@ -58,13 +58,13 @@
|
||||||
<add extension=".xlsx" path="~/Content/Images/excel-icon.png" />
|
<add extension=".xlsx" path="~/Content/Images/excel-icon.png" />
|
||||||
<add extension=".png" path="~/Content/Images/png-icon.png" />
|
<add extension=".png" path="~/Content/Images/png-icon.png" />
|
||||||
</fileIcons>
|
</fileIcons>
|
||||||
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net/op/view.aspx">
|
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net">
|
||||||
<add extension=".doc" />
|
<add extension=".doc" owaOpener="wv/wordviewerframe.aspx" />
|
||||||
<add extension=".docx" />
|
<add extension=".docx" owaOpener="wv/wordviewerframe.aspx" />
|
||||||
<add extension=".xls" />
|
<add extension=".xls" owaOpener="x/_layouts/xlviewerinternal.aspx" />
|
||||||
<add extension=".xlsx" />
|
<add extension=".xlsx" owaOpener="x/_layouts/xlviewerinternal.aspx" />
|
||||||
<add extension=".ppt" />
|
<add extension=".ppt" owaOpener="p/PowerPointFrame.aspx" />
|
||||||
<add extension=".pptx" />
|
<add extension=".pptx" owaOpener="p/PowerPointFrame.aspx" />
|
||||||
</officeOnline>
|
</officeOnline>
|
||||||
</webDavExplorerConfigurationSettings>
|
</webDavExplorerConfigurationSettings>
|
||||||
<!--
|
<!--
|
||||||
|
@ -76,6 +76,7 @@
|
||||||
</system.Web>
|
</system.Web>
|
||||||
-->
|
-->
|
||||||
<system.web>
|
<system.web>
|
||||||
|
<!--<identity impersonate="true"/>-->
|
||||||
<compilation debug="true" targetFramework="4.5" />
|
<compilation debug="true" targetFramework="4.5" />
|
||||||
<!-- Maximum size of uploaded file, in MB -->
|
<!-- Maximum size of uploaded file, in MB -->
|
||||||
<httpRuntime executionTimeout="1800" requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="16384" enableVersionHeader="false" />
|
<httpRuntime executionTimeout="1800" requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="16384" enableVersionHeader="false" />
|
||||||
|
@ -83,11 +84,8 @@
|
||||||
<!--
|
<!--
|
||||||
ASMX is mapped to a new handler so that proxy javascripts can also be served.
|
ASMX is mapped to a new handler so that proxy javascripts can also be served.
|
||||||
-->
|
-->
|
||||||
<httpHandlers>
|
|
||||||
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
|
|
||||||
</httpHandlers>
|
|
||||||
<authentication mode="Forms">
|
<authentication mode="Forms">
|
||||||
<forms name=".WEBSITEPANELWEBDAVPORTALAUTHASPX" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="" enableCrossAppRedirects="false"></forms>
|
<forms name=".WEBSITEPANELWEBDAVPORTALAUTHASPX" protection="All" timeout="20" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="" enableCrossAppRedirects="false"></forms>
|
||||||
</authentication>
|
</authentication>
|
||||||
<authorization>
|
<authorization>
|
||||||
<allow users="?" />
|
<allow users="?" />
|
||||||
|
@ -104,6 +102,9 @@
|
||||||
<modules>
|
<modules>
|
||||||
<add name="SecureSession" type="WebsitePanel.WebPortal.SecureSessionModule" />
|
<add name="SecureSession" type="WebsitePanel.WebPortal.SecureSessionModule" />
|
||||||
</modules>
|
</modules>
|
||||||
|
<security>
|
||||||
|
<requestFiltering allowDoubleEscaping="true" />
|
||||||
|
</security>
|
||||||
</system.webServer>
|
</system.webServer>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
|
|
@ -144,13 +144,12 @@
|
||||||
<Compile Include="Controllers\AccountController.cs" />
|
<Compile Include="Controllers\AccountController.cs" />
|
||||||
<Compile Include="Controllers\ErrorController.cs" />
|
<Compile Include="Controllers\ErrorController.cs" />
|
||||||
<Compile Include="Controllers\FileSystemController.cs" />
|
<Compile Include="Controllers\FileSystemController.cs" />
|
||||||
|
<Compile Include="Controllers\OwaController.cs" />
|
||||||
<Compile Include="CustomAttributes\LdapAuthorizationAttribute.cs" />
|
<Compile Include="CustomAttributes\LdapAuthorizationAttribute.cs" />
|
||||||
<Compile Include="DependencyInjection\NinjectDependecyResolver.cs" />
|
<Compile Include="DependencyInjection\NinjectDependecyResolver.cs" />
|
||||||
<Compile Include="DependencyInjection\PortalDependencies.cs" />
|
<Compile Include="DependencyInjection\PortalDependencies.cs" />
|
||||||
<Compile Include="DependencyInjection\Providers\HttpSessionStateProvider.cs" />
|
<Compile Include="DependencyInjection\Providers\HttpSessionStateProvider.cs" />
|
||||||
<Compile Include="DependencyInjection\Providers\WebDavManagerProvider.cs" />
|
<Compile Include="DependencyInjection\Providers\WebDavManagerProvider.cs" />
|
||||||
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
|
||||||
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
|
||||||
<Compile Include="Extensions\DictionaryExtensions.cs" />
|
<Compile Include="Extensions\DictionaryExtensions.cs" />
|
||||||
<Compile Include="Extensions\UriExtensions.cs" />
|
<Compile Include="Extensions\UriExtensions.cs" />
|
||||||
<Compile Include="FileOperations\FileOpenerManager.cs" />
|
<Compile Include="FileOperations\FileOpenerManager.cs" />
|
||||||
|
@ -162,13 +161,12 @@
|
||||||
<Compile Include="Models\AccountModel.cs" />
|
<Compile Include="Models\AccountModel.cs" />
|
||||||
<Compile Include="Models\DirectoryIdentity.cs" />
|
<Compile Include="Models\DirectoryIdentity.cs" />
|
||||||
<Compile Include="Models\ErrorModel.cs" />
|
<Compile Include="Models\ErrorModel.cs" />
|
||||||
<Compile Include="Models\IWebDavManager.cs" />
|
|
||||||
<Compile Include="Models\ModelForWebDav.cs" />
|
<Compile Include="Models\ModelForWebDav.cs" />
|
||||||
<Compile Include="Models\OfficeOnlineModel.cs" />
|
<Compile Include="Models\OfficeOnlineModel.cs" />
|
||||||
<Compile Include="Models\WebDavManager.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="UI\Routes\AccountRouteNames.cs" />
|
<Compile Include="UI\Routes\AccountRouteNames.cs" />
|
||||||
<Compile Include="UI\Routes\FileSystemRouteNames.cs" />
|
<Compile Include="UI\Routes\FileSystemRouteNames.cs" />
|
||||||
|
<Compile Include="UI\Routes\OwaRouteNames.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Content\bootstrap-theme.css" />
|
<Content Include="Content\bootstrap-theme.css" />
|
||||||
|
@ -261,7 +259,9 @@
|
||||||
<Content Include="Views\FileSystem\_ResourseCollectionPartial.cshtml" />
|
<Content Include="Views\FileSystem\_ResourseCollectionPartial.cshtml" />
|
||||||
<Content Include="Views\FileSystem\_ResoursePartial.cshtml" />
|
<Content Include="Views\FileSystem\_ResoursePartial.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="Views\Owa\" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="packages.config" />
|
<Content Include="packages.config" />
|
||||||
<None Include="Project_Readme.html" />
|
<None Include="Project_Readme.html" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue