WebDav Explorer code cleanup
This commit is contained in:
parent
a4c6331a2a
commit
f5b41b5c85
17 changed files with 210 additions and 216 deletions
|
@ -1,16 +0,0 @@
|
||||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
|
||||||
{
|
|
||||||
public class Rfc2898CryptographyParameters : AbstractConfigCollection
|
|
||||||
{
|
|
||||||
public string PasswordHash { get; private set; }
|
|
||||||
public string SaltKey { get; private set; }
|
|
||||||
public string VIKey { get; private set; }
|
|
||||||
|
|
||||||
public Rfc2898CryptographyParameters()
|
|
||||||
{
|
|
||||||
PasswordHash = ConfigSection.Rfc2898Cryptography.PasswordHash;
|
|
||||||
SaltKey = ConfigSection.Rfc2898Cryptography.SaltKey;
|
|
||||||
VIKey = ConfigSection.Rfc2898Cryptography.VIKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ namespace WebsitePanel.WebDavPortal.Config
|
||||||
string ApplicationName { get; }
|
string ApplicationName { get; }
|
||||||
ElementsRendering ElementsRendering { get; }
|
ElementsRendering ElementsRendering { get; }
|
||||||
WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; }
|
WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; }
|
||||||
Rfc2898CryptographyParameters Rfc2898CryptographyParameters { get; }
|
|
||||||
ConnectionStringsCollection ConnectionStrings { get; }
|
ConnectionStringsCollection ConnectionStrings { get; }
|
||||||
SessionKeysCollection SessionKeys { get; }
|
SessionKeysCollection SessionKeys { get; }
|
||||||
FileIconsDictionary FileIcons { get; }
|
FileIconsDictionary FileIcons { get; }
|
||||||
|
|
|
@ -12,7 +12,6 @@ namespace WebsitePanel.WebDavPortal.Config
|
||||||
private WebDavAppConfigManager()
|
private WebDavAppConfigManager()
|
||||||
{
|
{
|
||||||
_configSection = ((WebDavExplorerConfigurationSettingsSection) ConfigurationManager.GetSection(WebDavExplorerConfigurationSettingsSection.SectionName));
|
_configSection = ((WebDavExplorerConfigurationSettingsSection) ConfigurationManager.GetSection(WebDavExplorerConfigurationSettingsSection.SectionName));
|
||||||
Rfc2898CryptographyParameters = new Rfc2898CryptographyParameters();
|
|
||||||
WebsitePanelConstantUserParameters = new WebsitePanelConstantUserParameters();
|
WebsitePanelConstantUserParameters = new WebsitePanelConstantUserParameters();
|
||||||
ElementsRendering = new ElementsRendering();
|
ElementsRendering = new ElementsRendering();
|
||||||
ConnectionStrings = new ConnectionStringsCollection();
|
ConnectionStrings = new ConnectionStringsCollection();
|
||||||
|
@ -39,7 +38,6 @@ namespace WebsitePanel.WebDavPortal.Config
|
||||||
|
|
||||||
public ElementsRendering ElementsRendering { get; private set; }
|
public ElementsRendering ElementsRendering { get; private set; }
|
||||||
public WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; private set; }
|
public WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; private set; }
|
||||||
public Rfc2898CryptographyParameters Rfc2898CryptographyParameters { get; private set; }
|
|
||||||
public ConnectionStringsCollection ConnectionStrings { get; private set; }
|
public ConnectionStringsCollection ConnectionStrings { get; private set; }
|
||||||
public SessionKeysCollection SessionKeys { get; private set; }
|
public SessionKeysCollection SessionKeys { get; private set; }
|
||||||
public FileIconsDictionary FileIcons { get; private set; }
|
public FileIconsDictionary FileIcons { get; private set; }
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
namespace WebsitePanel.WebDavPortal.Constants
|
|
||||||
{
|
|
||||||
public static class DirectoryEntryPropertyNameConstants
|
|
||||||
{
|
|
||||||
public const string DistinguishedName = "distinguishedName";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -41,14 +41,6 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Login(AccountModel model)
|
public ActionResult Login(AccountModel model)
|
||||||
{
|
{
|
||||||
//var ldapConnectionString = WebDavAppConfigManager.Instance.ConnectionStrings.LdapServer;
|
|
||||||
//if (ldapConnectionString == null || !Regex.IsMatch(ldapConnectionString, @"^LDAP://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$"))
|
|
||||||
// return View(new AccountModel { LdapError = "LDAP server address is invalid" });
|
|
||||||
|
|
||||||
//var principal = new WebDavPortalIdentity(model.Login, model.Password);
|
|
||||||
//bool isAuthenticated = principal.Identity.IsAuthenticated;
|
|
||||||
//var organizationId = principal.GetOrganizationId();
|
|
||||||
|
|
||||||
AutheticationToServicesUsingWebsitePanelUser();
|
AutheticationToServicesUsingWebsitePanelUser();
|
||||||
var exchangeAccount = ES.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(model.Login);
|
var exchangeAccount = ES.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(model.Login);
|
||||||
var isAuthenticated = exchangeAccount != null && exchangeAccount.AccountPassword == model.Password;
|
var isAuthenticated = exchangeAccount != null && exchangeAccount.AccountPassword == model.Password;
|
||||||
|
@ -63,7 +55,6 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
{
|
{
|
||||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = model;
|
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = model;
|
||||||
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = new WebDavManager(new NetworkCredential(model.Login, model.Password, WebDavAppConfigManager.Instance.UserDomain), exchangeAccount.ItemId);
|
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = new WebDavManager(new NetworkCredential(model.Login, model.Password, WebDavAppConfigManager.Instance.UserDomain), exchangeAccount.ItemId);
|
||||||
//Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = new WebDavManager(new NetworkCredential("Administrator", "WSP99cc$$1", WebDavAppConfigManager.Instance.UserDomain), exchangeAccount.ItemId);
|
|
||||||
}
|
}
|
||||||
catch (ConnectToWebDavServerException exception)
|
catch (ConnectToWebDavServerException exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,11 +31,6 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
if (org != webDavManager.OrganizationName)
|
if (org != webDavManager.OrganizationName)
|
||||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||||
|
|
||||||
|
|
||||||
var test = Url.Action("ShowContent", "FileSystem");
|
|
||||||
var tetet = Url.Action("ShowContent", "FileSystem", new { org = "pgrorg" });
|
|
||||||
|
|
||||||
|
|
||||||
string fileName = pathPart.Split('/').Last();
|
string fileName = pathPart.Split('/').Last();
|
||||||
if (webDavManager.IsFile(fileName))
|
if (webDavManager.IsFile(fileName))
|
||||||
{
|
{
|
||||||
|
@ -52,7 +47,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
catch (UnauthorizedException exc)
|
catch (UnauthorizedException)
|
||||||
{
|
{
|
||||||
throw new HttpException(404, "Not Found");
|
throw new HttpException(404, "Not Found");
|
||||||
}
|
}
|
||||||
|
@ -81,7 +76,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
return PartialView("_ResourseCollectionPartial", result);
|
return PartialView("_ResourseCollectionPartial", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return new HttpStatusCodeResult(HttpStatusCode.NoContent); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,198 @@
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDavPortal.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,62 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Cryptography
|
|
||||||
{
|
|
||||||
public class Rfc2898Cryptography : ICryptography
|
|
||||||
{
|
|
||||||
public string PasswordHash { get; set; }
|
|
||||||
public string SaltKey { get; set; }
|
|
||||||
public string VIKey { get; set; }
|
|
||||||
|
|
||||||
public Rfc2898Cryptography(string passwordHash, string saltKey, string viKey)
|
|
||||||
{
|
|
||||||
PasswordHash = passwordHash;
|
|
||||||
SaltKey = saltKey;
|
|
||||||
VIKey = viKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Encrypt(string plainText)
|
|
||||||
{
|
|
||||||
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
|
|
||||||
|
|
||||||
byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256/8);
|
|
||||||
var symmetricKey = new RijndaelManaged {Mode = CipherMode.CBC, Padding = PaddingMode.Zeros};
|
|
||||||
ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));
|
|
||||||
|
|
||||||
byte[] cipherTextBytes;
|
|
||||||
|
|
||||||
using (var memoryStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
|
|
||||||
{
|
|
||||||
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
|
|
||||||
cryptoStream.FlushFinalBlock();
|
|
||||||
cipherTextBytes = memoryStream.ToArray();
|
|
||||||
cryptoStream.Close();
|
|
||||||
}
|
|
||||||
memoryStream.Close();
|
|
||||||
}
|
|
||||||
return Convert.ToBase64String(cipherTextBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Decrypt(string encryptedText)
|
|
||||||
{
|
|
||||||
byte[] cipherTextBytes = Convert.FromBase64String(encryptedText);
|
|
||||||
byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256/8);
|
|
||||||
var symmetricKey = new RijndaelManaged {Mode = CipherMode.CBC, Padding = PaddingMode.None};
|
|
||||||
|
|
||||||
ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));
|
|
||||||
var memoryStream = new MemoryStream(cipherTextBytes);
|
|
||||||
var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
|
|
||||||
var plainTextBytes = new byte[cipherTextBytes.Length];
|
|
||||||
|
|
||||||
int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
|
|
||||||
memoryStream.Close();
|
|
||||||
cryptoStream.Close();
|
|
||||||
return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount).TrimEnd("\0".ToCharArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
using Ninject.Activation;
|
|
||||||
using WebsitePanel.WebDavPortal.Config;
|
|
||||||
using WebsitePanel.WebDavPortal.Cryptography;
|
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.DependencyInjection
|
|
||||||
{
|
|
||||||
public class Rfc2898CryptographyProvider : Provider<Rfc2898Cryptography>
|
|
||||||
{
|
|
||||||
protected override Rfc2898Cryptography CreateInstance(IContext context)
|
|
||||||
{
|
|
||||||
var rfc2898Cryptography =
|
|
||||||
new Rfc2898Cryptography(WebDavAppConfigManager.Instance.Rfc2898CryptographyParameters.PasswordHash,
|
|
||||||
WebDavAppConfigManager.Instance.Rfc2898CryptographyParameters.SaltKey,
|
|
||||||
WebDavAppConfigManager.Instance.Rfc2898CryptographyParameters.VIKey);
|
|
||||||
|
|
||||||
return rfc2898Cryptography;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,7 +13,7 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||||
Bind<HttpSessionState>().ToConstant(HttpContext.Current.Session);
|
Bind<HttpSessionState>().ToConstant(HttpContext.Current.Session);
|
||||||
Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
||||||
Bind<AccountModel>().ToProvider<AccountInfoProvider>();
|
Bind<AccountModel>().ToProvider<AccountInfoProvider>();
|
||||||
Bind<ICryptography>().ToProvider<Rfc2898CryptographyProvider>();
|
Bind<ICryptography>().To<CryptoUtils>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,40 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.DirectoryServices;
|
|
||||||
using System.Security.Principal;
|
|
||||||
using WebsitePanel.WebDavPortal.Constants;
|
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Models
|
|
||||||
{
|
|
||||||
public class WebDavPortalIdentity
|
|
||||||
{
|
|
||||||
private readonly DirectoryEntry _dictionaryEntry;
|
|
||||||
public IIdentity Identity { get; protected set; }
|
|
||||||
|
|
||||||
public WebDavPortalIdentity(string userName, string password) : this(null, userName, password)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebDavPortalIdentity(string path, string userName, string password)
|
|
||||||
{
|
|
||||||
_dictionaryEntry = new DirectoryEntry(path, userName, password);
|
|
||||||
Identity = new DirectoryIdentity(_dictionaryEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object GetADObjectProperty(string name)
|
|
||||||
{
|
|
||||||
return _dictionaryEntry.Properties.Contains(name) ? _dictionaryEntry.Properties[name][0] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetOrganizationId()
|
|
||||||
{
|
|
||||||
const string distinguishedName = "CN=user200000,OU=virt,OU=TESTOU,DC=test,DC=local";
|
|
||||||
//string distinguishedName = GetADObjectProperty(DirectoryEntryPropertyNameConstants.DistinguishedName).ToString();
|
|
||||||
|
|
||||||
string[] distinguishedNameParts = distinguishedName.Split(',', '=');
|
|
||||||
if (distinguishedNameParts[2] != "OU")
|
|
||||||
throw new Exception(@"Problems with parsing 'distinguishedName' DirectoryEntry property");
|
|
||||||
|
|
||||||
return distinguishedNameParts[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="container row">
|
<div class="container row">
|
||||||
<form class="form-horizontal" method="POST" role="form">
|
<form class="form-horizontal" method="POST" role="form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h3 class="col-sm-offset-1">Authentication on the LDAP server</h3>
|
<h3 class="col-sm-offset-1">Sign In</h3>
|
||||||
</div>
|
</div>
|
||||||
@if (Model != null && !string.IsNullOrEmpty(Model.LdapError))
|
@if (Model != null && !string.IsNullOrEmpty(Model.LdapError))
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
var account = kernel.Get<AccountModel>();
|
var account = kernel.Get<AccountModel>();
|
||||||
if (account != null)
|
if (account != null)
|
||||||
{
|
{
|
||||||
<h4 class="nav navbar-text navbar-right">@account.Login</h4>
|
<h4 class="nav navbar-text navbar-right">@account.UserName</h4>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
<add key="WebPortal.PageTitleProvider" value="WebsitePanel.Portal.WebPortalPageTitleProvider, WebsitePanel.Portal.Modules" />
|
<add key="WebPortal.PageTitleProvider" value="WebsitePanel.Portal.WebPortalPageTitleProvider, WebsitePanel.Portal.Modules" />
|
||||||
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
|
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
|
||||||
<add key="SessionValidationKey" value="DAD46D476F85E0198BCA134D7AA5CC1D7" />
|
<add key="SessionValidationKey" value="DAD46D476F85E0198BCA134D7AA5CC1D7" />
|
||||||
|
|
||||||
|
<add key="WebsitePanel.CryptoKey" value="jj2n22t2kje035cg4l77" />
|
||||||
|
<add key="WebsitePanel.EncryptionEnabled" value="true"/>
|
||||||
|
<add key="WebsitePanel.AltCryptoKey" value="CryptoKey"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<webDavExplorerConfigurationSettings>
|
<webDavExplorerConfigurationSettings>
|
||||||
<userDomain value="WEBSITEPANEL"/>
|
<!--<userDomain value=""/>-->
|
||||||
<applicationName value="WebDAV Explorer"/>
|
<applicationName value="WebDAV Explorer"/>
|
||||||
<elementsRendering defaultCount="20" addElementsCount="20"/>
|
<elementsRendering defaultCount="20" addElementsCount="20"/>
|
||||||
<websitePanelConstantUser login="/s+FT5uzVxg1Klox7wS97A==" password="L8FtiUt71E1Do/RmlN6bPA==" />
|
<websitePanelConstantUser login="8P5wdPdqguwaFOGe/Zn06idbqaeoa7ZhST/U0hFYrYA=" password="HtR7J8dtBhovYLigXNtVutxqpvaE48Z+FBIokWZlR/g=" />
|
||||||
<rfc2898Cryptography passwordHash="66640c02dcdec47fb220539c1d47d80da5a98cd9c9fcebc317512db29a947e5c54667a85fdfdecfbde17ab76375bb9309e47025f7bb19a2c5df0c1be039d1c3d"
|
|
||||||
saltKey="f4f3397d550320975770be09e8f1510b1971b4876658ebb960a4b2df5b0d95059e8ac2c64eb8c0e0614df93bfbc31ece0f33121fc9c7bc9219db583eab3fee06"
|
|
||||||
VIKey="@1B2c3D4e5F6g7H8" />
|
|
||||||
<appConnectionStrings>
|
<appConnectionStrings>
|
||||||
<add key="WebDavServerConnectionString" connectionString="http://webdavtest.com"/>
|
<add key="WebDavServerConnectionString" connectionString="http://webdavtest.com"/>
|
||||||
<add key="LdapServerConnectionString" connectionString="LDAP://itransition.corp"/>
|
<add key="LdapServerConnectionString" connectionString="LDAP://itransition.corp"/>
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
using System.Configuration;
|
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|
||||||
{
|
|
||||||
public class Rfc2898CryptographyElement : ConfigurationElement
|
|
||||||
{
|
|
||||||
private const string PasswordHashKey = "passwordHash";
|
|
||||||
private const string SaltKeyKey = "saltKey";
|
|
||||||
private const string ViKeyKey = "VIKey";
|
|
||||||
|
|
||||||
[ConfigurationProperty(PasswordHashKey, IsKey = true, IsRequired = true, DefaultValue = "66640c02dcdec47fb220539c1d47d80da5a98cd9c9fcebc317512db29a947e5c54667a85fdfdecfbde17ab76375bb9309e47025f7bb19a2c5df0c1be039d1c3d")]
|
|
||||||
public string PasswordHash
|
|
||||||
{
|
|
||||||
get { return this[PasswordHashKey].ToString(); }
|
|
||||||
set { this[PasswordHashKey] = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConfigurationProperty(SaltKeyKey, IsKey = true, IsRequired = true, DefaultValue = "f4f3397d550320975770be09e8f1510b1971b4876658ebb960a4b2df5b0d95059e8ac2c64eb8c0e0614df93bfbc31ece0f33121fc9c7bc9219db583eab3fee06")]
|
|
||||||
public string SaltKey
|
|
||||||
{
|
|
||||||
get { return this[SaltKeyKey].ToString(); }
|
|
||||||
set { this[SaltKeyKey] = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConfigurationProperty(ViKeyKey, IsKey = true, IsRequired = true, DefaultValue = "@1B2c3D4e5F6g7H8")]
|
|
||||||
public string VIKey
|
|
||||||
{
|
|
||||||
get { return this[ViKeyKey].ToString(); }
|
|
||||||
set { this[ViKeyKey] = value; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,13 +44,6 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
set { this[ElementsRenderingKey] = value; }
|
set { this[ElementsRenderingKey] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConfigurationProperty(Rfc2898CryptographyKey, IsRequired = true)]
|
|
||||||
public Rfc2898CryptographyElement Rfc2898Cryptography
|
|
||||||
{
|
|
||||||
get { return (Rfc2898CryptographyElement)this[Rfc2898CryptographyKey]; }
|
|
||||||
set { this[Rfc2898CryptographyKey] = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConfigurationProperty(ConnectionStringsKey, IsDefaultCollection = false)]
|
[ConfigurationProperty(ConnectionStringsKey, IsDefaultCollection = false)]
|
||||||
public AppConnectionStringsElementCollection ConnectionStrings
|
public AppConnectionStringsElementCollection ConnectionStrings
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,22 +148,19 @@
|
||||||
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
|
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
|
||||||
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
|
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
|
||||||
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
|
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
|
||||||
<Compile Include="Config\Entities\Rfc2898CryptographyParameters.cs" />
|
|
||||||
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
||||||
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
||||||
<Compile Include="Config\IWebDavAppConfig.cs" />
|
<Compile Include="Config\IWebDavAppConfig.cs" />
|
||||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||||
<Compile Include="Constants\DirectoryEntryPropertyNameConstants.cs" />
|
|
||||||
<Compile Include="Constraints\OrganizationRouteConstraint.cs" />
|
<Compile Include="Constraints\OrganizationRouteConstraint.cs" />
|
||||||
<Compile Include="Controllers\AccountController.cs" />
|
<Compile Include="Controllers\AccountController.cs" />
|
||||||
<Compile Include="Controllers\ErrorController.cs" />
|
<Compile Include="Controllers\ErrorController.cs" />
|
||||||
<Compile Include="Controllers\FileSystemController.cs" />
|
<Compile Include="Controllers\FileSystemController.cs" />
|
||||||
|
<Compile Include="Cryptography\CryptoUtils.cs" />
|
||||||
<Compile Include="Cryptography\ICryptography.cs" />
|
<Compile Include="Cryptography\ICryptography.cs" />
|
||||||
<Compile Include="Cryptography\Rfc2898Cryptography.cs" />
|
|
||||||
<Compile Include="CustomAttributes\LdapAuthorizationAttribute.cs" />
|
<Compile Include="CustomAttributes\LdapAuthorizationAttribute.cs" />
|
||||||
<Compile Include="DependencyInjection\AccountInfoProvider.cs" />
|
<Compile Include="DependencyInjection\AccountInfoProvider.cs" />
|
||||||
<Compile Include="DependencyInjection\WebDavExplorerAppModule.cs" />
|
<Compile Include="DependencyInjection\WebDavExplorerAppModule.cs" />
|
||||||
<Compile Include="DependencyInjection\Rfc2898CryptographyProvider.cs" />
|
|
||||||
<Compile Include="DependencyInjection\WebDavManagerProvider.cs" />
|
<Compile Include="DependencyInjection\WebDavManagerProvider.cs" />
|
||||||
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
||||||
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
||||||
|
@ -182,7 +179,6 @@
|
||||||
<Compile Include="Models\ModelForWebDav.cs" />
|
<Compile Include="Models\ModelForWebDav.cs" />
|
||||||
<Compile Include="Models\OfficeOnlineModel.cs" />
|
<Compile Include="Models\OfficeOnlineModel.cs" />
|
||||||
<Compile Include="Models\WebDavManager.cs" />
|
<Compile Include="Models\WebDavManager.cs" />
|
||||||
<Compile Include="Models\WebDavPortalIdentity.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="WebConfigSections\AppConnectionStringsElement.cs" />
|
<Compile Include="WebConfigSections\AppConnectionStringsElement.cs" />
|
||||||
<Compile Include="WebConfigSections\AppConnectionStringsElementCollection.cs" />
|
<Compile Include="WebConfigSections\AppConnectionStringsElementCollection.cs" />
|
||||||
|
@ -192,7 +188,6 @@
|
||||||
<Compile Include="WebConfigSections\FileIconsElementCollection.cs" />
|
<Compile Include="WebConfigSections\FileIconsElementCollection.cs" />
|
||||||
<Compile Include="WebConfigSections\OfficeOnlineElement.cs" />
|
<Compile Include="WebConfigSections\OfficeOnlineElement.cs" />
|
||||||
<Compile Include="WebConfigSections\OfficeOnlineElementCollection.cs" />
|
<Compile Include="WebConfigSections\OfficeOnlineElementCollection.cs" />
|
||||||
<Compile Include="WebConfigSections\Rfc2898CryptographyElement.cs" />
|
|
||||||
<Compile Include="WebConfigSections\SessionKeysElement.cs" />
|
<Compile Include="WebConfigSections\SessionKeysElement.cs" />
|
||||||
<Compile Include="WebConfigSections\SessionKeysElementCollection.cs" />
|
<Compile Include="WebConfigSections\SessionKeysElementCollection.cs" />
|
||||||
<Compile Include="WebConfigSections\UserDomainElement.cs" />
|
<Compile Include="WebConfigSections\UserDomainElement.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue