Merge
This commit is contained in:
commit
63395fbc7d
27 changed files with 311 additions and 73 deletions
|
@ -59,7 +59,10 @@ namespace WebsitePanel.WebDav.Core
|
|||
{
|
||||
get
|
||||
{
|
||||
string displayName = _href.AbsoluteUri.Replace(_baseUri.AbsoluteUri, "");
|
||||
var href = HttpUtility.UrlDecode(_href.AbsoluteUri);
|
||||
var baseUri = HttpUtility.UrlDecode(_baseUri.AbsoluteUri);
|
||||
|
||||
string displayName = href.Replace(baseUri, "");
|
||||
displayName = Regex.Replace(displayName, "\\/$", "");
|
||||
Match displayNameMatch = Regex.Match(displayName, "([\\/]+)$");
|
||||
if (displayNameMatch.Success)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal
|
||||
{
|
||||
|
@ -9,6 +10,22 @@ namespace WebsitePanel.WebDavPortal
|
|||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
#region Account
|
||||
|
||||
routes.MapRoute(
|
||||
name: AccountRouteNames.Logout,
|
||||
url: "account/logout",
|
||||
defaults: new { controller = "Account", action = "Logout" }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: AccountRouteNames.Login,
|
||||
url: "account/login",
|
||||
defaults: new { controller = "Account", action = "Login" }
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
routes.MapRoute(
|
||||
name: "Office365DocumentRoute",
|
||||
url: "office365/{org}/{*pathPart}",
|
||||
|
@ -16,7 +33,7 @@ namespace WebsitePanel.WebDavPortal
|
|||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: "FilePathRoute",
|
||||
name: FileSystemRouteNames.FilePath,
|
||||
url: "{org}/{*pathPart}",
|
||||
defaults: new { controller = "FileSystem", action = "ShowContent", pathPart = UrlParameter.Optional },
|
||||
constraints: new { org = new WebsitePanel.WebDavPortal.Constraints.OrganizationRouteConstraint() }
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
{
|
||||
public class ElementsRendering : AbstractConfigCollection
|
||||
{
|
||||
public int DefaultCount { get; private set; }
|
||||
public int AddElementsCount { get; private set; }
|
||||
public List<string> ElementsToIgnore { get; private set; }
|
||||
|
||||
public ElementsRendering()
|
||||
{
|
||||
DefaultCount = ConfigSection.ElementsRendering.DefaultCount;
|
||||
AddElementsCount = ConfigSection.ElementsRendering.AddElementsCount;
|
||||
ElementsToIgnore = ConfigSection.ElementsRendering.ElementsToIgnore.Split(',').ToList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
|
@ -16,6 +17,8 @@ namespace WebsitePanel.WebDavPortal.Constraints
|
|||
|
||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
|
||||
{
|
||||
var webdavManager = DependencyResolver.Current.GetService<IWebDavManager>();
|
||||
|
||||
object value;
|
||||
if (!values.TryGetValue(parameterName, out value))
|
||||
return false;
|
||||
|
@ -30,9 +33,7 @@ namespace WebsitePanel.WebDavPortal.Constraints
|
|||
if (httpContext.Session == null)
|
||||
return false;
|
||||
|
||||
IKernel kernel = new StandardKernel(new WebDavExplorerAppModule());
|
||||
var webDavManager = kernel.Get<IWebDavManager>();
|
||||
if (webDavManager != null && str == webDavManager.OrganizationName)
|
||||
if (webdavManager != null && str == webdavManager.OrganizationName)
|
||||
{
|
||||
actualOrgName = str;
|
||||
return true;
|
||||
|
|
|
@ -32,4 +32,17 @@ textarea {
|
|||
color: red;
|
||||
font-weight: bold;
|
||||
padding-top: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
#username {
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
#logout {
|
||||
font-size: 1.2em;
|
||||
color: #9d9d9d;
|
||||
}
|
||||
|
||||
#logout :hover {
|
||||
color: white;
|
||||
}
|
|
@ -22,18 +22,27 @@ using WebsitePanel.WebDavPortal.Models;
|
|||
using System.Collections.Generic;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using WebDAV;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Controllers
|
||||
{
|
||||
public class AccountController : Controller
|
||||
{
|
||||
private readonly IKernel _kernel = new StandardKernel(new NinjectSettings {AllowNullInjection = true}, new WebDavExplorerAppModule());
|
||||
private readonly AccountModel _accountModel;
|
||||
private readonly IWebDavManager _webdavManager;
|
||||
private readonly ICryptography _cryptography;
|
||||
|
||||
public AccountController(AccountModel accountModel, IWebDavManager webdavManager, ICryptography cryptography)
|
||||
{
|
||||
_accountModel = accountModel;
|
||||
_webdavManager = webdavManager;
|
||||
_cryptography = cryptography;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Login()
|
||||
{
|
||||
object isAuthentication = _kernel.Get<AccountModel>();
|
||||
if (isAuthentication != null)
|
||||
if (_accountModel != null)
|
||||
return RedirectToAction("ShowContent", "FileSystem");
|
||||
return View();
|
||||
}
|
||||
|
@ -50,32 +59,53 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
if (isAuthenticated)
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ItemId] = exchangeAccount.ItemId;
|
||||
|
||||
|
||||
model.Groups = ES.Services.Organizations.GetSecurityGroupsByMember(exchangeAccount.ItemId, exchangeAccount.AccountId);
|
||||
model.DisplayName = exchangeAccount.DisplayName;
|
||||
|
||||
WebDavManager manager = null;
|
||||
|
||||
try
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = model;
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = new WebDavManager(new NetworkCredential(model.Login, model.Password, WebDavAppConfigManager.Instance.UserDomain), exchangeAccount.ItemId);
|
||||
|
||||
manager = new WebDavManager(new NetworkCredential(model.Login, model.Password, WebDavAppConfigManager.Instance.UserDomain), exchangeAccount.ItemId);
|
||||
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = manager;
|
||||
}
|
||||
catch (ConnectToWebDavServerException exception)
|
||||
{
|
||||
return View(new AccountModel { LdapError = exception.Message });
|
||||
}
|
||||
return RedirectToAction("ShowContent", "FileSystem", new { org = _kernel.Get<IWebDavManager>().OrganizationName });
|
||||
|
||||
return RedirectToAction("ShowContent", "FileSystem", new { org = manager.OrganizationName });
|
||||
}
|
||||
return View(new AccountModel { LdapError = "The user name or password is incorrect" });
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Logout()
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = null;
|
||||
|
||||
return RedirectToRoute(AccountRouteNames.Login);
|
||||
}
|
||||
|
||||
private void AutheticationToServicesUsingWebsitePanelUser()
|
||||
{
|
||||
var crypto = _kernel.Get<ICryptography>();
|
||||
var websitePanelLogin = WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Login;
|
||||
var websitePanelPassword = crypto.Decrypt(WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Password);
|
||||
var websitePanelPassword = _cryptography.Decrypt(WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Password);
|
||||
|
||||
var authTicket = new FormsAuthenticationTicket(1, websitePanelLogin, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout),
|
||||
FormsAuthentication.SlidingExpiration, websitePanelPassword + Environment.NewLine);
|
||||
var encryptedTicket = FormsAuthentication.Encrypt(authTicket);
|
||||
var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
|
||||
|
||||
if (FormsAuthentication.SlidingExpiration)
|
||||
{
|
||||
authCookie.Expires = authTicket.Expiration;
|
||||
}
|
||||
|
||||
Response.Cookies.Add(authCookie);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,26 +22,31 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
[LdapAuthorization]
|
||||
public class FileSystemController : Controller
|
||||
{
|
||||
private readonly IKernel _kernel = new StandardKernel(new WebDavExplorerAppModule());
|
||||
private readonly IWebDavManager _webdavManager;
|
||||
|
||||
public FileSystemController(IWebDavManager webdavManager)
|
||||
{
|
||||
_webdavManager = webdavManager;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult ShowContent(string org, string pathPart = "")
|
||||
{
|
||||
var webDavManager = new StandardKernel(new WebDavExplorerAppModule()).Get<IWebDavManager>();
|
||||
if (org != webDavManager.OrganizationName)
|
||||
if (org != _webdavManager.OrganizationName)
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||
|
||||
string fileName = pathPart.Split('/').Last();
|
||||
if (webDavManager.IsFile(fileName))
|
||||
if (_webdavManager.IsFile(fileName))
|
||||
{
|
||||
var fileBytes = webDavManager.GetFileBytes(fileName);
|
||||
var fileBytes = _webdavManager.GetFileBytes(fileName);
|
||||
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
webDavManager.OpenFolder(pathPart);
|
||||
IEnumerable<IHierarchyItem> children = webDavManager.GetChildren();
|
||||
_webdavManager.OpenFolder(pathPart);
|
||||
IEnumerable<IHierarchyItem> children = _webdavManager.GetChildren().Where(x => !WebDavAppConfigManager.Instance.ElementsRendering.ElementsToIgnore.Contains(x.DisplayName.Trim('/')));
|
||||
|
||||
var model = new ModelForWebDav { Items = children.Take(WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount), UrlSuffix = pathPart };
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] = WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount;
|
||||
|
||||
|
@ -55,8 +60,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart = "")
|
||||
{
|
||||
var webDavManager = _kernel.Get<IWebDavManager>();
|
||||
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();
|
||||
|
||||
return View(new OfficeOnlineModel(uri, new Uri(fileUrl).Segments.Last()));
|
||||
|
@ -68,9 +72,11 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
if (Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] != null)
|
||||
{
|
||||
var renderedElementsCount = (int)Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount];
|
||||
var webDavManager = _kernel.Get<IWebDavManager>();
|
||||
IEnumerable<IHierarchyItem> children = webDavManager.GetChildren();
|
||||
|
||||
IEnumerable<IHierarchyItem> children = _webdavManager.GetChildren();
|
||||
|
||||
var result = children.Skip(renderedElementsCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount);
|
||||
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] = renderedElementsCount + WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount;
|
||||
|
||||
return PartialView("_ResourseCollectionPartial", result);
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Web.Routing;
|
|||
using Ninject;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.CustomAttributes
|
||||
{
|
||||
|
@ -11,16 +12,19 @@ namespace WebsitePanel.WebDavPortal.CustomAttributes
|
|||
{
|
||||
protected override bool AuthorizeCore(HttpContextBase httpContext)
|
||||
{
|
||||
IKernel kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule());
|
||||
var accountInfo = kernel.Get<AccountModel>();
|
||||
var accountInfo = DependencyResolver.Current.GetService<AccountModel>();
|
||||
|
||||
if (accountInfo == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
|
||||
{
|
||||
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Account", action = "Login" }));
|
||||
filterContext.Result = new RedirectToRouteResult(AccountRouteNames.Login, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using Ninject;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||
{
|
||||
public class NinjectDependecyResolver : IDependencyResolver
|
||||
{
|
||||
IKernel kernal;
|
||||
|
||||
public NinjectDependecyResolver()
|
||||
{
|
||||
kernal = new StandardKernel(new NinjectSettings { AllowNullInjection = true });
|
||||
AddBindings();
|
||||
}
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return kernal.TryGet(serviceType);
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetServices(Type serviceType)
|
||||
{
|
||||
return kernal.GetAll(serviceType);
|
||||
}
|
||||
|
||||
private void AddBindings()
|
||||
{
|
||||
PortalDependencies.Configure(kernal);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using Ninject;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.SessionState;
|
||||
using WebsitePanel.WebDavPortal.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection.Providers;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||
{
|
||||
public class PortalDependencies
|
||||
{
|
||||
public static void Configure(IKernel kernerl)
|
||||
{
|
||||
kernerl.Bind<HttpSessionState>().ToProvider<HttpSessionStateProvider>();
|
||||
kernerl.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
||||
kernerl.Bind<AccountModel>().ToProvider<AccountInfoProvider>();
|
||||
kernerl.Bind<ICryptography>().To<CryptoUtils>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Ninject.Activation;
|
|||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
||||
{
|
||||
public class AccountInfoProvider : Provider<AccountModel>
|
||||
{
|
||||
|
@ -12,7 +12,13 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
|
|||
{
|
||||
var session = context.Kernel.Get<HttpSessionState>();
|
||||
|
||||
var accountInfo = session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] as AccountModel;
|
||||
AccountModel accountInfo = null;
|
||||
|
||||
if (session != null)
|
||||
{
|
||||
accountInfo = session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] as AccountModel;
|
||||
}
|
||||
|
||||
return accountInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using Ninject.Activation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.SessionState;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
||||
{
|
||||
public class HttpSessionStateProvider : Provider<HttpSessionState>
|
||||
{
|
||||
protected override HttpSessionState CreateInstance(IContext context)
|
||||
{
|
||||
return HttpContext.Current.Session;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Ninject.Activation;
|
|||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
||||
{
|
||||
public class WebDavManagerProvider : Provider<WebDavManager>
|
||||
{
|
||||
|
@ -12,7 +12,13 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
|
|||
{
|
||||
var session = context.Kernel.Get<HttpSessionState>();
|
||||
|
||||
var webDavManager = session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] as WebDavManager;
|
||||
WebDavManager webDavManager = null;
|
||||
|
||||
if (session != null)
|
||||
{
|
||||
webDavManager = session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] as WebDavManager;
|
||||
}
|
||||
|
||||
return webDavManager;
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
using System.Web;
|
||||
using System.Web.SessionState;
|
||||
using Ninject.Modules;
|
||||
using WebsitePanel.WebDavPortal.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||
{
|
||||
public class WebDavExplorerAppModule : NinjectModule
|
||||
{
|
||||
public override void Load()
|
||||
{
|
||||
Bind<HttpSessionState>().ToConstant(HttpContext.Current.Session);
|
||||
Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
||||
Bind<AccountModel>().ToProvider<AccountInfoProvider>();
|
||||
Bind<ICryptography>().To<CryptoUtils>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.Web.Mvc;
|
|||
using System.Web.Optimization;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDavPortal.Controllers;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal
|
||||
{
|
||||
|
@ -15,6 +16,10 @@ namespace WebsitePanel.WebDavPortal
|
|||
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
|
||||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||||
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
||||
|
||||
DependencyResolver.SetResolver(new NinjectDependecyResolver());
|
||||
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
}
|
||||
|
||||
protected void Application_Error(object sender, EventArgs e)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Models
|
||||
{
|
||||
|
@ -21,6 +23,10 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
}
|
||||
}
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public IEnumerable<ExchangeAccount> Groups { get; set; }
|
||||
|
||||
public string LdapError { get; set; }
|
||||
}
|
||||
}
|
|
@ -11,12 +11,18 @@ using WebsitePanel.Portal;
|
|||
using WebsitePanel.Providers.OS;
|
||||
using Ninject;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
using System.Web.Mvc;
|
||||
using log4net;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Models
|
||||
{
|
||||
public class WebDavManager : IWebDavManager
|
||||
{
|
||||
private readonly WebDavSession _webDavSession = new WebDavSession();
|
||||
|
||||
private readonly AccountModel _accountModel;
|
||||
private readonly ILog Log;
|
||||
|
||||
private IList<SystemFile> _rootFolders;
|
||||
private int _itemId;
|
||||
private IFolder _currentFolder;
|
||||
|
@ -36,11 +42,12 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
|
||||
public WebDavManager(NetworkCredential credential, int itemId)
|
||||
{
|
||||
_accountModel = DependencyResolver.Current.GetService<AccountModel>();
|
||||
Log = LogManager.GetLogger(this.GetType());
|
||||
|
||||
_webDavSession.Credentials = credential;
|
||||
_itemId = itemId;
|
||||
IKernel _kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule());
|
||||
var accountModel = _kernel.Get<AccountModel>();
|
||||
_rootFolders = ConnectToWebDavServer(accountModel.UserName);
|
||||
_rootFolders = ConnectToWebDavServer(_accountModel);
|
||||
|
||||
if (_rootFolders.Any())
|
||||
{
|
||||
|
@ -126,14 +133,24 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
}
|
||||
}
|
||||
|
||||
private IList<SystemFile> ConnectToWebDavServer(string userName)
|
||||
private IList<SystemFile> ConnectToWebDavServer(AccountModel user)
|
||||
{
|
||||
var rootFolders = new List<SystemFile>();
|
||||
|
||||
foreach (var folder in ES.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
||||
{
|
||||
var permissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
||||
if (permissions.Any(x => x.DisplayName == userName))
|
||||
rootFolders.Add(folder);
|
||||
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
if ((!permission.IsGroup
|
||||
&& (permission.DisplayName == user.UserName || permission.DisplayName == user.DisplayName))
|
||||
|| (permission.IsGroup && user.Groups.Any(x=> x.DisplayName == permission.DisplayName)))
|
||||
{
|
||||
rootFolders.Add(folder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rootFolders;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ function GetResources() {
|
|||
GetResources();
|
||||
oldResourcesDivHeight = $('#resourcesDiv').height();
|
||||
};
|
||||
|
||||
recalculateResourseHeight();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.UI.Routes
|
||||
{
|
||||
public class AccountRouteNames
|
||||
{
|
||||
public const string Logout = "AccountLogout";
|
||||
public const string Login = "AccountLogin";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.UI.Routes
|
||||
{
|
||||
public class FileSystemRouteNames
|
||||
{
|
||||
public const string FilePath = "FilePathRoute";
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
@using Ninject
|
||||
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
|
||||
@{
|
||||
var webDavManager = (new StandardKernel(new WebsitePanel.WebDavPortal.DependencyInjection.WebDavExplorerAppModule())).Get<WebsitePanel.WebDavPortal.Models.IWebDavManager>();
|
||||
var webDavManager = DependencyResolver.Current.GetService<WebsitePanel.WebDavPortal.Models.IWebDavManager>();
|
||||
ViewBag.Title = (string.IsNullOrEmpty(Model.UrlSuffix) ? webDavManager.OrganizationName : Model.UrlSuffix);
|
||||
}
|
||||
@Scripts.Render("~/bundles/jquery")
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
break;
|
||||
default:
|
||||
isTargetBlank = false;
|
||||
IKernel _kernel = new StandardKernel(new WebsitePanel.WebDavPortal.DependencyInjection.WebDavExplorerAppModule());
|
||||
var webDavManager = _kernel.Get<WebsitePanel.WebDavPortal.Models.IWebDavManager>();
|
||||
var webDavManager = DependencyResolver.Current.GetService<WebsitePanel.WebDavPortal.Models.IWebDavManager>();
|
||||
href = Model.Href.AbsolutePath;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
@using WebsitePanel.WebDavPortal.Config
|
||||
@using WebsitePanel.WebDavPortal.DependencyInjection
|
||||
@using WebsitePanel.WebDavPortal.Models
|
||||
@using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
@{
|
||||
var account = DependencyResolver.Current.GetService<AccountModel>();
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -20,17 +26,16 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
@Html.ActionLink(WebDavAppConfigManager.Instance.ApplicationName, "Login", "Account", new { area = "" }, new { @class = "navbar-brand" })
|
||||
@Html.RouteLink(WebDavAppConfigManager.Instance.ApplicationName, FileSystemRouteNames.FilePath, new { pathPart = string.Empty }, new { @class = "navbar-brand" })
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
@{
|
||||
IKernel kernel = new StandardKernel(new NinjectSettings { AllowNullInjection = true }, new WebDavExplorerAppModule());
|
||||
var account = kernel.Get<AccountModel>();
|
||||
if (account != null)
|
||||
{
|
||||
<h4 class="nav navbar-text navbar-right">@account.UserName</h4>
|
||||
<a id="logout" class="nav navbar-text navbar-right" href="@Url.RouteUrl(AccountRouteNames.Logout)" title="Log out"><i class="glyphicon glyphicon-log-out"></i></a>
|
||||
<h4 id="username" class="nav navbar-text navbar-right">@account.Login</h4>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
For more information on how to configure your ASP.NET application, please visit
|
||||
http://go.microsoft.com/fwlink/?LinkId=301880
|
||||
-->
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="webDavExplorerConfigurationSettings" type="WebsitePanel.WebDavPortal.WebConfigSections.WebDavExplorerConfigurationSettingsSection" allowLocation="true" allowDefinition="Everywhere"/>
|
||||
<section name="webDavExplorerConfigurationSettings" type="WebsitePanel.WebDavPortal.WebConfigSections.WebDavExplorerConfigurationSettingsSection" allowLocation="true" allowDefinition="Everywhere" />
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
</configSections>
|
||||
<log4net>
|
||||
<appender name="FileAppender" type="log4net.Appender.FileAppender">
|
||||
<param name="File" value="Logs\log-debug.log" />
|
||||
<param name="AppendToFile" value="true" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d %-5p %c - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="FileAppender" />
|
||||
</root>
|
||||
</log4net>
|
||||
|
||||
<appSettings>
|
||||
<add key="webpages:Version" value="3.0.0.0"/>
|
||||
<add key="webpages:Enabled" value="false"/>
|
||||
|
@ -24,7 +39,7 @@
|
|||
<webDavExplorerConfigurationSettings>
|
||||
<!--<userDomain value=""/>-->
|
||||
<applicationName value="WebDAV Explorer"/>
|
||||
<elementsRendering defaultCount="20" addElementsCount="20"/>
|
||||
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config"/>
|
||||
<websitePanelConstantUser login="serveradmin" password="HtR7J8dtBhovYLigXNtVutxqpvaE48Z+FBIokWZlR/g=" />
|
||||
<sessionKeys>
|
||||
<add key="AccountInfoSessionKey" value="AccountInfo"/>
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
{
|
||||
private const string DefaultCountKey = "defaultCount";
|
||||
private const string AddElementsCountKey = "addElementsCount";
|
||||
private const string ElementsToIgnoreKey = "elementsToIgnoreKey";
|
||||
|
||||
[ConfigurationProperty(DefaultCountKey, IsKey = true, IsRequired = true, DefaultValue = 30)]
|
||||
public int DefaultCount
|
||||
|
@ -20,5 +21,12 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
get { return (int)this[AddElementsCountKey]; }
|
||||
set { this[AddElementsCountKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ElementsToIgnoreKey, IsKey = true, IsRequired = true, DefaultValue = "")]
|
||||
public string ElementsToIgnore
|
||||
{
|
||||
get { return (string)this[ElementsToIgnoreKey]; }
|
||||
set { this[ElementsToIgnoreKey] = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,6 +48,9 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Web.Services3">
|
||||
<HintPath>..\..\Lib\Microsoft.Web.Services3.dll</HintPath>
|
||||
|
@ -158,9 +161,11 @@
|
|||
<Compile Include="Cryptography\CryptoUtils.cs" />
|
||||
<Compile Include="Cryptography\ICryptography.cs" />
|
||||
<Compile Include="CustomAttributes\LdapAuthorizationAttribute.cs" />
|
||||
<Compile Include="DependencyInjection\AccountInfoProvider.cs" />
|
||||
<Compile Include="DependencyInjection\WebDavExplorerAppModule.cs" />
|
||||
<Compile Include="DependencyInjection\WebDavManagerProvider.cs" />
|
||||
<Compile Include="DependencyInjection\Providers\AccountInfoProvider.cs" />
|
||||
<Compile Include="DependencyInjection\NinjectDependecyResolver.cs" />
|
||||
<Compile Include="DependencyInjection\PortalDependencies.cs" />
|
||||
<Compile Include="DependencyInjection\Providers\HttpSessionStateProvider.cs" />
|
||||
<Compile Include="DependencyInjection\Providers\WebDavManagerProvider.cs" />
|
||||
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
||||
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
||||
<Compile Include="Extensions\DictionaryExtensions.cs" />
|
||||
|
@ -179,6 +184,8 @@
|
|||
<Compile Include="Models\OfficeOnlineModel.cs" />
|
||||
<Compile Include="Models\WebDavManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI\Routes\AccountRouteNames.cs" />
|
||||
<Compile Include="UI\Routes\FileSystemRouteNames.cs" />
|
||||
<Compile Include="WebConfigSections\ApplicationNameElement.cs" />
|
||||
<Compile Include="WebConfigSections\ElementsRenderingElement.cs" />
|
||||
<Compile Include="WebConfigSections\FileIconsElement.cs" />
|
||||
|
@ -289,6 +296,7 @@
|
|||
<Content Include="App_GlobalResources\Resource.errors.resx">
|
||||
<Generator>GlobalResourceProxyGenerator</Generator>
|
||||
<LastGenOutput>Resource.errors.designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<package id="bootstrap" version="3.3.0" targetFramework="net45" />
|
||||
<package id="jQuery" version="2.1.1" targetFramework="net45" />
|
||||
<package id="jQuery.Validation" version="1.13.1" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.0" 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.Web.Optimization" version="1.1.3" targetFramework="net45" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue