This commit is contained in:
vfedosevich 2015-01-20 00:39:19 -08:00
commit bfd17a48c1
44 changed files with 1688 additions and 1387 deletions

View file

@ -7634,3 +7634,116 @@ COMMIT TRAN
RETURN
GO
-- WebDAv portal
IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'WebDavAccessTokens')
DROP TABLE WebDavAccessTokens
GO
CREATE TABLE WebDavAccessTokens
(
ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
FilePath NVARCHAR(MAX) NOT NULL,
AuthData NVARCHAR(MAX) NOT NULL,
AccessToken UNIQUEIDENTIFIER NOT NULL,
ExpirationDate DATETIME NOT NULL,
AccountID INT NOT NULL ,
ItemId INT NOT NULL
)
GO
ALTER TABLE [dbo].[WebDavAccessTokens] WITH CHECK ADD CONSTRAINT [FK_WebDavAccessTokens_UserId] FOREIGN KEY([AccountID])
REFERENCES [dbo].[ExchangeAccounts] ([AccountID])
ON DELETE CASCADE
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddWebDavAccessToken')
DROP PROCEDURE AddWebDavAccessToken
GO
CREATE PROCEDURE [dbo].[AddWebDavAccessToken]
(
@TokenID INT OUTPUT,
@FilePath NVARCHAR(MAX),
@AccessToken UNIQUEIDENTIFIER,
@AuthData NVARCHAR(MAX),
@ExpirationDate DATETIME,
@AccountID INT,
@ItemId INT
)
AS
INSERT INTO WebDavAccessTokens
(
FilePath,
AccessToken,
AuthData,
ExpirationDate,
AccountID ,
ItemId
)
VALUES
(
@FilePath ,
@AccessToken ,
@AuthData,
@ExpirationDate ,
@AccountID,
@ItemId
)
SET @TokenID = SCOPE_IDENTITY()
RETURN
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteExpiredWebDavAccessTokens')
DROP PROCEDURE DeleteExpiredWebDavAccessTokens
GO
CREATE PROCEDURE [dbo].[DeleteExpiredWebDavAccessTokens]
AS
DELETE FROM WebDavAccessTokens
WHERE ExpirationDate < getdate()
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetWebDavAccessTokenById')
DROP PROCEDURE GetWebDavAccessTokenById
GO
CREATE PROCEDURE [dbo].[GetWebDavAccessTokenById]
(
@Id int
)
AS
SELECT
ID ,
FilePath ,
AuthData ,
AccessToken,
ExpirationDate,
AccountID,
ItemId
FROM WebDavAccessTokens
Where ID = @Id AND ExpirationDate > getdate()
GO
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetWebDavAccessTokenByAccessToken')
DROP PROCEDURE GetWebDavAccessTokenByAccessToken
GO
CREATE PROCEDURE [dbo].[GetWebDavAccessTokenByAccessToken]
(
@AccessToken UNIQUEIDENTIFIER
)
AS
SELECT
ID ,
FilePath ,
AuthData ,
AccessToken,
ExpirationDate,
AccountID,
ItemId
FROM WebDavAccessTokens
Where AccessToken = @AccessToken AND ExpirationDate > getdate()
GO

View file

@ -0,0 +1,15 @@
using System;
namespace WebsitePanel.EnterpriseServer.Base.HostedSolution
{
public class WebDavAccessToken
{
public int Id { get; set; }
public string FilePath { get; set; }
public string AuthData { get; set; }
public Guid AccessToken { get; set; }
public DateTime ExpirationDate { get; set; }
public int AccountId { get; set; }
public int ItemId { get; set; }
}
}

View file

@ -120,6 +120,7 @@
<Compile Include="HostedSolution\ServiceLevel.cs" />
<Compile Include="HostedSolution\CRMLycenseTypes.cs" />
<Compile Include="HostedSolution\ESPermission.cs" />
<Compile Include="HostedSolution\WebDavAccessToken.cs" />
<Compile Include="Log\LogRecord.cs" />
<Compile Include="Packages\ServiceLevelQuotaValueInfo.cs" />
<Compile Include="Packages\HostingPlanContext.cs" />

View file

