webdav portal auth via ad

This commit is contained in:
vfedosevich 2015-01-13 04:18:56 -08:00
parent 05d9fddb5d
commit 7dd090820b
56 changed files with 927 additions and 281 deletions

View file

@ -0,0 +1,17 @@
using System.Configuration;
using WebsitePanel.WebDavPortal.WebConfigSections;
namespace WebsitePanel.WebDav.Core.Config.Entities
{
public abstract class AbstractConfigCollection
{
protected WebDavExplorerConfigurationSettingsSection ConfigSection;
protected AbstractConfigCollection()
{
ConfigSection =
(WebDavExplorerConfigurationSettingsSection)
ConfigurationManager.GetSection(WebDavExplorerConfigurationSettingsSection.SectionName);
}
}
}

View file

@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Linq;
namespace WebsitePanel.WebDav.Core.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();
}
}
}

View file

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using WebsitePanel.WebDav.Core.Config.WebConfigSections;
namespace WebsitePanel.WebDav.Core.Config.Entities
{
public class FileIconsDictionary : AbstractConfigCollection, IReadOnlyDictionary<string, string>
{
private readonly IDictionary<string, string> _fileIcons;
public FileIconsDictionary()
{
DefaultPath = ConfigSection.FileIcons.DefaultPath;
_fileIcons = ConfigSection.FileIcons.Cast<FileIconsElement>().ToDictionary(x => x.Extension, y => y.Path);
}
public string DefaultPath { get; private set; }
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
return _fileIcons.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public int Count
{
get { return _fileIcons.Count; }
}
public bool ContainsKey(string extension)
{
return _fileIcons.ContainsKey(extension);
}
public bool TryGetValue(string extension, out string path)
{
return _fileIcons.TryGetValue(extension, out path);
}
public string this[string extension]
{
get { return ContainsKey(extension) ? _fileIcons[extension] : DefaultPath; }
}
public IEnumerable<string> Keys
{
get { return _fileIcons.Keys; }
}
public IEnumerable<string> Values
{
get { return _fileIcons.Values; }
}
}
}

View file

@ -0,0 +1,21 @@
using System.Globalization;
namespace WebsitePanel.WebDav.Core.Config.Entities
{
public class HttpErrorsCollection
{
public string this[int statusCode]
{
get
{
var message = Resources.HttpErrors.ResourceManager.GetString("_" + statusCode.ToString(CultureInfo.InvariantCulture));
return message ?? Default;
}
}
public string Default
{
get { return Resources.HttpErrors.Default; }
}
}
}

View file

@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using WebsitePanel.WebDavPortal.WebConfigSections;
namespace WebsitePanel.WebDav.Core.Config.Entities
{
public class OfficeOnlineCollection : AbstractConfigCollection, IReadOnlyCollection<string>
{
private readonly IList<string> _officeExtensions;
public OfficeOnlineCollection()
{
IsEnabled = ConfigSection.OfficeOnline.IsEnabled;
Url = ConfigSection.OfficeOnline.Url;
_officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().Select(x => x.Extension).ToList();
}
public bool IsEnabled { get; private set; }
public string Url { get; private set; }
public IEnumerator<string> GetEnumerator()
{
return _officeExtensions.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public int Count
{
get { return _officeExtensions.Count; }
}
public bool Contains(string extension)
{
return _officeExtensions.Contains(extension);
}
}
}

View file

@ -0,0 +1,54 @@
using System.Collections.Generic;
using System.Linq;
using WebsitePanel.WebDavPortal.WebConfigSections;
namespace WebsitePanel.WebDav.Core.Config.Entities
{
public class SessionKeysCollection : AbstractConfigCollection
{
private readonly IEnumerable<SessionKeysElement> _sessionKeys;
public SessionKeysCollection()
{
_sessionKeys = ConfigSection.SessionKeys.Cast<SessionKeysElement>();
}
public string AuthTicket
{
get
{
SessionKeysElement sessionKey =
_sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.AuthTicketKey);
return sessionKey != null ? sessionKey.Value : null;
}
}
public string WebDavManager
{
get
{
SessionKeysElement sessionKey =
_sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.WebDavManagerKey);
return sessionKey != null ? sessionKey.Value : null;
}
}
public string ResourseRenderCount
{
get
{
SessionKeysElement sessionKey = _sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.ResourseRenderCountKey);
return sessionKey != null ? sessionKey.Value : null;
}
}
public string ItemId
{
get
{
SessionKeysElement sessionKey = _sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.ItemIdSessionKey);
return sessionKey != null ? sessionKey.Value : null;
}
}
}
}

View file

@ -0,0 +1,14 @@
namespace WebsitePanel.WebDav.Core.Config.Entities
{
public class WebsitePanelConstantUserParameters : AbstractConfigCollection
{
public string Login { get; private set; }
public string Password { get; private set; }
public WebsitePanelConstantUserParameters()
{
Login = ConfigSection.WebsitePanelConstantUser.Login;
Password = ConfigSection.WebsitePanelConstantUser.Password;
}
}
}

View file

@ -0,0 +1,16 @@
using WebsitePanel.WebDav.Core.Config.Entities;
namespace WebsitePanel.WebDav.Core.Config
{
public interface IWebDavAppConfig
{
string UserDomain { get; }
string ApplicationName { get; }
ElementsRendering ElementsRendering { get; }
WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; }
SessionKeysCollection SessionKeys { get; }
FileIconsDictionary FileIcons { get; }
HttpErrorsCollection HttpErrors { get; }
OfficeOnlineCollection OfficeOnline { get; }
}
}

View file

@ -0,0 +1,16 @@
using System.Configuration;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
public class ApplicationNameElement : 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

@ -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 AuthTimeoutCookieNameElement : 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

@ -0,0 +1,32 @@
using System.Configuration;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
public class ElementsRenderingElement : ConfigurationElement
{
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
{
get { return (int)this[DefaultCountKey]; }
set { this[DefaultCountKey] = value; }
}
[ConfigurationProperty(AddElementsCountKey, IsKey = true, IsRequired = true, DefaultValue = 20)]
public int AddElementsCount
{
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; }
}
}
}

View file

@ -0,0 +1,24 @@
using System.Configuration;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
public class FileIconsElement : ConfigurationElement
{
private const string ExtensionKey = "extension";
private const string PathKey = "path";
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
public string Extension
{
get { return (string) this[ExtensionKey]; }
set { this[ExtensionKey] = value; }
}
[ConfigurationProperty(PathKey, IsKey = true, IsRequired = true)]
public string Path
{
get { return (string) this[PathKey]; }
set { this[PathKey] = value; }
}
}
}

View file

@ -0,0 +1,27 @@
using System.Configuration;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
[ConfigurationCollection(typeof (FileIconsElement))]
public class FileIconsElementCollection : ConfigurationElementCollection
{
private const string DefaultPathKey = "defaultPath";
[ConfigurationProperty(DefaultPathKey, IsRequired = false, DefaultValue = "/")]
public string DefaultPath
{
get { return (string) this[DefaultPathKey]; }
set { this[DefaultPathKey] = value; }
}
protected override ConfigurationElement CreateNewElement()
{
return new FileIconsElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((FileIconsElement) element).Extension;
}
}
}

View file

@ -0,0 +1,16 @@
using System.Configuration;
namespace WebsitePanel.WebDavPortal.WebConfigSections
{
public class OfficeOnlineElement : ConfigurationElement
{
private const string ExtensionKey = "extension";
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
public string Extension
{
get { return this[ExtensionKey].ToString(); }
set { this[ExtensionKey] = value; }
}
}
}

View file

@ -0,0 +1,36 @@
using System;
using System.Configuration;
namespace WebsitePanel.WebDavPortal.WebConfigSections
{
[ConfigurationCollection(typeof(OfficeOnlineElement))]
public class OfficeOnlineElementCollection : ConfigurationElementCollection
{
private const string UrlKey = "url";
private const string IsEnabledKey = "isEnabled";
[ConfigurationProperty(UrlKey, IsKey = true, IsRequired = true)]
public string Url
{
get { return this[UrlKey].ToString(); }
set { this[UrlKey] = value; }
}
[ConfigurationProperty(IsEnabledKey, IsKey = true, IsRequired = true, DefaultValue = false)]
public bool IsEnabled
{
get { return Boolean.Parse(this[IsEnabledKey].ToString()); }
set { this[IsEnabledKey] = value; }
}
protected override ConfigurationElement CreateNewElement()
{
return new OfficeOnlineElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((OfficeOnlineElement)element).Extension;
}
}
}

View file

@ -0,0 +1,30 @@
using System.Configuration;
namespace WebsitePanel.WebDavPortal.WebConfigSections
{
public class SessionKeysElement : ConfigurationElement
{
private const string KeyKey = "key";
private const string ValueKey = "value";
public const string AccountInfoKey = "AccountInfoSessionKey";
public const string AuthTicketKey = "AuthTicketKey";
public const string WebDavManagerKey = "WebDavManagerSessionKey";
public const string ResourseRenderCountKey = "ResourseRenderCountSessionKey";
public const string ItemIdSessionKey = "ItemId";
[ConfigurationProperty(KeyKey, IsKey = true, IsRequired = true)]
public string Key
{
get { return (string) this[KeyKey]; }
set { this[KeyKey] = value; }
}
[ConfigurationProperty(ValueKey, IsKey = true, IsRequired = true)]
public string Value
{
get { return (string) this[ValueKey]; }
set { this[ValueKey] = value; }
}
}
}

View file

@ -0,0 +1,19 @@
using System.Configuration;
using WebsitePanel.WebDavPortal.WebConfigSections;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
[ConfigurationCollection(typeof (SessionKeysElement))]
public class SessionKeysElementCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new SessionKeysElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((SessionKeysElement) element).Key;
}
}
}

View file

@ -0,0 +1,16 @@
using System.Configuration;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
public class UserDomainElement : 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

@ -0,0 +1,77 @@
using System.Configuration;
using WebsitePanel.WebDav.Core.Config.WebConfigSections;
namespace WebsitePanel.WebDavPortal.WebConfigSections
{
public class WebDavExplorerConfigurationSettingsSection : ConfigurationSection
{
private const string UserDomainKey = "userDomain";
private const string AuthTimeoutCookieNameKey = "authTimeoutCookieName";
private const string AppName = "applicationName";
private const string WebsitePanelConstantUserKey = "websitePanelConstantUser";
private const string ElementsRenderingKey = "elementsRendering";
private const string Rfc2898CryptographyKey = "rfc2898Cryptography";
private const string ConnectionStringsKey = "appConnectionStrings";
private const string SessionKeysKey = "sessionKeys";
private const string FileIconsKey = "fileIcons";
private const string OfficeOnlineKey = "officeOnline";
public const string SectionName = "webDavExplorerConfigurationSettings";
[ConfigurationProperty(AuthTimeoutCookieNameKey, IsRequired = true)]
public AuthTimeoutCookieNameElement AuthTimeoutCookieName
{
get { return (AuthTimeoutCookieNameElement)this[AuthTimeoutCookieNameKey]; }
set { this[AuthTimeoutCookieNameKey] = value; }
}
[ConfigurationProperty(UserDomainKey, IsRequired = true)]
public UserDomainElement UserDomain
{
get { return (UserDomainElement) this[UserDomainKey]; }
set { this[UserDomainKey] = value; }
}
[ConfigurationProperty(AppName, IsRequired = true)]
public ApplicationNameElement ApplicationName
{
get { return (ApplicationNameElement)this[AppName]; }
set { this[AppName] = value; }
}
[ConfigurationProperty(WebsitePanelConstantUserKey, IsRequired = true)]
public WebsitePanelConstantUserElement WebsitePanelConstantUser
{
get { return (WebsitePanelConstantUserElement)this[WebsitePanelConstantUserKey]; }
set { this[WebsitePanelConstantUserKey] = value; }
}
[ConfigurationProperty(ElementsRenderingKey, IsRequired = true)]
public ElementsRenderingElement ElementsRendering
{
get { return (ElementsRenderingElement)this[ElementsRenderingKey]; }
set { this[ElementsRenderingKey] = value; }
}
[ConfigurationProperty(SessionKeysKey, IsDefaultCollection = false)]
public SessionKeysElementCollection SessionKeys
{
get { return (SessionKeysElementCollection) this[SessionKeysKey]; }
set { this[SessionKeysKey] = value; }
}
[ConfigurationProperty(FileIconsKey, IsDefaultCollection = false)]
public FileIconsElementCollection FileIcons
{
get { return (FileIconsElementCollection) this[FileIconsKey]; }
set { this[FileIconsKey] = value; }
}
[ConfigurationProperty(OfficeOnlineKey, IsDefaultCollection = false)]
public OfficeOnlineElementCollection OfficeOnline
{
get { return (OfficeOnlineElementCollection)this[OfficeOnlineKey]; }
set { this[OfficeOnlineKey] = value; }
}
}
}

View file

@ -0,0 +1,24 @@
using System.Configuration;
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
{
public class WebsitePanelConstantUserElement : ConfigurationElement
{
private const string LoginKey = "login";
private const string PasswordKey = "password";
[ConfigurationProperty(LoginKey, IsKey = true, IsRequired = true)]
public string Login
{
get { return this[LoginKey].ToString(); }
set { this[LoginKey] = value; }
}
[ConfigurationProperty(PasswordKey, IsKey = true, IsRequired = true)]
public string Password
{
get { return this[PasswordKey].ToString(); }
set { this[PasswordKey] = value; }
}
}
}

View file

@ -0,0 +1,50 @@
using System.Configuration;
using WebsitePanel.WebDav.Core.Config.Entities;
using WebsitePanel.WebDavPortal.WebConfigSections;
namespace WebsitePanel.WebDav.Core.Config
{
public class WebDavAppConfigManager : IWebDavAppConfig
{
private static WebDavAppConfigManager _instance;
private readonly WebDavExplorerConfigurationSettingsSection _configSection;
private WebDavAppConfigManager()
{
_configSection = ((WebDavExplorerConfigurationSettingsSection) ConfigurationManager.GetSection(WebDavExplorerConfigurationSettingsSection.SectionName));
WebsitePanelConstantUserParameters = new WebsitePanelConstantUserParameters();
ElementsRendering = new ElementsRendering();
SessionKeys = new SessionKeysCollection();
FileIcons = new FileIconsDictionary();
HttpErrors = new HttpErrorsCollection();
OfficeOnline = new OfficeOnlineCollection();
}
public static WebDavAppConfigManager Instance
{
get { return _instance ?? (_instance = new WebDavAppConfigManager()); }
}
public string UserDomain
{
get { return _configSection.UserDomain.Value; }
}
public string ApplicationName
{
get { return _configSection.ApplicationName.Value; }
}
public string AuthTimeoutCookieName
{
get { return _configSection.AuthTimeoutCookieName.Value; }
}
public ElementsRendering ElementsRendering { get; private set; }
public WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; private set; }
public SessionKeysCollection SessionKeys { get; private set; }
public FileIconsDictionary FileIcons { get; private set; }
public HttpErrorsCollection HttpErrors { get; private set; }
public OfficeOnlineCollection OfficeOnline { get; private set; }
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
namespace WebsitePanel.WebDav.Core.Interfaces.Security
{
public interface IAuthenticationService
{
WspPrincipal LogIn(string login, string password);
void CreateAuthenticationTicket(WspPrincipal principal);
void LogOut();
}
}

View file

@ -0,0 +1,90 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.33440
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebsitePanel.WebDav.Core.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class HttpErrors {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal HttpErrors() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebsitePanel.WebDav.Core.Resources.HttpErrors", typeof(HttpErrors).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to The requested content was not found.
/// </summary>
internal static string _404 {
get {
return ResourceManager.GetString("_404", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The following server error was encountered.
/// </summary>
internal static string _500 {
get {
return ResourceManager.GetString("_500", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Fatal error.
/// </summary>
internal static string Default {
get {
return ResourceManager.GetString("Default", resourceCulture);
}
}
}
}

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Default" xml:space="preserve">
<value>Fatal error</value>
</data>
<data name="_404" xml:space="preserve">
<value>The requested content was not found</value>
</data>
<data name="_500" xml:space="preserve">
<value>The following server error was encountered</value>
</data>
</root>

View file

@ -0,0 +1,74 @@
using System;
using System.DirectoryServices.AccountManagement;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Security;
using WebsitePanel.WebDav.Core.Interfaces.Security;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
using WebsitePanel.WebDav.Core.Security.Cryptography;
using WebsitePanel.WebDav.Core.Wsp.Framework;
namespace WebsitePanel.WebDav.Core.Security.Authentication
{
public class FormsAuthenticationService : IAuthenticationService
{
private readonly ICryptography _cryptography;
private readonly PrincipalContext _principalContext;
public FormsAuthenticationService(ICryptography cryptography)
{
_cryptography = cryptography;
_principalContext = new PrincipalContext(ContextType.Domain);
}
public WspPrincipal LogIn(string login, string password)
{
if (_principalContext.ValidateCredentials(login, password) == false)
{
return null;
}
var principal = new WspPrincipal(login);
var exchangeAccount = WSP.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(login);
var organization = WSP.Services.Organizations.GetOrganization(exchangeAccount.ItemId);
principal.AccountId = exchangeAccount.AccountId;
principal.ItemId = exchangeAccount.ItemId;
principal.OrganizationId = organization.OrganizationId;
principal.DisplayName = exchangeAccount.DisplayName;
principal.EncryptedPassword = _cryptography.Encrypt(password);
CreateAuthenticationTicket(principal);
HttpContext.Current.User = principal;
return principal;
}
public void CreateAuthenticationTicket(WspPrincipal principal)
{
var serializer = new JavaScriptSerializer();
string userData = serializer.Serialize(principal);
var authTicket = new FormsAuthenticationTicket(1, principal.Identity.Name, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout),
FormsAuthentication.SlidingExpiration, userData);
var encTicket = FormsAuthentication.Encrypt(authTicket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
if (FormsAuthentication.SlidingExpiration)
{
cookie.Expires = authTicket.Expiration;
}
HttpContext.Current.Response.Cookies.Add(cookie);
}
public void LogOut()
{
FormsAuthentication.SignOut();
}
}
}

View file

@ -0,0 +1,47 @@
using System.Security.Principal;
using System.Web.Script.Serialization;
using System.Web.Security;
using System.Xml.Serialization;
namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
{
public class WspPrincipal : IPrincipal
{
public int AccountId { get; set; }
public string OrganizationId { get; set; }
public int ItemId { get; set; }
public string Login { get; set; }
public string EncryptedPassword { get; set; }
public string DisplayName { get; set; }
public string UserName
{
get
{
return !string.IsNullOrEmpty(Login) ? Login.Split('@')[0] : string.Empty;
}
}
[XmlIgnore, ScriptIgnore]
public IIdentity Identity { get; private set; }
public WspPrincipal(string username)
{
Identity = new GenericIdentity(username);
Login = username;
}
public WspPrincipal()
{
}
public bool IsInRole(string role)
{
return Identity.IsAuthenticated
&& !string.IsNullOrWhiteSpace(role)
&& Roles.IsUserInRole(Identity.Name, role);
}
}
}

View file

@ -0,0 +1,195 @@
using System;
using System.Configuration;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Win32;
namespace WebsitePanel.WebDav.Core.Security.Cryptography
{
public class CryptoUtils : ICryptography
{
private string EnterpriseServerRegistryPath = "SOFTWARE\\WebsitePanel\\EnterpriseServer";
private string CryptoKey
{
get
{
string Key = ConfigurationManager.AppSettings["WebsitePanel.AltCryptoKey"];
string value = string.Empty;
if (!string.IsNullOrEmpty(Key))
{
RegistryKey root = Registry.LocalMachine;
RegistryKey rk = root.OpenSubKey(EnterpriseServerRegistryPath);
if (rk != null)
{
value = (string)rk.GetValue(Key, null);
rk.Close();
}
}
if (!string.IsNullOrEmpty(value))
return value;
else
return ConfigurationManager.AppSettings["WebsitePanel.CryptoKey"];
}
}
private bool EncryptionEnabled
{
get
{
return (ConfigurationManager.AppSettings["WebsitePanel.EncryptionEnabled"] != null)
? Boolean.Parse(ConfigurationManager.AppSettings["WebsitePanel.EncryptionEnabled"]) : true;
}
}
public string Encrypt(string InputText)
{
string Password = CryptoKey;
if (!EncryptionEnabled)
return InputText;
if (InputText == null)
return InputText;
// We are now going to create an instance of the
// Rihndael class.
RijndaelManaged RijndaelCipher = new RijndaelManaged();
// First we need to turn the input strings into a byte array.
byte[] PlainText = System.Text.Encoding.Unicode.GetBytes(InputText);
// We are using salt to make it harder to guess our key
// using a dictionary attack.
byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
// The (Secret Key) will be generated from the specified
// password and salt.
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, Salt);
// Create a encryptor from the existing SecretKey bytes.
// We use 32 bytes for the secret key
// (the default Rijndael key length is 256 bit = 32 bytes) and
// then 16 bytes for the IV (initialization vector),
// (the default Rijndael IV length is 128 bit = 16 bytes)
ICryptoTransform Encryptor = RijndaelCipher.CreateEncryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16));
// Create a MemoryStream that is going to hold the encrypted bytes
MemoryStream memoryStream = new MemoryStream();
// Create a CryptoStream through which we are going to be processing our data.
// CryptoStreamMode.Write means that we are going to be writing data
// to the stream and the output will be written in the MemoryStream
// we have provided. (always use write mode for encryption)
CryptoStream cryptoStream = new CryptoStream(memoryStream, Encryptor, CryptoStreamMode.Write);
// Start the encryption process.
cryptoStream.Write(PlainText, 0, PlainText.Length);
// Finish encrypting.
cryptoStream.FlushFinalBlock();
// Convert our encrypted data from a memoryStream into a byte array.
byte[] CipherBytes = memoryStream.ToArray();
// Close both streams.
memoryStream.Close();
cryptoStream.Close();
// Convert encrypted data into a base64-encoded string.
// A common mistake would be to use an Encoding class for that.
// It does not work, because not all byte values can be
// represented by characters. We are going to be using Base64 encoding
// That is designed exactly for what we are trying to do.
string EncryptedData = Convert.ToBase64String(CipherBytes);
// Return encrypted string.
return EncryptedData;
}
public string Decrypt(string InputText)
{
try
{
if (!EncryptionEnabled)
return InputText;
if (InputText == null || InputText == "")
return InputText;
string Password = CryptoKey;
RijndaelManaged RijndaelCipher = new RijndaelManaged();
byte[] EncryptedData = Convert.FromBase64String(InputText);
byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, Salt);
// Create a decryptor from the existing SecretKey bytes.
ICryptoTransform Decryptor = RijndaelCipher.CreateDecryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16));
MemoryStream memoryStream = new MemoryStream(EncryptedData);
// Create a CryptoStream. (always use Read mode for decryption).
CryptoStream cryptoStream = new CryptoStream(memoryStream, Decryptor, CryptoStreamMode.Read);
// Since at this point we don't know what the size of decrypted data
// will be, allocate the buffer long enough to hold EncryptedData;
// DecryptedData is never longer than EncryptedData.
byte[] PlainText = new byte[EncryptedData.Length];
// Start decrypting.
int DecryptedCount = cryptoStream.Read(PlainText, 0, PlainText.Length);
memoryStream.Close();
cryptoStream.Close();
// Convert decrypted data into a string.
string DecryptedData = Encoding.Unicode.GetString(PlainText, 0, DecryptedCount);
// Return decrypted string.
return DecryptedData;
}
catch
{
return "";
}
}
private string SHA1(string plainText)
{
// Convert plain text into a byte array.
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
HashAlgorithm hash = new SHA1Managed(); ;
// Compute hash value of our plain text with appended salt.
byte[] hashBytes = hash.ComputeHash(plainTextBytes);
// Return the result.
return Convert.ToBase64String(hashBytes);
}
}
}

View file

@ -0,0 +1,8 @@
namespace WebsitePanel.WebDav.Core.Security.Cryptography
{
public interface ICryptography
{
string Encrypt(string plainText);
string Decrypt(string encryptedText);
}
}

View file

@ -11,6 +11,8 @@
<AssemblyName>WebsitePanel.WebDav.Core</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -30,18 +32,82 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</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>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.Web">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Services" />
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebsitePanel.EnterpriseServer.Client">
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
</Reference>
<Reference Include="WebsitePanel.Providers.Base">
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.Providers.Base.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Config\Entities\AbstractConfigCollection.cs" />
<Compile Include="Config\Entities\ElementsRendering.cs" />
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
<Compile Include="Config\IWebDavAppConfig.cs" />
<Compile Include="Config\WebConfigSections\ApplicationNameElement.cs" />
<Compile Include="Config\WebConfigSections\AuthTimeoutCookieNameElement.cs" />
<Compile Include="Config\WebConfigSections\ElementsRenderingElement.cs" />
<Compile Include="Config\WebConfigSections\FileIconsElement.cs" />
<Compile Include="Config\WebConfigSections\FileIconsElementCollection.cs" />
<Compile Include="Config\WebConfigSections\OfficeOnlineElement.cs" />
<Compile Include="Config\WebConfigSections\OfficeOnlineElementCollection.cs" />
<Compile Include="Config\WebConfigSections\SessionKeysElement.cs" />
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
<Compile Include="Config\WebDavAppConfigManager.cs" />
<Compile Include="Exceptions\UnauthorizedException.cs" />
<Compile Include="Exceptions\WebDavException.cs" />
<Compile Include="Exceptions\WebDavHttpException.cs" />
@ -49,6 +115,7 @@
<Compile Include="IFolder.cs" />
<Compile Include="IHierarchyItem.cs" />
<Compile Include="IItemContent.cs" />
<Compile Include="Interfaces\Security\IAuthenticationService.cs" />
<Compile Include="IResource.cs" />
<Compile Include="IResumableUpload.cs" />
<Compile Include="ItemType.cs" />
@ -56,9 +123,45 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Property.cs" />
<Compile Include="PropertyName.cs" />
<Compile Include="Resources\HttpErrors.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>HttpErrors.resx</DependentUpon>
</Compile>
<Compile Include="Security\Cryptography\CryptoUtils.cs" />
<Compile Include="Security\Cryptography\ICryptography.cs" />
<Compile Include="Security\Authentication\FormsAuthenticationService.cs" />
<Compile Include="Security\Authentication\Principals\WspPrincipal.cs" />
<Compile Include="WebDavSession.cs" />
<Compile Include="WspContext.cs" />
<Compile Include="Wsp\Framework\WSP.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\ActiveDirectory\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebsitePanel.WebPortal\WebsitePanel.WebPortal.csproj">
<Project>{C99EFB18-FFE7-45BB-8CA8-29336F3E8C68}</Project>
<Name>WebsitePanel.WebPortal</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\HttpErrors.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>HttpErrors.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View file

@ -0,0 +1,287 @@
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Services3;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.EnterpriseServer.HostedSolution;
using WebsitePanel.WebDav.Core.Config;
using WebsitePanel.WebDav.Core.Security.Cryptography;
using WebsitePanel.WebPortal;
namespace WebsitePanel.WebDav.Core.Wsp.Framework
{
// WSP.Services
public class WSP
{
private readonly ICryptography _cryptography;
protected WSP()
{
_cryptography = DependencyResolver.Current.GetService<ICryptography>();
}
public static WSP Services
{
get
{
WSP services = (WSP)HttpContext.Current.Items["WebServices"];
if (services == null)
{
services = new WSP();
HttpContext.Current.Items["WebServices"] = services;
}
return services;
}
}
public esCRM CRM
{
get
{
return GetCachedProxy<esCRM>();
}
}
public esVirtualizationServer VPS
{
get { return GetCachedProxy<esVirtualizationServer>(); }
}
public esVirtualizationServerForPrivateCloud VPSPC
{
get { return GetCachedProxy<esVirtualizationServerForPrivateCloud>(); }
}
public esBlackBerry BlackBerry
{
get { return GetCachedProxy<esBlackBerry>(); }
}
public esOCS OCS
{
get { return GetCachedProxy<esOCS>(); }
}
public esLync Lync
{
get { return GetCachedProxy<esLync>(); }
}
public esOrganizations Organizations
{
get
{
return GetCachedProxy<esOrganizations>();
}
}
public esSystem System
{
get { return GetCachedProxy<esSystem>(); }
}
public esApplicationsInstaller ApplicationsInstaller
{
get { return GetCachedProxy<esApplicationsInstaller>(); }
}
public esWebApplicationGallery WebApplicationGallery
{
get { return GetCachedProxy<esWebApplicationGallery>(); }
}
public esAuditLog AuditLog
{
get { return GetCachedProxy<esAuditLog>(); }
}
public esAuthentication Authentication
{
get { return GetCachedProxy<esAuthentication>(false); }
}
public esComments Comments
{
get { return GetCachedProxy<esComments>(); }
}
public esDatabaseServers DatabaseServers
{
get { return GetCachedProxy<esDatabaseServers>(); }
}
public esFiles Files
{
get { return GetCachedProxy<esFiles>(); }
}
public esFtpServers FtpServers
{
get { return GetCachedProxy<esFtpServers>(); }
}
public esMailServers MailServers
{
get { return GetCachedProxy<esMailServers>(); }
}
public esOperatingSystems OperatingSystems
{
get { return GetCachedProxy<esOperatingSystems>(); }
}
public esPackages Packages
{
get { return GetCachedProxy<esPackages>(); }
}
public esScheduler Scheduler
{
get { return GetCachedProxy<esScheduler>(); }
}
public esTasks Tasks
{
get { return GetCachedProxy<esTasks>(); }
}
public esServers Servers
{
get { return GetCachedProxy<esServers>(); }
}
public esStatisticsServers StatisticsServers
{
get { return GetCachedProxy<esStatisticsServers>(); }
}
public esUsers Users
{
get { return GetCachedProxy<esUsers>(); }
}
public esWebServers WebServers
{
get { return GetCachedProxy<esWebServers>(); }
}
public esSharePointServers SharePointServers
{
get { return GetCachedProxy<esSharePointServers>(); }
}
public esHostedSharePointServers HostedSharePointServers
{
get { return GetCachedProxy<esHostedSharePointServers>(); }
}
public esImport Import
{
get { return GetCachedProxy<esImport>(); }
}
public esBackup Backup
{
get { return GetCachedProxy<esBackup>(); }
}
public esExchangeServer ExchangeServer
{
get { return GetCachedProxy<esExchangeServer>(); }
}
public esHeliconZoo HeliconZoo
{
get { return GetCachedProxy<esHeliconZoo>(); }
}
public esEnterpriseStorage EnterpriseStorage
{
get { return GetCachedProxy<esEnterpriseStorage>(); }
}
public esRemoteDesktopServices RDS
{
get { return GetCachedProxy<esRemoteDesktopServices>(); }
}
protected virtual T GetCachedProxy<T>()
{
return GetCachedProxy<T>(true);
}
protected virtual T GetCachedProxy<T>(bool secureCalls)
{
Type t = typeof(T);
string key = t.FullName + ".ServiceProxy";
T proxy = (T)HttpContext.Current.Items[key];
if (proxy == null)
{
proxy = (T)Activator.CreateInstance(t);
HttpContext.Current.Items[key] = proxy;
}
object p = proxy;
// configure proxy
ConfigureEnterpriseServerProxy((WebServicesClientProtocol)p, secureCalls);
return proxy;
}
public void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy)
{
// load ES properties
string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"];
EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
cnfg.EnterpriseServerUrl = serverUrl;
// create assertion
if (applyPolicy)
{
cnfg.Username = WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Login;
cnfg.Password = _cryptography.Decrypt(WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Password);
}
cnfg.Configure(proxy);
}
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
namespace WebsitePanel.WebDav.Core
{
public class WspContext
{
public static WspPrincipal User { get { return HttpContext.Current.User as WspPrincipal; } }
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<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.WebPages" version="3.2.2" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
</packages>