Initial project's source code check-in.

This commit is contained in:
ptsurbeleu 2011-07-13 16:07:32 -07:00
commit b03b0b373f
4573 changed files with 981205 additions and 0 deletions

View file

@ -0,0 +1,709 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using WebsitePanel.Providers.Common;
using System.Linq;
namespace WebsitePanel.Providers.Web
{
public class HtaccessFolder : IComparable
{
#region Constants
public const string HTTPD_CONF_FILE = "httpd.conf";
public const string HTACCESS_FILE = ".htaccess";
public const string HTPASSWDS_FILE = ".htpasswds";
public const string HTGROUPS_FILE = ".htgroups";
public const string AUTH_NAME_DIRECTIVE = "AuthName";
public const string AUTH_TYPE_DIRECTIVE = "AuthType";
public const string AUTH_TYPE_BASIC = "Basic";
public const string AUTH_TYPE_DIGEST = "Digest";
public const string DEFAULT_AUTH_TYPE = AUTH_TYPE_BASIC;
public static readonly string[] PASSWORD_ENCODING_TYPES = new string[]
{
"Apache MD5",
"Unix Crypt",
"SHA1"
};
public static readonly string[] AUTH_TYPES = new string[]
{
AUTH_TYPE_BASIC,
AUTH_TYPE_DIGEST
};
public const string REQUIRE_DIRECTIVE = "Require";
public const string AUTH_BASIC_PROVIDER_FILE = "AuthBasicProvider file";
public const string AUTH_DIGEST_PROVIDER_FILE = "AuthDigestProvider file";
public const string VALID_USER = "valid-user";
public const string REQUIRE_USER = "user";
public const string REQUIRE_GROUP = "group";
public const string AUTH_USER_FILE_DIRECTIVE = "AuthUserFile";
public const string AUTH_GROUP_FILE_DIRECTIVE = "AuthGroupFile";
protected static string LinesSeparator = System.Environment.NewLine;
#endregion
#region parsing regexps
protected static readonly Regex RE_AUTH_NAME = new Regex(@"^\s*AuthName\s+(.+)\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
protected static readonly Regex RE_AUTH_TYPE = new Regex(@"^\s*AuthType\s+(basic|digest)\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
protected static readonly Regex RE_REQUIRE = new Regex(@"^\s*Require\s+(.+)\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
protected static readonly Regex RE_AUTH_PROVIDER = new Regex(@"^\s*Auth(Basic|Digest)Provider\s+(file)\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
protected static readonly Regex RE_AUTH_USER_FILE = new Regex(@"^\s*AuthUserFile\s+(.+)\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
protected static readonly Regex RE_AUTH_GROUP_FILE = new Regex(@"^\s*AuthGroupFile\s+(.+)\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
public static readonly Regex RE_DIGEST_PASSWORD = new Regex(@"^[^:]*:[0-9a-f]{32}$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
#endregion
#region private fields
private string siteRootPath;
private string path;
private string contentPath;
private string htaccessContent;
private string authName;
private string authType = DEFAULT_AUTH_TYPE;
private List<string> users;
private List<string> groups;
private bool validUser = false;
private string authUserFile;
private string authGroupFile;
private bool doAuthUpdate = false;
private string filename = HTACCESS_FILE;
#endregion
#region public properties
public string Path
{
get { return path; }
set
{
path = value;
if (path.EndsWith("\\") && !path.Equals("\\"))
{
path = path.Substring(0, path.Length - 1);
}
}
}
public string ContentPath
{
get { return contentPath; }
set { contentPath = value; }
}
public string HtaccessContent
{
get { return htaccessContent; }
set { htaccessContent = value; }
}
public string AuthName
{
get { return authName; }
set { authName = value; }
}
public string AuthType
{
get { return authType; }
set { authType = value; }
}
public List<string> Users
{
get { return users; }
set { users = value; }
}
public List<string> Groups
{
get { return groups; }
set { groups = value; }
}
public bool ValidUser
{
get { return validUser; }
set { validUser = value; }
}
public bool DoAuthUpdate
{
get { return doAuthUpdate; }
set { doAuthUpdate = value; }
}
public string AuthUserFile
{
get { return authUserFile; }
set { authUserFile = value; }
}
public string AuthGroupFile
{
get { return authGroupFile; }
set { authGroupFile = value; }
}
public string SiteRootPath
{
get { return siteRootPath; }
set { siteRootPath = value; }
}
#endregion
public HtaccessFolder()
{
Users = new List<string>();
Groups = new List<string>();
}
public HtaccessFolder(string siteRootPath, string path, string contentPath)
: this()
{
this.SiteRootPath = siteRootPath;
this.Path = path;
this.ContentPath = contentPath;
ReadHtaccess();
}
private void ReadHttpdConf()
{
filename = HTTPD_CONF_FILE;
string htpath = System.IO.Path.Combine(ContentPath, filename);
HtaccessContent = ReadFile(htpath);
}
public void ReadHtaccess()
{
filename = HTACCESS_FILE;
string htpath = System.IO.Path.Combine(ContentPath, filename);
HtaccessContent = ReadFile(htpath);
ParseHtaccess();
}
private void ParseHtaccess()
{
validUser = false;
Match mAuthName = RE_AUTH_NAME.Match(HtaccessContent);
if (mAuthName.Success)
{
AuthName = mAuthName.Groups[1].Value;
}
Match mAuthType = RE_AUTH_TYPE.Match(HtaccessContent);
if (mAuthType.Success)
{
AuthType = mAuthType.Groups[1].Value;
}
Match mRequire = RE_REQUIRE.Match(HtaccessContent);
if (mRequire.Success)
{
ParseRequirements(mRequire.Groups[1].Value);
}
Match mAuthUserFile = RE_AUTH_USER_FILE.Match(HtaccessContent);
if (mAuthUserFile.Success)
{
AuthUserFile = mAuthUserFile.Groups[1].Value;
}
else
{
string authUserFilePath = System.IO.Path.Combine(SiteRootPath, HTPASSWDS_FILE);
if (File.Exists(authUserFilePath))
{
AuthUserFile = authUserFilePath;
}
}
Match mAuthGroupFile = RE_AUTH_GROUP_FILE.Match(HtaccessContent);
if (mAuthGroupFile.Success)
{
AuthGroupFile = mAuthGroupFile.Groups[1].Value;
}
else
{
string authGroupFilePath = System.IO.Path.Combine(SiteRootPath, HTGROUPS_FILE);
if (File.Exists(authGroupFilePath))
{
AuthGroupFile = authGroupFilePath;
}
}
}
private void ParseRequirements(string requirementsLine)
{
bool acceptUsers = false, acceptGroups = false;
foreach (string requirement in requirementsLine.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries))
{
string req = requirement.Trim();
if (req.Equals(VALID_USER))
{
ValidUser = true;
acceptUsers = acceptGroups = false;
}
else if (req.Equals(REQUIRE_USER))
{
acceptUsers = true;
acceptGroups = false;
}
else if (req.Equals(REQUIRE_GROUP))
{
acceptUsers = false;
acceptGroups = true;
}
else
{
if (acceptUsers)
{
Users.Add(req);
}
else if (acceptGroups)
{
Groups.Add(req);
}
}
}
}
public void Update()
{
if (Directory.Exists(ContentPath))
{
if (doAuthUpdate)
{
UpdateAuthDirectives();
}
string htaccessPath = System.IO.Path.Combine(ContentPath, filename);
WriteFile(htaccessPath, HtaccessContent);
}
}
private void UpdateAuthDirectives()
{
if (Users.Contains(VALID_USER))
{
ValidUser = true;
Users.Remove(VALID_USER);
}
else
{
ValidUser = false;
}
// update AuthName
Match mAuthName = RE_AUTH_NAME.Match(HtaccessContent);
if (!string.IsNullOrEmpty(AuthName))
{
string s = string.Format("{0} \"{1}\"", AUTH_NAME_DIRECTIVE, AuthName);
if (mAuthName.Success)
{
HtaccessContent = RE_AUTH_NAME.Replace(HtaccessContent, s);
}
else
{
HtaccessContent += s + Environment.NewLine;
}
}
else
{
if (mAuthName.Success)
{
HtaccessContent = RE_AUTH_NAME.Replace(HtaccessContent, "");
}
}
// update AuthType
Match mAuthType = RE_AUTH_TYPE.Match(HtaccessContent);
if (!string.IsNullOrEmpty(AuthType))
{
string s = string.Format("{0} {1}", AUTH_TYPE_DIRECTIVE, AuthType);
if (mAuthType.Success)
{
HtaccessContent = RE_AUTH_TYPE.Replace(HtaccessContent, s);
}
else
{
HtaccessContent += s + Environment.NewLine;
}
}
else
{
if (mAuthType.Success)
{
HtaccessContent = RE_AUTH_TYPE.Replace(HtaccessContent, "");
}
}
// update Auth(Basic|Digest)Provider
Match mAuthProvider = RE_AUTH_PROVIDER.Match(HtaccessContent);
string prov = AuthType == "Basic" ? AUTH_BASIC_PROVIDER_FILE : AUTH_DIGEST_PROVIDER_FILE;
if (mAuthProvider.Success)
{
HtaccessContent = RE_AUTH_PROVIDER.Replace(HtaccessContent, prov);
}
else
{
HtaccessContent += prov + Environment.NewLine;
}
// update AuthUserFile
Match mAuthUserFile = RE_AUTH_USER_FILE.Match(HtaccessContent);
if (!string.IsNullOrEmpty(AuthUserFile))
{
string s = string.Format("{0} {1}", AUTH_USER_FILE_DIRECTIVE, AuthUserFile);
if (mAuthUserFile.Success)
{
HtaccessContent = RE_AUTH_USER_FILE.Replace(HtaccessContent, s);
}
else
{
HtaccessContent += s + Environment.NewLine;
}
}
else
{
if (mAuthUserFile.Success)
{
HtaccessContent = RE_AUTH_USER_FILE.Replace(HtaccessContent, "");
}
}
// update AuthUserFile
Match mAuthGroupFile = RE_AUTH_GROUP_FILE.Match(HtaccessContent);
if (!string.IsNullOrEmpty(AuthGroupFile))
{
string s = string.Format("{0} {1}", AUTH_GROUP_FILE_DIRECTIVE, AuthGroupFile);
if (mAuthGroupFile.Success)
{
HtaccessContent = RE_AUTH_GROUP_FILE.Replace(HtaccessContent, s);
}
else
{
HtaccessContent += s + Environment.NewLine;
}
}
else
{
if (mAuthGroupFile.Success)
{
HtaccessContent = RE_AUTH_GROUP_FILE.Replace(HtaccessContent, "");
}
}
// update Require
Match mRequire = RE_REQUIRE.Match(HtaccessContent);
if (ValidUser || Users.Count > 0 || Groups.Count > 0)
{
string s = GenerateReqiure();
if (mRequire.Success)
{
HtaccessContent = RE_REQUIRE.Replace(HtaccessContent, s);
}
else
{
HtaccessContent += s + Environment.NewLine;
}
}
else
{
if (mRequire.Success)
{
HtaccessContent = RE_AUTH_TYPE.Replace(HtaccessContent, "");
}
}
}
private string GenerateReqiure()
{
StringBuilder sb = new StringBuilder();
sb.Append(REQUIRE_DIRECTIVE);
if (ValidUser)
{
sb.Append(" ").Append(VALID_USER);
}
if (Users.Count > 0)
{
sb.Append(" ").Append(REQUIRE_USER);
foreach (string user in Users)
{
sb.AppendFormat(" {0}", user);
}
}
if (Groups.Count > 0)
{
sb.Append(" ").Append(REQUIRE_GROUP);
foreach (string group in Groups)
{
sb.AppendFormat(" {0}", group);
}
}
return sb.ToString();
}
#region Implementation of IComparable
public int CompareTo(object obj)
{
HtaccessFolder folder = obj as HtaccessFolder;
if (folder != null)
{
return String.CompareOrdinal(this.Path.ToLower(), folder.Path.ToLower());
}
return 0;
}
#endregion
#region static helper members
public static void GetDirectoriesWithHtaccess(string siteRootPath, string virtualRoot, string rootPath, string subPath, List<HtaccessFolder> folders)
{
if (Directory.Exists(subPath))
{
if (HasHtaccessInDirectory(subPath))
{
// Check this subPath is in folders list already
bool included = folders.Any(x => String.Equals(subPath, x.ContentPath, StringComparison.OrdinalIgnoreCase));
// Add only if it is not included
if (included == false)
{
//
folders.Add(new HtaccessFolder
{
SiteRootPath = siteRootPath,
Path = virtualRoot + RelativePath(rootPath, subPath),
ContentPath = subPath
});
}
}
// Process nested virtual directories if any
Array.ForEach(Directory.GetDirectories(subPath), (x) =>
{
GetDirectoriesWithHtaccess(siteRootPath, virtualRoot, rootPath, x, folders);
});
}
}
private static bool HasHtaccessInDirectory(string path)
{
return File.Exists(System.IO.Path.Combine(path, HTACCESS_FILE));
}
private static string RelativePath(string basePath, string subPath)
{
if (string.Equals(basePath, subPath, StringComparison.OrdinalIgnoreCase))
{
return "\\";
}
if (subPath.StartsWith(subPath, StringComparison.OrdinalIgnoreCase))
{
return subPath.Substring(basePath.Length);
}
throw new ArgumentException("Paths do not have a common base");
}
public static HtaccessFolder CreateHtaccessFolder(string siteRootPath, string folderPath)
{
HtaccessFolder folder = new HtaccessFolder
{
SiteRootPath = siteRootPath,
Path = folderPath,
ContentPath = System.IO.Path.Combine(siteRootPath, folderPath)
};
folder.ReadHtaccess();
return folder;
}
public static HtaccessFolder CreateHttpdConfFolder(string path)
{
HtaccessFolder folder = new HtaccessFolder
{
ContentPath = path,
Path = HTTPD_CONF_FILE
};
folder.ReadHttpdConf();
return folder;
}
public static string ReadFile(string path)
{
string result = string.Empty;
if (!File.Exists(path))
return result;
using (StreamReader reader = new StreamReader(path))
{
result = reader.ReadToEnd();
reader.Close();
}
return result;
}
public static List<string> ReadLinesFile(string path)
{
List<string> lines = new List<string>();
string content = ReadFile(path);
if (!string.IsNullOrEmpty(content))
{
foreach (string line in Regex.Split(content, LinesSeparator))
{
lines.Add(line);
}
}
return lines;
}
public static void WriteFile(string path, string content)
{
// remove 'hidden' attribute
FileAttributes fileAttributes = FileAttributes.Normal;
if (File.Exists(path))
{
fileAttributes = File.GetAttributes(path);
if ((fileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
fileAttributes &= ~FileAttributes.Hidden;
File.SetAttributes(path, fileAttributes);
}
}
// check if folder exists
string folder = System.IO.Path.GetDirectoryName(path);
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
// write file
using (StreamWriter writer = new StreamWriter(path))
{
writer.WriteLine(content);
writer.Close();
}
// set 'hidden' attribute
fileAttributes = File.GetAttributes(path);
fileAttributes |= FileAttributes.Hidden;
File.SetAttributes(path, fileAttributes);
}
public static void WriteLinesFile(string path, List<string> lines)
{
StringBuilder content = new StringBuilder();
foreach (string line in lines)
{
if (!string.IsNullOrEmpty(line))
{
content.AppendLine(line);
}
}
WriteFile(path, content.ToString());
}
#endregion
}
public class HtaccessUser : WebUser
{
public const string ENCODING_TYPE_APACHE_MD5 = "Apache MD5";
public const string ENCODING_TYPE_UNIX_CRYPT = "Unix Crypt";
public const string ENCODING_TYPE_SHA1 = "SHA1";
public static readonly string[] ENCODING_TYPES = new string[]
{
ENCODING_TYPE_APACHE_MD5, ENCODING_TYPE_UNIX_CRYPT, ENCODING_TYPE_SHA1
};
private string authType;
private string encType;
private string realm;
public string AuthType
{
get
{
if (string.IsNullOrEmpty(authType))
{
if (!string.IsNullOrEmpty(Password))
{
authType = HtaccessFolder.RE_DIGEST_PASSWORD.IsMatch(Password) ? HtaccessFolder.AUTH_TYPE_DIGEST : HtaccessFolder.AUTH_TYPE_BASIC;
}
}
return authType;
}
set { authType = value; }
}
public string EncType
{
get
{
if (string.IsNullOrEmpty(encType))
{
if (HtaccessFolder.AUTH_TYPE_BASIC != AuthType)
{
encType = string.Empty;
}
else if (Password.StartsWith("{SHA"))
{
encType = ENCODING_TYPE_SHA1;
}
else if (Password.StartsWith("$apr1$"))
{
encType = ENCODING_TYPE_APACHE_MD5;
}
else
{
encType = ENCODING_TYPE_UNIX_CRYPT;
}
}
return encType;
}
set { encType = value; }
}
public string Realm
{
get { return realm; }
set { realm = value; }
}
}
}

View file

@ -0,0 +1,73 @@
// Copyright (c) 2011, 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.Net;
using System.Collections;
using System.ComponentModel;
namespace WebsitePanel.Providers.Web
{
public class HttpError
{
private string errorCode;
private string errorSubcode;
private string handlerType;
private string errorContent;
public HttpError()
{
}
public string ErrorCode
{
get { return errorCode; }
set {errorCode = value; }
}
public string ErrorSubcode
{
get { return errorSubcode; }
set {errorSubcode = value; }
}
public string HandlerType
{
get { return handlerType; }
set{ handlerType = value; }
}
public string ErrorContent
{
get { return errorContent; }
set { errorContent = value; }
}
}
}

View file

@ -0,0 +1,58 @@
// Copyright (c) 2011, 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.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers.Web
{
public class HttpHeader
{
private string key;
private string val;
public HttpHeader()
{
}
public string Key
{
get { return this.key; }
set { this.key = value; }
}
public string Value
{
get { return this.val; }
set { this.val = value; }
}
}
}

View file

@ -0,0 +1,153 @@
// Copyright (c) 2011, 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.Collections.Generic;
using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Providers.ResultObjects;
using WebsitePanel.Providers.WebAppGallery;
using WebsitePanel.Providers.Common;
namespace WebsitePanel.Providers.Web
{
/// <summary>
/// Summary description for IWebServer.
/// </summary>
public interface IWebServer
{
// sites
void ChangeSiteState(string siteId, ServerState state);
ServerState GetSiteState(string siteId);
bool SiteExists(string siteId);
string[] GetSites();
string GetSiteId(string siteName);
WebSite GetSite(string siteId);
string[] GetSitesAccounts(string[] siteIds);
ServerBinding[] GetSiteBindings(string siteId);
string CreateSite(WebSite site);
void UpdateSite(WebSite site);
void UpdateSiteBindings(string siteId, ServerBinding[] bindings);
void DeleteSite(string siteId);
// virtual directories
bool VirtualDirectoryExists(string siteId, string directoryName);
WebVirtualDirectory[] GetVirtualDirectories(string siteId);
WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName);
void CreateVirtualDirectory(string siteId, WebVirtualDirectory directory);
void UpdateVirtualDirectory(string siteId, WebVirtualDirectory directory);
void DeleteVirtualDirectory(string siteId, string directoryName);
// FrontPage
bool IsFrontPageSystemInstalled();
bool IsFrontPageInstalled(string siteId);
bool InstallFrontPage(string siteId, string username, string password);
void UninstallFrontPage(string siteId, string username);
void ChangeFrontPagePassword(string username, string password);
//ColdFusion
bool IsColdFusionSystemInstalled();
//bool IsColdFusionEnabled(string siteId);
// permissions
void GrantWebSiteAccess(string path, string siteId, NTFSPermission permission);
// Secured folders
void InstallSecuredFolders(string siteId);
void UninstallSecuredFolders(string siteId);
List<WebFolder> GetFolders(string siteId);
WebFolder GetFolder(string siteId, string folderPath);
void UpdateFolder(string siteId, WebFolder folder);
void DeleteFolder(string siteId, string folderPath);
List<WebUser> GetUsers(string siteId);
WebUser GetUser(string siteId, string userName);
void UpdateUser(string siteId, WebUser user);
void DeleteUser(string siteId, string userName);
List<WebGroup> GetGroups(string siteId);
WebGroup GetGroup(string siteId, string groupName);
void UpdateGroup(string siteId, WebGroup group);
void DeleteGroup(string siteId, string groupName);
// Helicon Ape
HeliconApeStatus GetHeliconApeStatus(string siteId);
void InstallHeliconApe(string ServiceId);
void EnableHeliconApe(string siteId);
void DisableHeliconApe(string siteId);
List<HtaccessFolder> GetHeliconApeFolders(string siteId);
HtaccessFolder GetHeliconApeHttpdFolder();
HtaccessFolder GetHeliconApeFolder(string siteId, string folderPath);
void UpdateHeliconApeFolder(string siteId, HtaccessFolder folder);
void UpdateHeliconApeHttpdFolder(HtaccessFolder folder);
void DeleteHeliconApeFolder(string siteId, string folderPath);
List<HtaccessUser> GetHeliconApeUsers(string siteId);
HtaccessUser GetHeliconApeUser(string siteId, string userName);
void UpdateHeliconApeUser(string siteId, HtaccessUser user);
void DeleteHeliconApeUser(string siteId, string userName);
List<WebGroup> GetHeliconApeGroups(string siteId);
WebGroup GetHeliconApeGroup(string siteId, string groupName);
void UpdateHeliconApeGroup(string siteId, WebGroup group);
void DeleteHeliconApeGroup(string siteId, string groupName);
// web app gallery
bool IsMsDeployInstalled();
GalleryCategoriesResult GetGalleryCategories();
GalleryApplicationsResult GetGalleryApplications(string categoryId);
GalleryApplicationResult GetGalleryApplication(string id);
GalleryWebAppStatus GetGalleryApplicationStatus(string id);
GalleryWebAppStatus DownloadGalleryApplication(string id);
DeploymentParametersResult GetGalleryApplicationParameters(string id);
StringResultObject InstallGalleryApplication(string id, List<DeploymentParameter> updatedValues);
//
void GrantWebManagementAccess(string siteId, string accountName, string accountPassword);
void RevokeWebManagementAccess(string siteId, string accountName);
void ChangeWebManagementAccessPassword(string accountName, string accountPassword);
bool CheckWebManagementAccountExists(string accountName);
ResultObject CheckWebManagementPasswordComplexity(string accountPassword);
// Web Deploy Publishing Access
void GrantWebDeployPublishingAccess(string siteId, string accountName, string accountPassword);
void RevokeWebDeployPublishingAccess(string siteId, string accountName);
//SSL
SSLCertificate generateCSR(SSLCertificate certificate);
SSLCertificate generateRenewalCSR(SSLCertificate certificate);
SSLCertificate installCertificate(SSLCertificate certificate, WebSite website);
SSLCertificate getCertificate(WebSite site);
SSLCertificate installPFX(byte[] certificate, string password, WebSite website);
byte[] exportCertificate(string serialNumber, string password);
List<SSLCertificate> getServerCertificates();
ResultObject DeleteCertificate(SSLCertificate certificate, WebSite website);
SSLCertificate ImportCertificate(WebSite website);
bool CheckCertificate(WebSite webSite);
}
}

View file

@ -0,0 +1,58 @@
// Copyright (c) 2011, 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.Net;
using System.Collections;
using System.ComponentModel;
namespace WebsitePanel.Providers.Web
{
public class MimeMap
{
private string extension;
private string mimeType;
public MimeMap()
{
}
public string Extension
{
get { return extension; }
set { extension = value; }
}
public string MimeType
{
get { return mimeType; }
set { mimeType = value ; }
}
}
}

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers.Web
{
[Serializable]
public class SSLCertificate
{
public int id { get; set; }
public string FriendlyName { get; set; }
public string Hostname { get; set; }
public string DistinguishedName { get; set; }
public string CSR { get; set; }
public int CSRLength { get; set; }
public int SiteID { get; set; }
public int UserID { get; set; }
public bool Installed { get; set; }
public string PrivateKey { get; set; }
public string Certificate { get; set; }
public byte[] Hash { get; set; }
public string Organisation { get; set; }
public string OrganisationUnit { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
public DateTime ValidFrom { get; set;}
public DateTime ExpiryDate { get; set; }
public string SerialNumber { get; set; }
public byte[] Pfx { get; set; }
public string Password { get; set; }
public bool Success { get; set; }
public bool IsRenewal { get; set; }
public int PreviousId { get; set; }
public SSLCertificate()
{}
}
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2011, 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.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers.Web
{
public class SharedSSLFolder : WebVirtualDirectory
{
}
}

View file

@ -0,0 +1,66 @@
// Copyright (c) 2011, 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.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers.Web
{
public class WebFolder
{
private string title;
private string path;
private string[] users;
private string[] groups;
public string Title
{
get { return title; }
set { title = value; }
}
public string Path
{
get { return path; }
set { path = value; }
}
public string[] Users
{
get { return users; }
set { users = value; }
}
public string[] Groups
{
get { return groups; }
set { groups = value; }
}
}
}

View file

@ -0,0 +1,52 @@
// Copyright (c) 2011, 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.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers.Web
{
public class WebGroup
{
private string name;
private string[] users;
public string Name
{
get { return name; }
set { name = value; }
}
public string[] Users
{
get { return users; }
set { users = value; }
}
}
}

View file

@ -0,0 +1,237 @@
// Copyright (c) 2011, 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.ComponentModel;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace WebsitePanel.Providers.Web
{
/// <summary>
/// Summary description for WebSiteItem.
/// </summary>
[Serializable]
public class WebSite : WebVirtualDirectory
{
#region String constants
public const string IIS7_SITE_ID = "WebSiteId_IIS7";
public const string IIS7_LOG_EXT_FILE_FIELDS = "IIS7_LogExtFileFields";
#endregion
private string siteId;
private string siteIPAddress;
private int siteIPAddressId;
private string logsPath;
private string dataPath;
private ServerBinding[] bindings;
private bool frontPageAvailable;
private bool frontPageInstalled;
private bool coldFusionAvailable;
private bool createCFVirtualDirectories;
private string frontPageAccount;
private string frontPagePassword;
private string coldFusionVersion;
private ServerState siteState;
private bool securedFoldersInstalled;
private bool heliconApeInstalled;
private bool heliconApeEnabled;
public WebSite()
{
}
[Persistent]
public string SiteId
{
get { return siteId; }
set { siteId = value; }
}
public string SiteIPAddress
{
get { return siteIPAddress; }
set { siteIPAddress = value; }
}
[Persistent]
public int SiteIPAddressId
{
get { return siteIPAddressId; }
set { siteIPAddressId = value; }
}
/// <summary>
/// Gets or sets logs path for the web site
/// </summary>
[Persistent]
public string LogsPath { get; set; }
[Persistent]
public string DataPath
{
get { return dataPath; }
set { dataPath = value; }
}
public ServerBinding[] Bindings
{
get { return bindings; }
set { bindings = value; }
}
[Persistent]
public string FrontPageAccount
{
get { return this.frontPageAccount; }
set { this.frontPageAccount = value; }
}
[Persistent]
public string FrontPagePassword
{
get { return this.frontPagePassword; }
set { this.frontPagePassword = value; }
}
public bool FrontPageAvailable
{
get { return this.frontPageAvailable; }
set { this.frontPageAvailable = value; }
}
public bool FrontPageInstalled
{
get { return this.frontPageInstalled; }
set { this.frontPageInstalled = value; }
}
public bool ColdFusionAvailable
{
get { return this.coldFusionAvailable; }
set { this.coldFusionAvailable = value; }
}
public string ColdFusionVersion
{
get { return this.coldFusionVersion; }
set { this.coldFusionVersion = value; }
}
public bool CreateCFVirtualDirectories
{
get { return this.createCFVirtualDirectories; }
set { this.createCFVirtualDirectories = value; }
}
public ServerState SiteState
{
get { return this.siteState; }
set { this.siteState = value; }
}
public bool SecuredFoldersInstalled
{
get { return this.securedFoldersInstalled; }
set { this.securedFoldersInstalled = value; }
}
public bool HeliconApeInstalled
{
get { return this.heliconApeInstalled; }
set { this.heliconApeInstalled = value; }
}
public bool HeliconApeEnabled
{
get { return this.heliconApeEnabled; }
set { this.heliconApeEnabled = value; }
}
}
[Flags]
public enum SiteAppPoolMode
{
Dedicated = 1,
Shared = 2,
Classic = 4,
Integrated = 8,
dotNetFramework1 = 16,
dotNetFramework2 = 32,
dotNetFramework4 = 64
};
public class WSHelper
{
public const int IIS6 = 0;
public const int IIS7 = 1;
//
public static Dictionary<SiteAppPoolMode, string[]> MMD = new Dictionary<SiteAppPoolMode, string[]>
{
{ SiteAppPoolMode.dotNetFramework1, new string[] {"", "v1.1"} },
{ SiteAppPoolMode.dotNetFramework2, new string[] {"2.0", "v2.0"} },
{ SiteAppPoolMode.dotNetFramework4, new string[] {"4.0", "v4.0"} },
};
public static string InferAppPoolName(string formatString, string siteName, SiteAppPoolMode NHRT)
{
if (String.IsNullOrEmpty(formatString))
throw new ArgumentNullException("formatString");
//
NHRT |= SiteAppPoolMode.Dedicated;
//
formatString = formatString.Replace("#SITE-NAME#", siteName);
//
foreach (var fwVersionKey in MMD.Keys)
{
if ((NHRT & fwVersionKey) == fwVersionKey)
{
formatString = formatString.Replace("#IIS6-ASPNET-VERSION#", MMD[fwVersionKey][IIS6]);
formatString = formatString.Replace("#IIS7-ASPNET-VERSION#", MMD[fwVersionKey][IIS7]);
//
break;
}
}
//
SiteAppPoolMode pipeline = NHRT & (SiteAppPoolMode.Classic | SiteAppPoolMode.Integrated);
formatString = formatString.Replace("#PIPELINE-MODE#", pipeline.ToString());
//
return formatString.Trim();
}
public static string WhatFrameworkVersionIs(SiteAppPoolMode value)
{
SiteAppPoolMode dotNetVersion = value & (SiteAppPoolMode.dotNetFramework1
| SiteAppPoolMode.dotNetFramework2 | SiteAppPoolMode.dotNetFramework4);
//
return String.Format("v{0}", MMD[dotNetVersion][IIS7]);
}
}
}

View file

@ -0,0 +1,59 @@
// Copyright (c) 2011, 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.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers.Web
{
public class WebUser
{
private string name;
private string[] groups;
private string password;
public string Name
{
get { return name; }
set { name = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string[] Groups
{
get { return groups; }
set { groups = value; }
}
}
}

View file

@ -0,0 +1,321 @@
// Copyright (c) 2011, 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.Net;
using System.Text;
using System.Xml.Serialization;
namespace WebsitePanel.Providers.Web
{
public class WebVirtualDirectory : ServiceProviderItem
{
#region Web Management Service Constants
public const string WmSvcAvailable = "WmSvcAvailable";
public const string WmSvcSiteEnabled = "WmSvcSiteEnabled";
public const string WmSvcAccountName = "WmSvcAccountName";
public const string WmSvcAccountPassword = "WmSvcAccountPassword";
public const string WmSvcServiceUrl = "WmSvcServiceUrl";
public const string WmSvcServicePort = "WmSvcServicePort";
public const string WmSvcDefaultPort = "8172";
#endregion
private string anonymousUsername;
private string anonymousUserPassword;
private string contentPath;
private bool enableWritePermissions;
private bool enableParentPaths;
private bool enableDirectoryBrowsing;
private bool enableAnonymousAccess;
private bool enableWindowsAuthentication;
private bool enableBasicAuthentication;
private string defaultDocs;
private string httpRedirect;
private HttpError[] httpErrors;
private MimeMap[] mimeMaps;
private HttpHeader[] httpHeaders;
private bool aspInstalled;
private string aspNetInstalled;
private string phpInstalled;
private bool perlInstalled;
private bool pythonInstalled;
private bool coldfusionInstalled;
private bool cgiBinInstalled;
private string applicationPool;
private bool dedicatedApplicationPool;
private string parentSiteName;
private bool redirectExactUrl;
private bool redirectDirectoryBelow;
private bool redirectPermanent;
private bool sharePointInstalled;
private bool iis7;
public string AnonymousUsername
{
get { return anonymousUsername; }
set { anonymousUsername = value; }
}
public string AnonymousUserPassword
{
get { return anonymousUserPassword; }
set { anonymousUserPassword = value; }
}
public string ContentPath
{
get { return contentPath; }
set { contentPath = value; }
}
public string HttpRedirect
{
get { return httpRedirect; }
set { httpRedirect = value; }
}
public string DefaultDocs
{
get { return defaultDocs; }
set { defaultDocs = value; }
}
public MimeMap[] MimeMaps
{
get { return mimeMaps; }
set { mimeMaps = value; }
}
public HttpError[] HttpErrors
{
get { return httpErrors; }
set { httpErrors = value; }
}
public string ApplicationPool
{
get { return this.applicationPool; }
set { this.applicationPool = value; }
}
public bool EnableParentPaths
{
get { return this.enableParentPaths; }
set { this.enableParentPaths = value; }
}
public HttpHeader[] HttpHeaders
{
get { return this.httpHeaders; }
set { this.httpHeaders = value; }
}
public bool EnableWritePermissions
{
get { return this.enableWritePermissions; }
set { this.enableWritePermissions = value; }
}
public bool EnableDirectoryBrowsing
{
get { return this.enableDirectoryBrowsing; }
set { this.enableDirectoryBrowsing = value; }
}
public bool EnableAnonymousAccess
{
get { return this.enableAnonymousAccess; }
set { this.enableAnonymousAccess = value; }
}
public bool EnableWindowsAuthentication
{
get { return this.enableWindowsAuthentication; }
set { this.enableWindowsAuthentication = value; }
}
public bool EnableBasicAuthentication
{
get { return this.enableBasicAuthentication; }
set { this.enableBasicAuthentication = value; }
}
public bool AspInstalled
{
get { return this.aspInstalled; }
set { this.aspInstalled = value; }
}
public string AspNetInstalled
{
get { return this.aspNetInstalled; }
set { this.aspNetInstalled = value; }
}
public string PhpInstalled
{
get { return this.phpInstalled; }
set { this.phpInstalled = value; }
}
public bool PerlInstalled
{
get { return this.perlInstalled; }
set { this.perlInstalled = value; }
}
public bool PythonInstalled
{
get { return this.pythonInstalled; }
set { this.pythonInstalled = value; }
}
public bool ColdFusionInstalled
{
get { return this.coldfusionInstalled; }
set { this.coldfusionInstalled = value; }
}
public bool DedicatedApplicationPool
{
get { return this.dedicatedApplicationPool; }
set { this.dedicatedApplicationPool = value; }
}
public string ParentSiteName
{
get { return this.parentSiteName; }
set { this.parentSiteName = value; }
}
public bool RedirectExactUrl
{
get { return this.redirectExactUrl; }
set { this.redirectExactUrl = value; }
}
public bool RedirectDirectoryBelow
{
get { return this.redirectDirectoryBelow; }
set { this.redirectDirectoryBelow = value; }
}
public bool RedirectPermanent
{
get { return this.redirectPermanent; }
set { this.redirectPermanent = value; }
}
public bool CgiBinInstalled
{
get { return this.cgiBinInstalled; }
set { this.cgiBinInstalled = value; }
}
public bool SharePointInstalled
{
get { return this.sharePointInstalled; }
set { this.sharePointInstalled = value; }
}
public bool IIs7
{
get { return this.iis7; }
set { this.iis7 = value; }
}
#region Web Deploy Publishing Properties
/// <summary>
/// Gets or sets Web Deploy publishing account name
/// </summary>
[Persistent]
public string WebDeployPublishingAccount { get; set; }
/// <summary>
/// Gets or sets Web Deploy publishing password
/// </summary>
[Persistent]
public string WebDeployPublishingPassword { get; set; }
/// <summary>
/// Gets or sets whether Web Deploy publishing is enabled on the server
/// </summary>
public bool WebDeployPublishingAvailable { get; set; }
/// <summary>
/// Gets or sets whether Web Deploy publishing is enabled for this particular web site
/// </summary>
[Persistent]
public bool WebDeploySitePublishingEnabled { get; set; }
/// <summary>
/// Gets or sets Web Deploy publishing profile data for this particular web site
/// </summary>
[Persistent]
public string WebDeploySitePublishingProfile { get; set; }
#endregion
/// <summary>
/// Gets fully qualified name which consists of parent website name if present and virtual directory name.
/// </summary>
[XmlIgnore]
public string VirtualPath
{
get
{
// virtual path is rooted
if (String.IsNullOrEmpty(ParentSiteName))
return "/"; //
else if (!Name.StartsWith("/"))
return "/" + Name;
//
return Name;
}
}
/// <summary>
/// Gets fully qualified name which consists of parent website name if present and virtual directory name.
/// </summary>
[XmlIgnore]
public string FullQualifiedPath
{
get
{
if (String.IsNullOrEmpty(ParentSiteName))
return Name;
else if (Name.StartsWith("/"))
return ParentSiteName + Name;
else
return ParentSiteName + "/" + Name;
}
}
}
}