@ -4330,6 +4330,57 @@ namespace WebsitePanel.EnterpriseServer
#region Enterprise Storage
public static int AddWebDavAccessToken(Base.HostedSolution.WebDavAccessToken accessToken)
{
SqlParameter prmId = new SqlParameter("@TokenID", SqlDbType.Int);
prmId.Direction = ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"AddWebDavAccessToken",
prmId,
new SqlParameter("@AccessToken", accessToken.AccessToken),
new SqlParameter("@FilePath", accessToken.FilePath),
new SqlParameter("@AuthData", accessToken.AuthData),
new SqlParameter("@ExpirationDate", accessToken.ExpirationDate),
new SqlParameter("@AccountID", accessToken.AccountId),
new SqlParameter("@ItemId", accessToken.ItemId)
);
// read identity
return Convert.ToInt32(prmId.Value);
}
public static void DeleteExpiredWebDavAccessTokens()
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"DeleteExpiredWebDavAccessTokens"
);
}
public static IDataReader GetWebDavAccessTokenById(int id)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetWebDavAccessTokenById",
new SqlParameter("@Id", id)
);
}
public static IDataReader GetWebDavAccessTokenByAccessToken(Guid accessToken)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetWebDavAccessTokenByAccessToken",
new SqlParameter("@AccessToken", accessToken)
);
}
public static int AddEntepriseFolder(int itemId, string folderName, int folderQuota, string locationDrive, string homeFolder, string domain)
{
SqlParameter prmId = new SqlParameter("@FolderID", SqlDbType.Int);

View file

@ -152,6 +152,26 @@ namespace WebsitePanel.EnterpriseServer
StartESBackgroundTaskInternal("SET_ENTERPRISE_FOLDER_SETTINGS", itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType);
}
public static int AddWebDavAccessToken(WebDavAccessToken accessToken)
{
return DataProvider.AddWebDavAccessToken(accessToken);
}
public static void DeleteExpiredWebDavAccessTokens()
{
DataProvider.DeleteExpiredWebDavAccessTokens();
}
public static WebDavAccessToken GetWebDavAccessTokenById(int id)
{
return ObjectUtils.FillObjectFromDataReader<WebDavAccessToken>(DataProvider.GetWebDavAccessTokenById(id));
}
public static WebDavAccessToken GetWebDavAccessTokenByAccessToken(Guid accessToken)
{
return ObjectUtils.FillObjectFromDataReader<WebDavAccessToken>(DataProvider.GetWebDavAccessTokenByAccessToken(accessToken));
}
#region Directory Browsing
public static bool GetDirectoryBrowseEnabled(int itemId, string siteId)

View file

@ -6,21 +6,21 @@
<!-- Connection strings -->
<connectionStrings>
<!--<add name="EnterpriseServer" connectionString="Server=(local)\SQLExpress;Database=WebsitePanel;uid=sa;pwd=Password12" providerName="System.Data.SqlClient"/>-->
<add name="EnterpriseServer" connectionString="Data Source=CHERNETSI\BENQMSSERVER;Initial Catalog=WebsitePanel;uid=sa;pwd=Password12;Integrated Security=True;" providerName="System.Data.SqlClient" />
<add name="EnterpriseServer" connectionString="server=IOGAN_HOME\ALEX;database=WebsitePanel3;uid=WebsitePanel3;pwd=7j3j0daqj4dqpt22x8eb;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<!-- Encryption util settings -->
<add key="WebsitePanel.CryptoKey" value="1234567890"/>
<add key="WebsitePanel.CryptoKey" value="31alhk2jnarmrmt5ecg3" />
<!-- A1D4KDHUE83NKHddF -->
<add key="WebsitePanel.EncryptionEnabled" value="true"/>
<add key="WebsitePanel.EncryptionEnabled" value="true" />
<!-- Web Applications -->
<add key="WebsitePanel.EnterpriseServer.WebApplicationsPath" value="~/WebApplications"/>
<add key="WebsitePanel.EnterpriseServer.WebApplicationsPath" value="~/WebApplications" />
<!-- Communication settings -->
<!-- Maximum waiting time when sending request to the remote server
The value is in seconds. "-1" - infinite. -->
<add key="WebsitePanel.EnterpriseServer.ServerRequestTimeout" value="3600"/>
<add key="WebsitePanel.AltConnectionString" value="ConnectionString"/>
<add key="WebsitePanel.AltCryptoKey" value="CryptoKey"/>
<add key="WebsitePanel.EnterpriseServer.ServerRequestTimeout" value="3600" />
<add key="WebsitePanel.AltConnectionString" value="ConnectionString" />
<add key="WebsitePanel.AltCryptoKey" value="CryptoKey" />
</appSettings>
<system.web>
<!-- Disable any authentication -->

View file

@ -56,6 +56,29 @@ namespace WebsitePanel.EnterpriseServer
[ToolboxItem(false)]
public class esEnterpriseStorage : WebService
{
[WebMethod]
public int AddWebDavAccessToken(WebDavAccessToken accessToken)
{
return EnterpriseStorageController.AddWebDavAccessToken(accessToken);
}
[WebMethod]
public void DeleteExpiredWebDavAccessTokens()
{
EnterpriseStorageController.DeleteExpiredWebDavAccessTokens();
}
[WebMethod]
public WebDavAccessToken GetWebDavAccessTokenById(int id)
{
return EnterpriseStorageController.GetWebDavAccessTokenById(id);
}
[WebMethod]
public WebDavAccessToken GetWebDavAccessTokenByAccessToken(Guid accessToken)
{
return EnterpriseStorageController.GetWebDavAccessTokenByAccessToken(accessToken);
}
[WebMethod]
public bool CheckFileServicesInstallation(int serviceId)

View file

@ -5,17 +5,6 @@
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3"/>
<section name="websitepanel.server" type="WebsitePanel.Server.ServerConfiguration, WebsitePanel.Server"/>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching"/>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings>
<add key="WebsitePanel.HyperV.UseDiskPartClearReadOnlyFlag" value="false"/>
@ -55,7 +44,7 @@
<!-- Perform security check -->
<enabled value="true"/>
<!-- Server password -->
<password value="+uxnDOdf55yuH6iZYXgYAxsfIBw="/>
<password value="FEhQyToJwdSRkkaytoTUGQRU5k4="/>
</security>
</websitepanel.server>
<system.web>
@ -74,29 +63,8 @@
</protocols>
<soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3"/>
</webServices>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<!-- WSE 3.0 settings -->
<microsoft.web.services3>
@ -137,41 +105,7 @@
</wsHttpBinding>
</bindings>
</system.serviceModel>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin/Crm2011;bin/Crm2013;bin/Exchange2013;bin/Sharepoint2013;bin/Lync2013;bin/Lync2013HP;bin/Dns2012;bin/IceWarp;bin/IIs80"/>
</assemblyBinding>

View file

@ -17,9 +17,9 @@
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
<UseIISExpress>false</UseIISExpress>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
@ -79,6 +79,7 @@
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
@ -271,12 +272,11 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseIIS>True</UseIIS>
<AutoAssignPort>False</AutoAssignPort>
<DevelopmentServerPort>9004</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<IISUrl>http://localhost:9003/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>

View file

@ -6,6 +6,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
public class WebDavExplorerConfigurationSettingsSection : ConfigurationSection
{
private const string UserDomainKey = "userDomain";
private const string WebdavRootKey = "webdavRoot";
private const string AuthTimeoutCookieNameKey = "authTimeoutCookieName";
private const string AppName = "applicationName";
private const string WebsitePanelConstantUserKey = "websitePanelConstantUser";
@ -25,6 +26,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
set { this[AuthTimeoutCookieNameKey] = value; }
}
[ConfigurationProperty(WebdavRootKey, IsRequired = true)]
public WebdavRootElement WebdavRoot
{
get { return (WebdavRootElement)this[WebdavRootKey]; }
set { this[WebdavRootKey] = value; }
}
[ConfigurationProperty(UserDomainKey, IsRequired = true)]
public UserDomainElement UserDomain
{

View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
public class WebdavRootElement : ConfigurationElement
{
private const string ValueKey = "value";
[ConfigurationProperty(ValueKey, IsKey = true, IsRequired = true)]
public string Value
{
get { return (string)this[ValueKey]; }
set { this[ValueKey] = value; }
}
}
}

View file

@ -30,6 +30,11 @@ namespace WebsitePanel.WebDav.Core.Config
get { return _configSection.UserDomain.Value; }
}
public string WebdavRoot
{
get { return _configSection.WebdavRoot.Value; }
}
public string ApplicationName
{
get { return _configSection.ApplicationName.Value; }

View file

@ -0,0 +1,14 @@
using System;
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
namespace WebsitePanel.WebDav.Core.Interfaces.Managers
{
public interface IAccessTokenManager
{
WebDavAccessToken CreateToken(WspPrincipal principal, string filePath);
WebDavAccessToken GetToken(int id);
WebDavAccessToken GetToken(Guid guid);
void ClearExpiredTokens();
}
}

View file

@ -5,15 +5,10 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Managers
{
public interface IWebDavManager
{
string RootPath { get; }
void OpenFolder(string pathPart);
IEnumerable<IHierarchyItem> GetChildren();
bool IsFile(string fileName);
byte[] GetFileBytes(string fileName);
IResource GetResource( string fileName);
string GetFileUrl(string fileName);
string CreateFileId(string path);
string FilePathFromId(string id);
IEnumerable<IHierarchyItem> OpenFolder(string path);
bool IsFile(string path);
byte[] GetFileBytes(string path);
IResource GetResource(string path);
string GetFileUrl(string path);
}
}

View file

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Security;
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
namespace WebsitePanel.WebDav.Core.Interfaces.Security
@ -11,9 +12,7 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Security
public interface IAuthenticationService
{
WspPrincipal LogIn(string login, string password);
WspPrincipal LogIn(string accessToken);
void CreateAuthenticationTicket(WspPrincipal principal);
string CreateAccessToken(WspPrincipal principal);
void LogOut();
}
}

View file

@ -0,0 +1,42 @@
using System;
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Interfaces.Managers;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
using WebsitePanel.WebDav.Core.Wsp.Framework;
namespace WebsitePanel.WebDav.Core.Managers
{
public class AccessTokenManager : IAccessTokenManager
{
public WebDavAccessToken CreateToken(WspPrincipal principal, string filePath)
{
var token = new WebDavAccessToken();
token.AccessToken = Guid.NewGuid();
token.AccountId = principal.AccountId;
token.ItemId = principal.ItemId;
token.AuthData = principal.EncryptedPassword;
token.ExpirationDate = DateTime.Now.AddHours(3);
token.FilePath = filePath;
token.Id = WSP.Services.EnterpriseStorage.AddWebDavAccessToken(token);
return token;
}
public WebDavAccessToken GetToken(int id)
{
return WSP.Services.EnterpriseStorage.GetWebDavAccessTokenById(id);
}
public WebDavAccessToken GetToken(Guid guid)
{
return WSP.Services.EnterpriseStorage.GetWebDavAccessTokenByAccessToken(guid);
}
public void ClearExpiredTokens()
{
WSP.Services.EnterpriseStorage.DeleteExpiredWebDavAccessTokens();
}
}
}

View file

@ -21,16 +21,8 @@ namespace WebsitePanel.WebDav.Core.Managers
private readonly ILog Log;
private IFolder _currentFolder;
private bool _isRoot = true;
private Lazy<IList<SystemFile>> _rootFolders;
private Lazy<string> _webDavRootPath;
public string RootPath
{
get { return _webDavRootPath.Value; }
}
private IFolder _currentFolder;
public WebDavManager(ICryptography cryptography)
{
@ -38,49 +30,29 @@ namespace WebsitePanel.WebDav.Core.Managers
Log = LogManager.GetLogger(this.GetType());
_webDavSession = new WebDavSession();
_rootFolders = new Lazy<IList<SystemFile>>(ConnectToWebDavServer);
_webDavRootPath = new Lazy<string>(() =>
{
if (_rootFolders.Value.Any())
{
var folder = _rootFolders.Value.First();
var uri = new Uri(folder.Url);
return uri.Scheme + "://" + uri.Host + uri.Segments[0] + uri.Segments[1];
}
return string.Empty;
});
}
public void OpenFolder(string pathPart)
{
if (string.IsNullOrWhiteSpace(pathPart))
{
_isRoot = true;
return;
}
_isRoot = false;
_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> OpenFolder(string pathPart)
{
IHierarchyItem[] children;
if (_isRoot)
if (string.IsNullOrWhiteSpace(pathPart))
{
children = _rootFolders.Value.Select(x => new WebDavHierarchyItem {Href = new Uri(x.Url), ItemType = ItemType.Folder}).ToArray();
children = ConnectToWebDavServer().Select(x => new WebDavHierarchyItem { Href = new Uri(x.Url), ItemType = ItemType.Folder }).ToArray();
}
else
{
{
if (_currentFolder == null || _currentFolder.Path.ToString() != pathPart)
{
_webDavSession.Credentials = new NetworkCredential(WspContext.User.Login,
_cryptography.Decrypt(WspContext.User.EncryptedPassword),
WebDavAppConfigManager.Instance.UserDomain);
_currentFolder = _webDavSession.OpenFolder(string.Format("{0}{1}/{2}", WebDavAppConfigManager.Instance.WebdavRoot, WspContext.User.OrganizationId, pathPart));
}
children = _currentFolder.GetChildren();
}
}
List<IHierarchyItem> sortedChildren = children.Where(x => x.ItemType == ItemType.Folder).OrderBy(x => x.DisplayName).ToList();
sortedChildren.AddRange(children.Where(x => x.ItemType != ItemType.Folder).OrderBy(x => x.DisplayName));
@ -88,30 +60,46 @@ namespace WebsitePanel.WebDav.Core.Managers
return sortedChildren;
}
public bool IsFile(string fileName)
public bool IsFile(string path)
{
if (string.IsNullOrWhiteSpace(fileName) | _currentFolder == null)
string folder = GetFileFolder(path);
if (string.IsNullOrWhiteSpace(folder))
{
return false;
}
var resourceName = GetResourceName(path);
OpenFolder(folder);
try
{
IResource resource = _currentFolder.GetResource(fileName);
//Stream stream = resource.GetReadStream();
IResource resource = _currentFolder.GetResource(resourceName);
return true;
}
catch (InvalidOperationException)
{
}
catch (Exception e){}
return false;
}
public byte[] GetFileBytes(string fileName)
public byte[] GetFileBytes(string path)
{
try
{
IResource resource = _currentFolder.GetResource(fileName);
string folder = GetFileFolder(path);
var resourceName = GetResourceName(path);
OpenFolder(folder);
IResource resource = _currentFolder.GetResource(resourceName);
Stream stream = resource.GetReadStream();
byte[] fileBytes = ReadFully(stream);
return fileBytes;
}
catch (InvalidOperationException exception)
@ -120,12 +108,17 @@ namespace WebsitePanel.WebDav.Core.Managers
}
}
public IResource GetResource(string fileName)
public IResource GetResource(string path)
{
try
{
IResource resource = _currentFolder.GetResource(fileName);
return resource;
string folder = GetFileFolder(path);
var resourceName = GetResourceName(path);
OpenFolder(folder);
return _currentFolder.GetResource(resourceName);
}
catch (InvalidOperationException exception)
{
@ -133,11 +126,17 @@ namespace WebsitePanel.WebDav.Core.Managers
}
}
public string GetFileUrl(string fileName)
public string GetFileUrl(string path)
{
try
{
IResource resource = _currentFolder.GetResource(fileName);
string folder = GetFileFolder(path);
var resourceName = GetResourceName(path);
OpenFolder(folder);
IResource resource = _currentFolder.GetResource(resourceName);
return resource.Href.ToString();
}
catch (InvalidOperationException exception)
@ -171,9 +170,11 @@ namespace WebsitePanel.WebDav.Core.Managers
return rootFolders;
}
#region Helpers
private byte[] ReadFully(Stream input)
{
var buffer = new byte[16*1024];
var buffer = new byte[16 * 1024];
using (var ms = new MemoryStream())
{
int read;
@ -183,15 +184,34 @@ namespace WebsitePanel.WebDav.Core.Managers
}
}
public string CreateFileId(string path)
private string GetFileFolder(string path)
{
return _cryptography.Encrypt(path).Replace("/", "AAAAA");
path = path.TrimEnd('/');
if (string.IsNullOrEmpty(path) || !path.Contains('/'))
{
return string.Empty;
}
string fileName = path.Split('/').Last();
int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase);
string folder = string.IsNullOrEmpty(fileName)? path : path.Remove(index - 1, fileName.Length + 1);
return folder;
}
public string FilePathFromId(string id)
private string GetResourceName(string path)
{
return _cryptography.Decrypt(id.Replace("AAAAA", "/"));
}
path = path.TrimEnd('/');
if (string.IsNullOrEmpty(path) || !path.Contains('/'))
{
return string.Empty;
}
return path.Split('/').Last(); ;
}
#endregion
}
}

View file

@ -23,13 +23,7 @@ namespace WebsitePanel.WebDav.Core.Owa
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 resource = _webDavManager.GetResource(path);
var cFileInfo = new CheckFileInfo
{
@ -44,13 +38,7 @@ namespace WebsitePanel.WebDav.Core.Owa
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);
var fileBytes = _webDavManager.GetFileBytes(path);
return new FileContentResult(fileBytes, MediaTypeNames.Application.Octet);
}

View file

@ -4,6 +4,7 @@ using System.Threading;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Security;
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Config;
using WebsitePanel.WebDav.Core.Interfaces.Security;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
@ -25,12 +26,17 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
public WspPrincipal LogIn(string login, string password)
{
if (_principalContext.ValidateCredentials(login, password) == false)
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
return null;
}
//var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.UserPrincipalName, login);
var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.UserPrincipalName, login);
if (_principalContext.ValidateCredentials(login, password) == false && user != null)
{
return null;
}
var principal = new WspPrincipal(login);
@ -53,24 +59,6 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
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)
{
var serializer = new JavaScriptSerializer();
@ -91,13 +79,6 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
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()
{
FormsAuthentication.SignOut();

View file

@ -12,7 +12,6 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
public int ItemId { get; set; }
public string Login { get; set; }
public string EncryptedPassword { get; set; }
public string DisplayName { get; set; }
@ -27,6 +26,8 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
[XmlIgnore, ScriptIgnore]
public IIdentity Identity { get; private set; }
public string EncryptedPassword { get; set; }
public WspPrincipal(string username)
{
Identity = new GenericIdentity(username);//new WindowsIdentity(username, "WindowsAuthentication");

View file

@ -41,10 +41,11 @@
</Reference>
<Reference Include="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Scheduler Domains\WebsitePanel\Bin\Microsoft.Web.Services3.dll</HintPath>
<HintPath>..\packages\Microsoft.Web.Services3.3.0.0.0\lib\net20\Microsoft.Web.Services3.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices.AccountManagement" />
@ -83,9 +84,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<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 Include="WebsitePanel.EnterpriseServer.Base">
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Base.dll</HintPath>
</Reference>
<Reference Include="WebsitePanel.EnterpriseServer.Client">
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
@ -114,6 +114,7 @@
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
<Compile Include="Config\WebConfigSections\WebdavRootElement.cs" />
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
<Compile Include="Config\WebDavAppConfigManager.cs" />
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
@ -126,6 +127,8 @@
<Compile Include="IFolder.cs" />
<Compile Include="IHierarchyItem.cs" />
<Compile Include="IItemContent.cs" />
<Compile Include="Managers\AccessTokenManager.cs" />
<Compile Include="Interfaces\Managers\IAccessTokenManager.cs" />
<Compile Include="Interfaces\Managers\IWebDavManager.cs" />
<Compile Include="Interfaces\Owa\IWopiServer.cs" />
<Compile Include="Interfaces\Security\IAuthenticationService.cs" />

View file

@ -5,4 +5,5 @@
<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.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Microsoft.Web.Services3" version="3.0.0.0" targetFramework="net45" />
</packages>

View file

@ -3,7 +3,7 @@
<!-- Display Settings -->
<PortalName>WebsitePanel</PortalName>
<!-- Enterprise Server -->
<EnterpriseServer>http://127.0.0.1:9555</EnterpriseServer>
<EnterpriseServer>http://localhost:9002</EnterpriseServer>
<!-- General Settings -->
<CultureCookieName>UserCulture</CultureCookieName>
<ThemeCookieName>UserTheme</ThemeCookieName>

View file

@ -30,13 +30,13 @@ namespace WebsitePanel.WebDavPortal
routes.MapRoute(
name: OwaRouteNames.GetFile,
url: "owa/wopi*/files/{encodedPath}/contents",
url: "owa/wopi*/files/{accessTokenId}/contents",
defaults: new { controller = "Owa", action = "GetFile" }
);
routes.MapRoute(
name: OwaRouteNames.CheckFileInfo,
url: "owa/wopi*/files/{encodedPath}",
url: "owa/wopi*/files/{accessTokenId}",
defaults: new { controller = "Owa", action = "CheckFileInfo" }
);
@ -48,6 +48,12 @@ namespace WebsitePanel.WebDavPortal
defaults: new { controller = "FileSystem", action = "ShowOfficeDocument", pathPart = UrlParameter.Optional }
);
routes.MapRoute(
name: FileSystemRouteNames.ShowAdditionalContent,
url: "show-additional-content/{*path}",
defaults: new { controller = "FileSystem", action = "ShowAdditionalContent", path = UrlParameter.Optional }
);
routes.MapRoute(
name: FileSystemRouteNames.FilePath,
url: "{org}/{*pathPart}",

View file

@ -40,9 +40,9 @@ namespace WebsitePanel.WebDavPortal.Controllers
{
var user = _authenticationService.LogIn(model.Login, model.Password);
ViewBag.LdapIsAuthentication = user.Identity.IsAuthenticated;
ViewBag.LdapIsAuthentication = user != null;
if (user.Identity.IsAuthenticated)
if (user != null && user.Identity.IsAuthenticated)
{
_authenticationService.CreateAuthenticationTicket(user);

View file

@ -29,31 +29,35 @@ namespace WebsitePanel.WebDavPortal.Controllers
private readonly ICryptography _cryptography;
private readonly IWebDavManager _webdavManager;
private readonly IAuthenticationService _authenticationService;
private readonly IAccessTokenManager _tokenManager;
public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService)
public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService, IAccessTokenManager tokenManager)
{
_cryptography = cryptography;
_webdavManager = webdavManager;
_authenticationService = authenticationService;
_tokenManager = tokenManager;
}
[HttpGet]
public ActionResult ShowContent(string org, string pathPart = "")
{
if (org != WspContext.User.OrganizationId)
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
string fileName = pathPart.Split('/').Last();
if (_webdavManager.IsFile(fileName))
{
var fileBytes = _webdavManager.GetFileBytes(fileName);
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
}
string fileName = pathPart.Split('/').Last();
if (_webdavManager.IsFile(pathPart))
{
var fileBytes = _webdavManager.GetFileBytes(pathPart);
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
}
try
{
_webdavManager.OpenFolder(pathPart);
IEnumerable<IHierarchyItem> children = _webdavManager.GetChildren().Where(x => !WebDavAppConfigManager.Instance.ElementsRendering.ElementsToIgnore.Contains(x.DisplayName.Trim('/')));
IEnumerable<IHierarchyItem> children = _webdavManager.OpenFolder(pathPart).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;
@ -70,33 +74,26 @@ namespace WebsitePanel.WebDavPortal.Controllers
{
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
string fileUrl = _webdavManager.RootPath.TrimEnd('/') + "/" + pathPart.TrimStart('/');
string accessToken = _authenticationService.CreateAccessToken(WspContext.User);
string fileUrl = WebDavAppConfigManager.Instance.WebdavRoot+ org + "/" + pathPart.TrimStart('/');
var accessToken = _tokenManager.CreateToken(WspContext.User, pathPart);
string wopiSrc = Server.UrlDecode(Url.RouteUrl(OwaRouteNames.CheckFileInfo, new { encodedPath = _webdavManager.CreateFileId(pathPart) }, Request.Url.Scheme));
string wopiSrc = Server.UrlDecode(Url.RouteUrl(OwaRouteNames.CheckFileInfo, new { accessTokenId = accessToken.Id }, 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));
var uri = string.Format("{0}/{1}?WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpener.OwaOpener, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken.AccessToken.ToString("N")));
return View(new OfficeOnlineModel(uri, new Uri(fileUrl).Segments.Last()));
}
[HttpPost]
public ActionResult ShowAdditionalContent()
public ActionResult ShowAdditionalContent(string path = "", int resourseRenderCount = 0)
{
if (Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] != null)
{
var renderedElementsCount = (int)Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount];
path = path.Replace(WspContext.User.OrganizationId, "").Trim('/');
IEnumerable<IHierarchyItem> children = _webdavManager.GetChildren();
IEnumerable<IHierarchyItem> children = _webdavManager.OpenFolder(path);
var result = children.Skip(renderedElementsCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount);
var result = children.Skip(resourseRenderCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount);
Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] = renderedElementsCount + WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount;
return PartialView("_ResourseCollectionPartial", result);
}
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
return PartialView("_ResourseCollectionPartial", result);
}
}
}

View file

@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Interfaces.Managers;
using WebsitePanel.WebDav.Core.Interfaces.Owa;
using WebsitePanel.WebDav.Core.Interfaces.Security;
using WebsitePanel.WebDav.Core.Security.Cryptography;
using WebsitePanel.WebDav.Core.Wsp.Framework;
namespace WebsitePanel.WebDavPortal.Controllers
{
@ -16,28 +19,40 @@ namespace WebsitePanel.WebDavPortal.Controllers
private readonly IWopiServer _wopiServer;
private readonly IWebDavManager _webDavManager;
private readonly IAuthenticationService _authenticationService;
private readonly IAccessTokenManager _tokenManager;
private readonly ICryptography _cryptography;
private WebDavAccessToken _token;
public OwaController(IWopiServer wopiServer, IWebDavManager webDavManager, IAuthenticationService authenticationService)
public OwaController(IWopiServer wopiServer, IWebDavManager webDavManager, IAuthenticationService authenticationService, IAccessTokenManager tokenManager, ICryptography cryptography)
{
_wopiServer = wopiServer;
_webDavManager = webDavManager;
_authenticationService = authenticationService;
_tokenManager = tokenManager;
_cryptography = cryptography;
}
public JsonResult CheckFileInfo( string encodedPath)
public ActionResult CheckFileInfo(int accessTokenId)
{
var path = _webDavManager.FilePathFromId(encodedPath);
if (!CheckAccess(accessTokenId))
{
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
}
var fileInfo = _wopiServer.GetCheckFileInfo(path);
var fileInfo = _wopiServer.GetCheckFileInfo(_token.FilePath);
return Json(fileInfo, JsonRequestBehavior.AllowGet);
}
public FileResult GetFile(string encodedPath)
public ActionResult GetFile(int accessTokenId)
{
var path = _webDavManager.FilePathFromId(encodedPath);
if (!CheckAccess(accessTokenId))
{
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
}
return _wopiServer.GetFile(path);
return _wopiServer.GetFile((_token.FilePath));
}
protected override void OnActionExecuting(ActionExecutingContext filterContext)
@ -46,8 +61,26 @@ namespace WebsitePanel.WebDavPortal.Controllers
if (!string.IsNullOrEmpty(Request["access_token"]))
{
_authenticationService.LogIn(Request["access_token"]);
var guid = Guid.Parse((Request["access_token"]));
_tokenManager.ClearExpiredTokens();
_token = _tokenManager.GetToken(guid);
var user = WSP.Services.ExchangeServer.GetAccount(_token.ItemId, _token.AccountId);
_authenticationService.LogIn(user.UserPrincipalName, _cryptography.Decrypt(_token.AuthData));
}
}
private bool CheckAccess(int accessTokenId)
{
if (_token == null || accessTokenId != _token.Id)
{
return false;
}
return true;
}
}
}

View file

@ -7,6 +7,7 @@ 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.Managers;
using WebsitePanel.WebDav.Core.Owa;
using WebsitePanel.WebDav.Core.Security;
using WebsitePanel.WebDav.Core.Security.Authentication;
@ -23,7 +24,8 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
kernel.Bind<HttpSessionState>().ToProvider<HttpSessionStateProvider>();
kernel.Bind<ICryptography>().To<CryptoUtils>();
kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>();
kernel.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
kernel.Bind<IWebDavManager>().To<WebDavManager>();
kernel.Bind<IAccessTokenManager>().To<AccessTokenManager>();
kernel.Bind<IWopiServer>().To<WopiServer>();
}
}

View file

@ -14,8 +14,8 @@ var oldResourcesDivHeight = $('#resourcesDiv').height();
function GetResources() {
$.ajax({
type: 'POST',
url: '/FileSystem/ShowAdditionalContent',
data: '',
url: '/show-additional-content',
data: { path: window.location.pathname, resourseRenderCount: $(".element-container").length },
dataType: "html",
success: function (result) {
var domElement = $(result);

View file

@ -8,5 +8,6 @@ namespace WebsitePanel.WebDavPortal.UI.Routes
public class FileSystemRouteNames
{
public const string FilePath = "FilePathRoute";
public const string ShowAdditionalContent = "ShowAdditionalContentRoute";
}
}

View file

@ -38,6 +38,7 @@
</appSettings>
<webDavExplorerConfigurationSettings>
<userDomain value="websitepanel.net" />
<webdavRoot value="https://webdav.websitepanel.net/" />
<applicationName value="WebDAV Explorer" />
<authTimeoutCookieName value=".auth-logout-timeout" />
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config" />

View file

@ -327,5 +327,22 @@ namespace WebsitePanel.Portal
var idn = new IdnMapping();
return idn.GetAscii(domainName);
}
/// <summary>
/// Adds the specified parameter to the Query String.
/// </summary>
/// <param name="url"></param>
/// <param name="paramName">Name of the parameter to add.</param>
/// <param name="paramValue">Value for the parameter to add.</param>
/// <returns>Url with added parameter.</returns>
public static Uri AddParameterToUrl(Uri url, string paramName, string paramValue)
{
var uriBuilder = new UriBuilder(url);
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
query[paramName] = paramValue;
uriBuilder.Query = query.ToString();
return new Uri(uriBuilder.ToString());
}
}
}

