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,97 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
namespace WebsitePanel.Providers.Common
{
sealed class ByteVector
{
# region Public
public ByteVector Add(Byte[] bytes, Int32 offset, Int32 count)
{
Byte [] b = new Byte[ count ];
Array.Copy( bytes, offset, b, 0, count );
_bytes.Add( b );
_size += count;
return this;
}
public ByteVector Add (Byte[] bytes)
{
return Add(bytes, 0, bytes.Length);
}
public ByteVector Add(string s, Encoding encoding)
{
if ( !string.IsNullOrEmpty(s) )
{
Add(encoding.GetBytes(s));
}
return this;
}
public ByteVector Add(string s)
{
return Add(s, Encoding.ASCII);
}
public Byte[] Get()
{
Byte [] result = new Byte[ _size ];
Int32 offset = 0;
foreach ( Byte [] b in _bytes )
{
Array.Copy( b, 0, result, offset, b.Length );
offset += b.Length;
}
return result;
}
public string GetHexString()
{
StringBuilder sb = new StringBuilder();
foreach (byte b in Get())
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
public Byte[] GetMD5Hash()
{
return MD5.Create().ComputeHash(Get());
}
public void Clear()
{
_bytes.Clear();
_size = 0;
}
public Int64 Size
{
get { return _size; }
}
# endregion
# region Private
readonly List<Byte[]> _bytes = new List<Byte[]>();
Int64 _size;
# endregion
}
}

View file

@ -0,0 +1,71 @@
// 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.
namespace WebsitePanel.Providers.Common
{
public class Constants
{
public const string ImportDomainAdmin = "ImportDomainAdmin";
public const string InheritDomainDefaultLimits = "InheritDomainDefaultLimits";
public const string EnableDomainAdministrators = "EnableDomainAdministrators";
public const string RelayAliasedMail = "RelayAliasedMail";
public const string UserName = "UserName";
public const string Password = "Password";
public const string NameServers = "NameServers";
public const string SqlServer = "SqlServer";
public const string ReportingServer = "ReportingServer";
public const string IFDWebApplicationRootDomain = "IFDWebApplicationRootDomain";
public const string CRMWebsiteIP = "CRMWebsiteIP";
public const string UrlSchema = "UrlSchema";
public const string Port = "Port";
public const string AppRootDomain = "AppRootDomain";
public const string UtilityPath = "UtilityPath";
public const string EnterpriseServer = "EnterpriseServer";
public const string AdministrationToolService = "AdministrationToolService";
}
}

View file

@ -0,0 +1,79 @@
// 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;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for DailyStatistics.
/// </summary>
[Serializable]
public class DailyStatistics
{
private int year;
private int month;
private int day;
private long bytesSent;
private long bytesReceived;
public DailyStatistics()
{
}
public int Year
{
get { return year; }
set { year = value; }
}
public int Month
{
get { return month; }
set { month = value; }
}
public int Day
{
get { return day; }
set { day = value; }
}
public long BytesSent
{
get { return bytesSent; }
set { bytesSent = value; }
}
public long BytesReceived
{
get { return bytesReceived; }
set { bytesReceived = value; }
}
}
}

View file

@ -0,0 +1,54 @@
// 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.
namespace WebsitePanel.Providers.Common
{
public class ErrorCodes
{
public const string CANNOT_CREATE_PROVIDER_INSTANCE = "CANNOT_CREATE_PROVIDER_INSTANCE";
public const string PROVIDER_NANE_IS_NOT_SPECIFIED = "PROVIDER_NANE_IS_NOT_SPECIFIED";
public const string CANNOT_CHECK_IF_PROVIDER_SOFTWARE_INSTALLED = "CANNOT_CHECK_IF_PROVIDER_SOFTWARE_INSTALLED";
public const string CANNOT_GET_PROVIDER_INFO = "CANNOT_GET_PROVIDER_INFO";
public const string CANNOT_GET_PASSWORD_COMPLEXITY = "CANNOT_GET_PASSWORD_COMPLEXITY";
public const string CANNOT_GET_ORGANIZATION_PROXY = "CANNOT_GET_ORGANIZATION_PROXY";
public const string CANNOT_GET_ORGANIZATION_BY_ITEM_ID = "CANNOT_GET_ORGANIZATION_BY_ITEM_ID";
public const string CANNOT_GET_ACCOUNT = "CANNOT_GET_ACCOUNT";
public const string CANNOT_GET_DISTRIBUTION_LIST_PERMISSIONS = "CANNOT_GET_DISTRIBUTION_LIST_PERMISSIONS";
public const string CANNOT_SET_DISTRIBUTION_LIST_PERMISSIONS = "CANNOT_SET_DISTRIBUTION_LIST_PERMISSIONS";
}
}

View file

@ -0,0 +1,112 @@
// 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.IO;
using WebsitePanel.Providers.Common;
namespace WebsitePanel.Providers
{
public abstract class HostingServiceProviderBase : IHostingServiceProvider
{
RemoteServerSettings serverSettings = new RemoteServerSettings();
ServiceProviderSettings providerSettings = new ServiceProviderSettings();
public RemoteServerSettings ServerSettings
{
get { return serverSettings; }
set { serverSettings = value; }
}
public ServiceProviderSettings ProviderSettings
{
get { return providerSettings; }
set { providerSettings = value; }
}
#region IHostingServiceProvider methods
public virtual string[] GetProviderDefaults()
{
return new string[] { };
}
public virtual string[] Install()
{
// install in silence
return new string[] { };
}
public virtual SettingPair[] GetProviderDefaultSettings()
{
return new SettingPair[] { };
}
public virtual void Uninstall()
{
// nothing to do
}
public abstract bool IsInstalled();
public virtual void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
{
// do nothing
}
public virtual void DeleteServiceItems(ServiceProviderItem[] items)
{
// do nothing
}
public virtual ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(ServiceProviderItem[] items)
{
// don't calculate disk space
return null;
}
public virtual ServiceProviderItemBandwidth[] GetServiceItemsBandwidth(ServiceProviderItem[] items, DateTime since)
{
// don't calculate bandwidth
return null;
}
#endregion
#region Helper Methods
protected void CheckTempPath(string path)
{
// check path
string tempPath = Path.GetTempPath();
//bug when calling from local machine
//if (!path.ToLower().StartsWith(tempPath.ToLower()))
// throw new Exception("The path is not allowed");
}
#endregion
}
}

View file

@ -0,0 +1,92 @@
// 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;
namespace WebsitePanel.Providers
{
public abstract class HostingServiceProviderWebService : System.Web.Services.WebService
{
public ServiceProviderSettingsSoapHeader settings = new ServiceProviderSettingsSoapHeader();
private RemoteServerSettings serverSettings;
private ServiceProviderSettings providerSettings;
private IHostingServiceProvider provider;
protected IHostingServiceProvider Provider
{
get
{
if (provider == null)
{
// try to create provider class
Type providerType = Type.GetType(ProviderSettings.ProviderType);
try
{
provider = (IHostingServiceProvider)Activator.CreateInstance(providerType);
((HostingServiceProviderBase)provider).ServerSettings = ServerSettings;
((HostingServiceProviderBase)provider).ProviderSettings = ProviderSettings;
}
catch (Exception ex)
{
throw new Exception(String.Format("Can not create '{0}' provider instance with '{1}' type",
ProviderSettings.ProviderName, ProviderSettings.ProviderType), ex);
}
}
return provider;
}
}
protected RemoteServerSettings ServerSettings
{
get
{
if (serverSettings == null)
{
// parse server settings
serverSettings = new RemoteServerSettings(settings.Settings);
}
return serverSettings;
}
}
protected ServiceProviderSettings ProviderSettings
{
get
{
if (providerSettings == null)
{
// parse provider settings
providerSettings = new ServiceProviderSettings(settings.Settings);
}
return providerSettings;
}
}
}
}

View file

@ -0,0 +1,72 @@
// 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;
using WebsitePanel.Providers.Common;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for IPanelServiceProvider.
/// </summary>
public interface IHostingServiceProvider
{
/// <summary>
/// Executes each time when the service is being added to some server.
/// Prepare environment for service usage (like setting folder permissions,
/// creating system users, etc.)
/// </summary>
string[] Install();
/// <summary>
/// Returns the list of additional provider properties.
/// </summary>
/// <returns>The array of additional properties.</returns>
SettingPair[] GetProviderDefaultSettings();
/// <summary>
/// Executes when service is being removed from server.
/// Performs any clean up operations.
/// </summary>
void Uninstall();
/// <summary>
/// Checks whether service is installed within the system. This method will be
/// used by server creation wizard for automatic services detection and configuring.
/// </summary>
/// <returns>True if service is installed; otherwise - false.</returns>
bool IsInstalled();
void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled);
void DeleteServiceItems(ServiceProviderItem[] items);
ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(ServiceProviderItem[] items);
ServiceProviderItemBandwidth[] GetServiceItemsBandwidth(ServiceProviderItem[] items, DateTime since);
}
}

View file

@ -0,0 +1,44 @@
// 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;
namespace WebsitePanel.Providers
{
[Flags]
[Serializable]
public enum NTFSPermission : int
{
FullControl = 0x1,// = 0x1F01FF,
Modify = 0x2,// = 0x1301BF,
//Execute = 0x4,// = 0x1200A9,
//ListFolderContents = 0x8,// = 0x1200A9,
Read = 0x10,// = 0x120089,
Write = 0x20// = 0x100116
}
}

View file

@ -0,0 +1,209 @@
using System;
using System.Security.Cryptography;
using System.Text;
namespace WebsitePanel.Providers.Common
{
public class PasswdHelper
{
protected static readonly string MD5_MAGIC_PREFIX = "$apr1$";
protected const int MD5_DIGESTSIZE = 16;
protected static readonly string SHA_MAGIC_PREFIX = "{SHA}";
private static readonly string itoa64 = /* 0 ... 63 => ASCII - 64 */
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static Random _random;
static PasswdHelper()
{
_random = new Random();
}
public static string to64(ulong v, int n)
{
StringBuilder sb = new StringBuilder();
while (--n >= 0)
{
sb.Append(itoa64[(int)v & 0x3f]);
v >>= 6;
}
return sb.ToString();
}
public static string ByteArrayToHexString(byte[] ba)
{
StringBuilder sb = new StringBuilder();
foreach (byte b in ba)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
public static byte[] getMD5HashHex(string s)
{
MD5 md5 = MD5.Create();
return md5.ComputeHash(Encoding.ASCII.GetBytes(s));
}
public static string MD5Encode(string pw, string salt)
{
// äëÿ ïðîâåðêè ïðèõîäèò òàêîå:
// $apr1$Vs5.....$iSQlpTkND9RjL7iAMTjDt.
// äëÿ ãåíåðèðîâàíèÿ ïàðîëÿ ïðèõîäèò ñëó÷àéíàÿ ñòðîêà - ñîëü
string password;
byte[] final;
// íàéä¸ì ñîëü, åñëè â êà÷åñòâå ñîëè ïðèø¸ë óæå õýø
// 1. Óáåð¸ì ìàãè÷åñêèé $apr1$
if (salt.StartsWith(MD5_MAGIC_PREFIX))
{
salt = salt.Substring(MD5_MAGIC_PREFIX.Length);
}
// 2. Íàéä¸ì ñîëü äî ïåðâîãî '$' Èëè 8 ñèìâîëîâ
int sp = salt.IndexOf('$');
if (sp < 0 || sp > 8) sp = 8;
salt = salt.Substring(0, sp);
//Debug.WriteLine(string.Format("salt [{0}]", salt));
ByteVector s = new ByteVector();
ByteVector s1 = new ByteVector();
s.Add(pw);
s.Add(MD5_MAGIC_PREFIX);
s.Add(salt);
s1.Add(pw);
s1.Add(salt);
s1.Add(pw);
final = s1.GetMD5Hash();
for (int i = pw.Length; i > 0; i -= MD5_DIGESTSIZE)
{
s.Add(final, 0, (i > MD5_DIGESTSIZE) ? MD5_DIGESTSIZE : i);
}
for (int i = 0; i < final.Length; i++)
final[i] = 0;
for (int i = pw.Length; i != 0; i >>= 1)
{
// (i & 1) â àïà÷å
if ((i & 0x01) == 1)
{
s.Add(final, 0, 1);
}
else
{
s.Add(pw.Substring(0, 1));
}
}
final = s.GetMD5Hash();
for (int i = 0; i < 1000; i++)
{
s1.Clear();
if ((i & 1) != 0)
{
s1.Add(pw);
}
else
{
s1.Add(final);
}
if ((i % 3) != 0)
{
s1.Add(salt);
}
if ((i % 7) != 0)
{
s1.Add(pw);
}
if ((i & 1) != 0)
{
s1.Add(final);
}
else
{
s1.Add(pw);
}
final = s1.GetMD5Hash();
}
password = "";
ulong l;
l = ((ulong)final[0] << 16) | ((ulong)final[6] << 8) | ((ulong)final[12]);
password += PasswdHelper.to64(l, 4);
l = ((ulong)final[1] << 16) | ((ulong)final[7] << 8) | ((ulong)final[13]);
password += PasswdHelper.to64(l, 4);
l = ((ulong)final[2] << 16) | ((ulong)final[8] << 8) | ((ulong)final[14]);
password += PasswdHelper.to64(l, 4);
l = ((ulong)final[3] << 16) | ((ulong)final[9] << 8) | ((ulong)final[15]);
password += PasswdHelper.to64(l, 4);
l = ((ulong)final[4] << 16) | ((ulong)final[10] << 8) | ((ulong)final[5]);
password += PasswdHelper.to64(l, 4);
l = ((ulong)final[11]);
password += PasswdHelper.to64(l, 2);
password = string.Format("{0}{1}${2}", MD5_MAGIC_PREFIX, salt, password);
return password;
}
public static string SHA1Encode(string clear)
{
if (clear.StartsWith(SHA_MAGIC_PREFIX))
{
clear = clear.Substring(SHA_MAGIC_PREFIX.Length);
}
SHA1 sha = new SHA1CryptoServiceProvider();
string cr = Convert.ToBase64String(
sha.ComputeHash(Encoding.Default.GetBytes(clear))
);
return SHA_MAGIC_PREFIX + cr;
}
public static string GetRandomSalt()
{
return to64((ulong)_random.Next(), 8);
}
public static string DigestEncode(string username, string realm, string passwd)
{
MD5 md5 = MD5.Create();
byte[] b = md5.ComputeHash(Encoding.ASCII.GetBytes(
string.Format("{0}:{1}:{2}", username, realm, passwd)
));
StringBuilder sb = new StringBuilder(b.Length*2);
for (int i = 0; i < b.Length; ++i)
{
sb.Append( String.Format("{0:x2}", b[i]) );
}
return sb.ToString();
}
}
}

View file

@ -0,0 +1,40 @@
// 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;
namespace WebsitePanel.Providers
{
[AttributeUsage(AttributeTargets.Property)]
public class PersistentAttribute : Attribute
{
public PersistentAttribute()
{
}
}
}

View file

@ -0,0 +1,124 @@
// 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.DirectoryServices;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.Providers
{
public class RemoteServerSettings
{
// Active Directory settings
private bool adEnabled;
private AuthenticationTypes adAuthenticationType;
private string adRootDomain;
private string adUsername;
private string adPassword;
// Server settings
private int serverId;
private string serverName;
public RemoteServerSettings()
{
// just do nothing
}
public RemoteServerSettings(string[] settings)
{
// parse settings array
foreach (string setting in settings)
{
int idx = setting.IndexOf('=');
string key = setting.Substring(0, idx);
string val = setting.Substring(idx + 1);
if (key == "AD:Enabled")
ADEnabled = Boolean.Parse(val);
else if (key == "AD:AuthenticationType")
ADAuthenticationType = (AuthenticationTypes)Enum.Parse(typeof(AuthenticationTypes), val, true);
else if (key == "AD:RootDomain")
ADRootDomain = val;
else if (key == "AD:Username")
ADUsername = val;
else if (key == "AD:Password")
ADPassword = val;
else if (key == "Server:ServerId")
ServerId = Int32.Parse(val);
else if (key == "Server:ServerName")
ServerName = val;
}
}
#region Public Properties
public bool ADEnabled
{
get { return this.adEnabled; }
set { this.adEnabled = value; }
}
public AuthenticationTypes ADAuthenticationType
{
get { return this.adAuthenticationType; }
set { this.adAuthenticationType = value; }
}
public string ADRootDomain
{
get { return this.adRootDomain; }
set { this.adRootDomain = value; }
}
public string ADUsername
{
get { return this.adUsername; }
set { this.adUsername = value; }
}
public string ADPassword
{
get { return this.adPassword; }
set { this.adPassword = value; }
}
public int ServerId
{
get { return this.serverId; }
set { this.serverId = value; }
}
public string ServerName
{
get { return this.serverName; }
set { this.serverName = value; }
}
#endregion
}
}

View file

@ -0,0 +1,67 @@
// 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;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for ServerBinding.
/// </summary>
[Serializable]
public class ServerBinding
{
public string Protocol { get; set; }
public string IP { get; set; }
public string Port { get; set; }
public string Host { get; set; }
public ServerBinding()
{
}
public ServerBinding(string ip, string port, string host)
: this("http", ip, port, host)
{
}
public ServerBinding(string protocol, string ip, string port, string host)
{
this.Protocol = protocol;
this.IP = ip;
this.Port = port;
this.Host = host;
}
public override string ToString()
{
return string.Format("{0}:{1}:{2}", this.IP, this.Port, this.Host);
}
}
}

View file

@ -0,0 +1,48 @@
// 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;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for ServerState.
/// </summary>
[Serializable]
public enum ServerState
{
Unknown = 0,
Starting = 1,
Started = 2,
Stopping = 3,
Stopped = 4,
Pausing = 5,
Paused = 6,
Continuing = 7
}
}

View file

@ -0,0 +1,166 @@
// 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.Collections.Specialized;
using System.Xml.Serialization;
using WebsitePanel.Providers.Common;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for ServiceProviderItem.
/// </summary>
[Serializable]
public abstract class ServiceProviderItem
{
private int id;
private int typeId = 0;
private int packageId = -1;
private int serviceId = -1;
private string name;
private string[] properties;
private string groupName;
private StringDictionary propsHash = null;
public ServiceProviderItem()
{
}
public int Id
{
get { return id; }
set { id = value; }
}
public int TypeId
{
get { return typeId; }
set { typeId = value; }
}
public int PackageId
{
get { return packageId; }
set { packageId = value; }
}
public int ServiceId
{
get { return serviceId; }
set { serviceId = value; }
}
public virtual string Name
{
get { return name; }
set { name = value; }
}
public string GroupName
{
get { return this.groupName; }
set { this.groupName = value; }
}
public DateTime CreatedDate
{
get;
set;
}
public string[] Properties
{
get
{
if (propsHash == null)
return null;
properties = new string[propsHash.Count];
int i = 0;
foreach (string key in propsHash.Keys)
properties[i++] = key + "=" + propsHash[key];
return properties;
}
set
{
if (value == null)
return;
properties = value;
// fill hash
propsHash = new StringDictionary();
foreach (string pair in value)
{
int idx = pair.IndexOf('=');
string name = pair.Substring(0, idx);
string val = pair.Substring(idx + 1);
propsHash.Add(name, val);
}
}
}
[XmlIgnore]
public string this[string propertyName]
{
get
{
if (propsHash == null)
propsHash = new StringDictionary();
return propsHash[propertyName];
}
set
{
if (propsHash == null)
propsHash = new StringDictionary();
propsHash[propertyName] = value;
}
}
public T GetValue<T>(string propertyName)
{
string strValue = this[propertyName];
//
if (String.IsNullOrEmpty(strValue))
return default(T);
//
return (T)Convert.ChangeType(strValue, typeof(T));
}
public void SetValue<T>(string propertyName, T propertyValue)
{
this[propertyName] = Convert.ToString(propertyValue);
}
}
}

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;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for ServiceProviderItemBandwidth.
/// </summary>
[Serializable]
public class ServiceProviderItemBandwidth
{
private int itemId;
private DailyStatistics[] days;
public ServiceProviderItemBandwidth()
{
}
public int ItemId
{
get { return itemId; }
set { itemId = value; }
}
public DailyStatistics[] Days
{
get { return days; }
set { days = value; }
}
}
}

