Removing the SecurityHelper and moving the 3 methods into the Provider as private classes, as they aren't used anywhere else.
The SecUtility will be removed along with the legacy MembershipProvider when cleanup is possible.
This commit is contained in:
@@ -183,16 +183,16 @@ namespace Umbraco.Web.Security.Providers
|
||||
// Initialize base provider class
|
||||
base.Initialize(name, config);
|
||||
|
||||
_applicationName = string.IsNullOrEmpty(config["applicationName"]) ? SecurityHelper.GetDefaultAppName() : config["applicationName"];
|
||||
_applicationName = string.IsNullOrEmpty(config["applicationName"]) ? GetDefaultAppName() : config["applicationName"];
|
||||
|
||||
_enablePasswordRetrieval = SecurityHelper.GetBooleanValue(config, "enablePasswordRetrieval", false);
|
||||
_enablePasswordReset = SecurityHelper.GetBooleanValue(config, "enablePasswordReset", false);
|
||||
_requiresQuestionAndAnswer = SecurityHelper.GetBooleanValue(config, "requiresQuestionAndAnswer", false);
|
||||
_requiresUniqueEmail = SecurityHelper.GetBooleanValue(config, "requiresUniqueEmail", true);
|
||||
_maxInvalidPasswordAttempts = SecurityHelper.GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);
|
||||
_passwordAttemptWindow = SecurityHelper.GetIntValue(config, "passwordAttemptWindow", 10, false, 0);
|
||||
_minRequiredPasswordLength = SecurityHelper.GetIntValue(config, "minRequiredPasswordLength", 7, true, 0x80);
|
||||
_minRequiredNonAlphanumericCharacters = SecurityHelper.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 0x80);
|
||||
_enablePasswordRetrieval = GetBooleanValue(config, "enablePasswordRetrieval", false);
|
||||
_enablePasswordReset = GetBooleanValue(config, "enablePasswordReset", false);
|
||||
_requiresQuestionAndAnswer = GetBooleanValue(config, "requiresQuestionAndAnswer", false);
|
||||
_requiresUniqueEmail = GetBooleanValue(config, "requiresUniqueEmail", true);
|
||||
_maxInvalidPasswordAttempts = GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);
|
||||
_passwordAttemptWindow = GetIntValue(config, "passwordAttemptWindow", 10, false, 0);
|
||||
_minRequiredPasswordLength = GetIntValue(config, "minRequiredPasswordLength", 7, true, 0x80);
|
||||
_minRequiredNonAlphanumericCharacters = GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 0x80);
|
||||
_passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"];
|
||||
|
||||
// make sure password format is Hashed by default.
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration.Provider;
|
||||
using System.Web.Hosting;
|
||||
|
||||
namespace Umbraco.Web.Security
|
||||
{
|
||||
internal class SecurityHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the boolean value.
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
/// <param name="valueName">Name of the value.</param>
|
||||
/// <param name="defaultValue">if set to <c>true</c> [default value].</param>
|
||||
/// <returns></returns>
|
||||
internal static bool GetBooleanValue(NameValueCollection config, string valueName, bool defaultValue)
|
||||
{
|
||||
bool flag;
|
||||
var str = config[valueName];
|
||||
if (str == null)
|
||||
return defaultValue;
|
||||
|
||||
if (bool.TryParse(str, out flag) == false)
|
||||
{
|
||||
throw new ProviderException("Value must be boolean.");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the int value.
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
/// <param name="valueName">Name of the value.</param>
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <param name="zeroAllowed">if set to <c>true</c> [zero allowed].</param>
|
||||
/// <param name="maxValueAllowed">The max value allowed.</param>
|
||||
/// <returns></returns>
|
||||
internal static int GetIntValue(NameValueCollection config, string valueName, int defaultValue, bool zeroAllowed, int maxValueAllowed)
|
||||
{
|
||||
int num;
|
||||
var s = config[valueName];
|
||||
if (s == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (int.TryParse(s, out num) == false)
|
||||
{
|
||||
if (zeroAllowed)
|
||||
{
|
||||
throw new ProviderException("Value must be non negative integer");
|
||||
}
|
||||
throw new ProviderException("Value must be positive integer");
|
||||
}
|
||||
if (zeroAllowed && (num < 0))
|
||||
{
|
||||
throw new ProviderException("Value must be non negativeinteger");
|
||||
}
|
||||
if (zeroAllowed == false && (num <= 0))
|
||||
{
|
||||
throw new ProviderException("Value must be positive integer");
|
||||
}
|
||||
if ((maxValueAllowed > 0) && (num > maxValueAllowed))
|
||||
{
|
||||
throw new ProviderException("Value too big");
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the default app.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static string GetDefaultAppName()
|
||||
{
|
||||
try
|
||||
{
|
||||
var applicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
|
||||
return string.IsNullOrEmpty(applicationVirtualPath) ? "/" : applicationVirtualPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,6 @@
|
||||
<Compile Include="Controllers\ProfileController.cs" />
|
||||
<Compile Include="Controllers\LoginStatusController.cs" />
|
||||
<Compile Include="Editors\MediaController.cs" />
|
||||
<Compile Include="Security\SecurityHelper.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentSortOrder.cs" />
|
||||
<Compile Include="Controllers\RegisterController.cs" />
|
||||
<Compile Include="Models\ProfileModel.cs" />
|
||||
|
||||
Reference in New Issue
Block a user