View file

@ -10,7 +10,7 @@
<div class="FormBody">
<p id="DomainPanel" runat="server" style="padding: 15px 0 15px 5px;">
<wsp:DomainControl ID="DomainName" runat="server" RequiredEnabled="True" ValidationGroup="Domain" OnTextChanged="DomainName_TextChanged"></wsp:DomainControl>
<wsp:DomainControl ID="DomainName" runat="server" RequiredEnabled="True" ValidationGroup="Domain"></wsp:DomainControl>
</p>
<wsp:CollapsiblePanel id="OptionsPanelHeader" runat="server"

View file

@ -158,7 +158,10 @@ namespace WebsitePanel.Portal
// allow sub-domains
AllowSubDomainsPanel.Visible = (type == DomainType.Domain) && PanelSecurity.EffectiveUser.Role != UserRole.User;
CheckForCorrectIdnDomainUsage(DomainName.Text);
if (IsPostBack)
{
CheckForCorrectIdnDomainUsage(DomainName.Text);
}
}
private DomainType GetDomainType(string typeName)
@ -279,10 +282,5 @@ namespace WebsitePanel.Portal
return true;
}
protected void DomainName_TextChanged(object sender, DomainControl.DomainNameEventArgs e)
{
CheckForCorrectIdnDomainUsage(e.DomainName);
}
}
}

View file

@ -149,7 +149,14 @@ namespace WebsitePanel.Portal
private void RedirectBack()
{
Response.Redirect(NavigateURL("PoolID", ddlPools.SelectedValue));
var returnUrl = Request["ReturnUrl"];
if (string.IsNullOrEmpty(returnUrl))
{
returnUrl = NavigateURL("PoolID", ddlPools.SelectedValue);
}
Response.Redirect(returnUrl);
}
protected void ddlPools_SelectedIndexChanged(object sender, EventArgs e)

View file

@ -107,7 +107,14 @@ namespace WebsitePanel.Portal
private void RedirectBack()
{
Response.Redirect(NavigateURL("PoolID", ddlPools.SelectedValue));
var returnUrl = Request["ReturnUrl"];
if (string.IsNullOrEmpty(returnUrl))
{
returnUrl = NavigateURL("PoolID", ddlPools.SelectedValue);
}
Response.Redirect(returnUrl);
}
protected void btnUpdate_Click(object sender, EventArgs e)

View file

@ -11,7 +11,7 @@
<Columns>
<asp:TemplateField SortExpression="ExternalIP" HeaderText="gvIPAddressesExternalIP">
<ItemTemplate>
<asp:hyperlink NavigateUrl='<%# EditModuleUrl("AddressID", Eval("AddressID").ToString(), "edit_ip") %>' runat="server" ID="lnkEdit">
<asp:hyperlink NavigateUrl='<%# EditModuleUrl("AddressID", Eval("AddressID").ToString(), "edit_ip", "ReturnUrl", GetReturnUrl()) %>' runat="server" ID="lnkEdit">
<%# Eval("ExternalIP") %>
</asp:hyperlink>
</ItemTemplate>

View file

@ -55,9 +55,15 @@ namespace WebsitePanel.Portal
return HostModule.EditUrl(key, keyVal, ctrlKey, key2 + "=" + keyVal2);
}
public string GetReturnUrl()
{
var returnUrl = Utils.AddParameterToUrl(Request.Url, "IpAddressesCollapsed", "False");
return Uri.EscapeDataString("~" + returnUrl.PathAndQuery);
}
protected void btnAdd_Click(object sender, EventArgs e)
{
Response.Redirect(HostModule.EditUrl("ServerID", PanelRequest.ServerId.ToString(), "add_ip"), true);
Response.Redirect(EditModuleUrl("ServerID", PanelRequest.ServerId.ToString(), "add_ip", "ReturnUrl", GetReturnUrl()), true);
}
}
}

View file

@ -59,6 +59,8 @@ namespace WebsitePanel.Portal
return;
}
}
IPAddressesHeader.IsCollapsed = IsIpAddressesCollapsed;
}
private void BindTools()
@ -232,5 +234,13 @@ namespace WebsitePanel.Portal
return;
}
}
protected bool IsIpAddressesCollapsed
{
get
{
return PanelRequest.GetBool("IpAddressesCollapsed", true);
}
}
}
}

View file

@ -77,11 +77,15 @@ namespace WebsitePanel.Portal.UserControls
get
{
var domainName = txtDomainName.Text.Trim();
if (IsSubDomain)
if (!IsSubDomain) return domainName;
if (string.IsNullOrEmpty(domainName))
{
domainName += "." + DomainsList.SelectedValue;
// Only return selected domain from DomainsList when no subdomain is entered yet
return DomainsList.SelectedValue;
}
return domainName;
return domainName + "." + DomainsList.SelectedValue;
}
set { txtDomainName.Text = value; }
}

View file

@ -220,7 +220,7 @@ namespace WebsitePanel.Portal
function wspValidatePasswordSymbols(source, args)
{
if(args.Value == source.getAttribute('dpsw')) return true;
args.IsValid = wspValidatePattern(/(\W)/g, args.Value,
args.IsValid = wspValidatePattern(/([\W_])/g, args.Value,
parseInt(source.getAttribute('minimumNumber')));
}
@ -357,7 +357,7 @@ namespace WebsitePanel.Portal
protected void valRequireSymbols_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = ((args.Value == EMPTY_PASSWORD) || ValidatePattern("(\\W)", args.Value, MinimumSymbols));
args.IsValid = ((args.Value == EMPTY_PASSWORD) || ValidatePattern("([\\W_])", args.Value, MinimumSymbols));
}
private bool ValidatePattern(string regexp, string val, int minimumNumber)

View file

@ -24,6 +24,8 @@
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -74,8 +76,7 @@
</Reference>
<Reference Include="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lib\Microsoft.Web.Services3.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Services3.3.0.0.0\lib\net20\Microsoft.Web.Services3.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -292,6 +293,7 @@
<Content Include="App_Themes\Default\Common.skin" />
<Content Include="App_Themes\Default\DataBoundControls.skin" />
<Content Include="App_Themes\Default\Icons.skin" />
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Containers\Default\TopPane.ascx" />
@ -802,4 +804,5 @@
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</Project>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.Services3" version="3.0.0.0" targetFramework="net40" />
</packages>