View file

@ -0,0 +1,56 @@
// 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
{
[Serializable]
public class ServiceProviderItemDiskSpace
{
private int itemId;
public int ItemId
{
get { return itemId; }
set { itemId = value; }
}
private long diskSpace;
public long DiskSpace
{
get { return diskSpace; }
set { diskSpace = value; }
}
public ServiceProviderItemDiskSpace()
{
}
}
}

View file

@ -0,0 +1,122 @@
// 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
{
public class ServiceProviderItemType
{
private int itemTypeId;
private int groupId;
private string displayName;
private string typeName;
private int typeOrder;
private bool calculateDiskspace;
private bool calculateBandwidth;
private bool suspendable;
private bool disposable;
private bool searchable;
private bool importable;
private bool backupable;
public int ItemTypeId
{
get { return itemTypeId; }
set { itemTypeId = value; }
}
public int GroupId
{
get { return groupId; }
set { groupId = value; }
}
public string DisplayName
{
get { return displayName; }
set { displayName = value; }
}
public string TypeName
{
get { return typeName; }
set { typeName = value; }
}
public int TypeOrder
{
get { return typeOrder; }
set { typeOrder = value; }
}
public bool CalculateDiskspace
{
get { return calculateDiskspace; }
set { calculateDiskspace = value; }
}
public bool CalculateBandwidth
{
get { return calculateBandwidth; }
set { calculateBandwidth = value; }
}
public bool Suspendable
{
get { return suspendable; }
set { suspendable = value; }
}
public bool Disposable
{
get { return disposable; }
set { disposable = value; }
}
public bool Searchable
{
get { return searchable; }
set { searchable = value; }
}
public bool Importable
{
get { return importable; }
set { importable = value; }
}
public bool Backupable
{
get { return backupable; }
set { backupable = value; }
}
}
}

View file

@ -0,0 +1,136 @@
// 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.Specialized;
using System.Text;
namespace WebsitePanel.Providers
{
public class ServiceProviderSettings
{
// settings hash
StringDictionary hash = new StringDictionary();
private int providerGroupID = 0;
private string providerCode = "unknown";
private string providerName = "Unknown";
private string providerType = "";
public ServiceProviderSettings()
{
// just do nothing
}
public ServiceProviderSettings(string[] settings)
{
// parse settings array
foreach (string setting in settings)
{
int idx = setting.IndexOf('=');
string key = setting.Substring(0, idx);
string val = setting.Substring(idx + 1);
if (key.StartsWith("Server:") ||
key.StartsWith("AD:"))
continue;
if (key == "Provider:ProviderGroupID")
ProviderGroupID = Int32.Parse(val);
else if (key == "Provider:ProviderCode")
ProviderCode = val;
else if (key == "Provider:ProviderName")
ProviderName = val;
else if (key == "Provider:ProviderType")
ProviderType = val;
else
hash[key] = val;
}
}
public string this[string settingName]
{
get
{
return hash[settingName];
}
}
public int GetInt(string settingName)
{
int result;
Int32.TryParse(hash[settingName], out result);
return result;
}
public long GetLong(string settingName)
{
long result;
Int64.TryParse(hash[settingName], out result);
return result;
}
public bool GetBool(string settingName)
{
bool result;
Boolean.TryParse(hash[settingName], out result);
return result;
}
#region Public properties
public int ProviderGroupID
{
get { return this.providerGroupID; }
set { this.providerGroupID = value; }
}
public string ProviderCode
{
get { return this.providerCode; }
set { this.providerCode = value; }
}
public string ProviderName
{
get { return this.providerName; }
set { this.providerName = value; }
}
public string ProviderType
{
get { return this.providerType; }
set { this.providerType = value; }
}
public StringDictionary Settings
{
get { return hash; }
}
#endregion
}
}

