{
internal class SqliteMembershipProvider : MembershipProvider
{
- private const string m_TableName = "Users";
- private string m_ConnectionString = string.Empty;
- private const int m_NewPasswordLength = 8;
- private bool machineKeyIsAutoGenerated;
+ const string m_TableName = "Users";
+ string m_ConnectionString = string.Empty;
+ const int m_NewPasswordLength = 8;
+ bool machineKeyIsAutoGenerated;
// Used when determining encryption key values.
- private MachineKeySection m_MachineKey = null;
+ MachineKeySection m_MachineKey = null;
DbParameter AddParameter (DbCommand command, string parameterName, object parameterValue)
{
}
// Get encryption and decryption key information from the configuration.
- System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);
- m_MachineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");
+ m_MachineKey = (MachineKeySection)WebConfigurationManager.GetSection("system.web/machineKey", null);
if (!m_PasswordFormat.Equals(MembershipPasswordFormat.Clear))
{
/// System.Web.Security.MembershipProvider properties.
/// </summary>
#region System.Web.Security.MembershipProvider properties
- private string m_ApplicationName = string.Empty;
- private bool m_EnablePasswordReset = false;
- private bool m_EnablePasswordRetrieval = false;
- private bool m_RequiresQuestionAndAnswer = false;
- private bool m_RequiresUniqueEmail = false;
- private int m_MaxInvalidPasswordAttempts = 0;
- private int m_PasswordAttemptWindow = 0;
- private MembershipPasswordFormat m_PasswordFormat = MembershipPasswordFormat.Clear;
- private int m_MinRequiredNonAlphanumericCharacters = 0;
- private int m_MinRequiredPasswordLength = 0;
- private string m_PasswordStrengthRegularExpression = string.Empty;
+ string m_ApplicationName = string.Empty;
+ bool m_EnablePasswordReset = false;
+ bool m_EnablePasswordRetrieval = false;
+ bool m_RequiresQuestionAndAnswer = false;
+ bool m_RequiresUniqueEmail = false;
+ int m_MaxInvalidPasswordAttempts = 0;
+ int m_PasswordAttemptWindow = 0;
+ MembershipPasswordFormat m_PasswordFormat = MembershipPasswordFormat.Clear;
+ int m_MinRequiredNonAlphanumericCharacters = 0;
+ int m_MinRequiredPasswordLength = 0;
+ string m_PasswordStrengthRegularExpression = string.Empty;
public override string ApplicationName
{
/// <param name="configValue"></param>
/// <param name="defaultValue"></param>
/// <returns></returns>
- private string GetConfigValue(string configValue, string defaultValue)
+ string GetConfigValue(string configValue, string defaultValue)
{
if (string.IsNullOrEmpty(configValue))
return defaultValue;
/// </summary>
/// <param name="reader">SqliteDataReader object</param>
/// <returns>MembershipUser object</returns>
- private MembershipUser GetUserFromReader(SqliteDataReader reader)
+ MembershipUser GetUserFromReader(SqliteDataReader reader)
{
object providerUserKey = reader.GetValue(0);
string username = reader.GetString(1);
/// <param name="password"></param>
/// <param name="dbpassword"></param>
/// <returns></returns>
- private bool CheckPassword(string password, string dbpassword)
+ bool CheckPassword(string password, string dbpassword)
{
string pass1 = password;
string pass2 = dbpassword;
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
- private string EncodePassword(string password)
+ string EncodePassword(string password)
{
if (string.IsNullOrEmpty(password))
return password;
case MembershipPasswordFormat.Hashed:
HMACSHA1 hash = new HMACSHA1();
if (machineKeyIsAutoGenerated)
- hash.Key = MachineKeySectionUtils.ValidationKeyBytes ();
+ hash.Key = MachineKeySection.Config.GetValidationKey ();
else
hash.Key = HexToByte(m_MachineKey.ValidationKey);
encodedPassword = Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password)));
/// </summary>
/// <param name="encodedPassword"></param>
/// <returns></returns>
- private string UnEncodePassword(string encodedPassword)
+ string UnEncodePassword(string encodedPassword)
{
string password = encodedPassword;
/// </summary>
/// <param name="hexString"></param>
/// <returns></returns>
- private byte[] HexToByte(string hexString)
+ byte[] HexToByte(string hexString)
{
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
/// </summary>
/// <param name="username"></param>
/// <param name="failType"></param>
- private void UpdateFailureCount(string username, FailureType failType)
+ void UpdateFailureCount(string username, FailureType failType)
{
DateTime windowStart = new DateTime();
int failureCount = 0;
}
}
- private enum FailureType
+ enum FailureType
{
Password,
PasswordAnswer