View file

@ -0,0 +1,49 @@
// 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.Specialized;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for ServiceProviderSettings.
/// </summary>
public class ServiceProviderSettingsSoapHeader : SoapHeader
{
public string[] Settings;
/// <summary>
/// This property is just a flag telling us that this SOAP header should be encrypted.
/// </summary>
[XmlAttribute("SecureHeader", Namespace = "http://smbsaas/websitepanel/server/")]
public bool SecureHeader;
}
}

View file

@ -0,0 +1,62 @@
// 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
{
public class SettingPair
{
private string name;
private string value;
public SettingPair()
{
}
public SettingPair(string name, string value)
{
this.name = name;
this.value = value;
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Value
{
get { return value; }
set { this.value = value; }
}
}
}

View file

@ -0,0 +1,206 @@
// 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.Reflection;
using System.Collections;
using System.Collections.Generic;
namespace WebsitePanel.Providers
{
/// <summary>
/// Summary description for SoapObject.
/// </summary>
[Serializable]
public class SoapServiceProviderItem
{
// static fields
private static Hashtable typeProperties = new Hashtable();
private string[] properties;
private string typeName;
public SoapServiceProviderItem()
{
}
public string[] Properties
{
get { return properties; }
set { properties = value; }
}
public string TypeName
{
get { return typeName; }
set { typeName = value; }
}
// static methods
public static SoapServiceProviderItem Wrap(ServiceProviderItem item)
{
if (item == null)
return null;
// wrap only "persistent" properties
SoapServiceProviderItem sobj = new SoapServiceProviderItem();
sobj.TypeName = item.GetType().AssemblyQualifiedName;
// add common properties
Hashtable props = GetObjectProperties(item, true);
props.Add("Id", item.Id.ToString());
props.Add("Name", item.Name);
props.Add("ServiceId", item.ServiceId.ToString());
props.Add("PackageId", item.PackageId.ToString());
List<string> wrProps = new List<string>();
foreach (string key in props.Keys)
{
wrProps.Add(key + "=" + props[key].ToString());
}
sobj.Properties = wrProps.ToArray();
return sobj;
}
public static ServiceProviderItem Unwrap(SoapServiceProviderItem sobj)
{
Type type = Type.GetType(sobj.TypeName);
ServiceProviderItem item = (ServiceProviderItem)Activator.CreateInstance(type);
// get properties
if (sobj.Properties != null)
{
// get type properties and add it to the hash
Dictionary<string, PropertyInfo> hash = new Dictionary<string, PropertyInfo>();
PropertyInfo[] propInfos = GetTypeProperties(type);
foreach (PropertyInfo propInfo in propInfos)
hash.Add(propInfo.Name, propInfo);
// set service item properties
foreach (string pair in sobj.Properties)
{
int idx = pair.IndexOf('=');
string name = pair.Substring(0, idx);
string val = pair.Substring(idx + 1);
if (hash.ContainsKey(name))
{
// set value
PropertyInfo propInfo = hash[name];
propInfo.SetValue(item, Cast(val, propInfo.PropertyType), null);
}
}
}
return item;
}
private static Hashtable GetObjectProperties(object obj, bool persistentOnly)
{
Hashtable hash = new Hashtable();
Type type = obj.GetType();
PropertyInfo[] props = type.GetProperties(BindingFlags.Instance
| BindingFlags.Public);
foreach (PropertyInfo prop in props)
{
// check for persistent attribute
object[] attrs = prop.GetCustomAttributes(typeof(PersistentAttribute), false);
if (!persistentOnly || (persistentOnly && attrs.Length > 0))
{
object val = prop.GetValue(obj, null);
string s = "";
if (val != null)
{
if (prop.PropertyType == typeof(string[]))
s = String.Join(";", (string[])val);
else if (prop.PropertyType == typeof(int[]))
{
int[] ivals = (int[])val;
string[] svals = new string[ivals.Length];
for (int i = 0; i < svals.Length; i++)
svals[i] = ivals[i].ToString();
s = String.Join(";", svals);
}
else
s = val.ToString();
}
// add property to hash
hash.Add(prop.Name, s);
}
}
return hash;
}
private static PropertyInfo[] GetTypeProperties(Type type)
{
string typeName = type.AssemblyQualifiedName;
if (typeProperties[typeName] != null)
return (PropertyInfo[])typeProperties[typeName];
PropertyInfo[] props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
typeProperties[typeName] = props;
return props;
}
private static object Cast(string val, Type type)
{
if (type == typeof(string))
return val;
if (type == typeof(Int32))
return Int32.Parse(val);
if (type == typeof(Int64))
return Int64.Parse(val);
if (type == typeof(Boolean))
return Boolean.Parse(val);
if (type == typeof(Decimal))
return Decimal.Parse(val);
if (type == typeof(Guid))
return new Guid(val);
if (type.IsEnum)
return Enum.Parse(type, val, true);
if (type == typeof(string[]) && val != null)
{
return val.Split(';');
}
if (type == typeof(int[]) && val != null)
{
string[] sarr = val.Split(';');
int[] iarr = new int[sarr.Length];
for (int i = 0; i < sarr.Length; i++)
iarr[i] = Int32.Parse(sarr[i]);
return iarr;
}
else
return val;
}
}
}

View file

@ -0,0 +1,239 @@
// 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.Server
{
public class TerminalSession
{
private int sessionId;
private string username;
private string status;
public int SessionId
{
get { return this.sessionId; }
set { this.sessionId = value; }
}
public string Username
{
get { return this.username; }
set { this.username = value; }
}
public string Status
{
get { return this.status; }
set { this.status = value; }
}
}
public class WindowsProcess
{
private int pid;
private string name;
private string username;
private long cpuUsage;
private long memUsage;
public int Pid
{
get { return this.pid; }
set { this.pid = value; }
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
public string Username
{
get { return this.username; }
set { this.username = value; }
}
public long CpuUsage
{
get { return this.cpuUsage; }
set { this.cpuUsage = value; }
}
public long MemUsage
{
get { return this.memUsage; }
set { this.memUsage = value; }
}
}
public class WindowsService
{
private string id;
private string name;
private WindowsServiceStatus status;
private bool canStop;
private bool canPauseAndContinue;
public WindowsService()
{
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
public WindowsServiceStatus Status
{
get { return this.status; }
set { this.status = value; }
}
public bool CanStop
{
get { return this.canStop; }
set { this.canStop = value; }
}
public bool CanPauseAndContinue
{
get { return this.canPauseAndContinue; }
set { this.canPauseAndContinue = value; }
}
public string Id
{
get { return this.id; }
set { this.id = value; }
}
}
public enum WindowsServiceStatus
{
ContinuePending = 1,
Paused = 2,
PausePending = 3,
Running = 4,
StartPending = 5,
Stopped = 6,
StopPending = 7
}
public class SystemLogEntriesPaged
{
private int count;
private SystemLogEntry[] entries;
public int Count
{
get { return count; }
set { count = value; }
}
public SystemLogEntry[] Entries
{
get { return entries; }
set { entries = value; }
}
}
public class SystemLogEntry
{
private SystemLogEntryType entryType;
private DateTime created;
private string source;
private string category;
private long eventId;
private string userName;
private string machineName;
private string message;
public SystemLogEntryType EntryType
{
get { return entryType; }
set { entryType = value; }
}
public DateTime Created
{
get { return created; }
set { created = value; }
}
public string Source
{
get { return source; }
set { source = value; }
}
public string Category
{
get { return category; }
set { category = value; }
}
public string UserName
{
get { return userName; }
set { userName = value; }
}
public string MachineName
{
get { return machineName; }
set { machineName = value; }
}
public long EventID
{
get { return eventId; }
set { eventId = value; }
}
public string Message
{
get { return message; }
set { message = value; }
}
}
public enum SystemLogEntryType
{
Information,
Warning,
Error,
SuccessAudit,
FailureAudit
}
}