public static PasswordSetting GetPasswordSetting() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(HttpContext.Current.Server.MapPath("~/PasswordPolicy.xml")); PasswordSetting passwordSetting = new PasswordSetting(); foreach (XmlNode node in xmlDoc.ChildNodes) { foreach (XmlNode node2 in node.ChildNodes) { passwordSetting.Duration = int.Parse(node2["duration"].InnerText); passwordSetting.MinLength = int.Parse(node2["minLength"].InnerText); passwordSetting.MaxLength = int.Parse(node2["maxLength"].InnerText); passwordSetting.NumsLength = int.Parse(node2["numsLength"].InnerText); passwordSetting.SpecialLength = int.Parse(node2["specialLength"].InnerText); passwordSetting.UpperLength = int.Parse(node2["upperLength"].InnerText); passwordSetting.SpecialChars = node2["specialChars"].InnerText; passwordSetting.MaxConsecutiveRepeatedChars = int.Parse(node2["maxConsecutiveRepeatedChars"].InnerText); } } return(passwordSetting); }
public CredentialsProfile(string profileName, ProfileScope profileScope, string userName, PasswordSetting password, string domain) { _profileName = profileName; _profileScope = profileScope; _userName = userName; _password = password; _domain = domain; }
public UserMongoDBService(IUserMongoDBRepository userMongoDBRepository, IPasswordService passwordService, IOptions <PasswordSetting> passwordSetting) { _userMongoDBRepository = userMongoDBRepository; _passwordService = passwordService; _passwordSetting = passwordSetting.Value; }
public override void Execute() { if (CommandArgs.Count != 2) { throw new ArgumentException("Missing arguments, usage: EasyPass -a <project name> <password>"); } var projectName = CommandArgs[0]; var password = CommandArgs[1]; var newPasswordSetting = new PasswordSetting() { ProjectName = projectName, Password = password }; _passwordSettingRepository.AddUpdatePasswordSetting(newPasswordSetting); }
public CredentialsProfile(string profileName, ProfileScope profileScope, string userName, string password, string domain) { _profileName = profileName; _profileScope = profileScope; _userName = userName; _password = new PasswordSetting(password) { IsDecrypted = true }; _domain = domain; }
public BusConfiguration( UserNameSetting userName, PasswordSetting password, MessageBrokerUriSetting messageBrokerUri, MessageBrokerSetting messageBroker, AzureTokenProviderKeyNameSetting azureTokenProviderKeyName, AzureTokenProviderSharedAccessKeySetting azureTokenProviderSharedAccessKey) { UserName = userName; Password = password; MessageBrokerUri = messageBrokerUri; MessageBroker = messageBroker; AzureTokenProviderKeyName = azureTokenProviderKeyName; AzureTokenProviderSharedAccessKey = azureTokenProviderSharedAccessKey; }
public static bool IsPasswordMeetPolicy(string strPassword) { PasswordSetting passwordSetting = Helper.GetPasswordSetting(); StringBuilder sbPasswordRegx = new StringBuilder(string.Empty); //min and max sbPasswordRegx.Append(@"(?=^.{" + passwordSetting.MinLength + "," + passwordSetting.MaxLength + "}$)"); //numbers length sbPasswordRegx.Append(@"(?=(?:.*?\d){" + passwordSetting.NumsLength + "})"); //a-z characters sbPasswordRegx.Append(@"(?=.*[a-z])"); //A-Z length sbPasswordRegx.Append(@"(?=(?:.*?[A-Z]){" + passwordSetting.UpperLength + "})"); //special characters length sbPasswordRegx.Append(@"(?=(?:.*?[" + passwordSetting.SpecialChars + "]){" + passwordSetting.SpecialLength + "})"); //(?!.*\s) - no spaces //^(?:(?!([0-9a-zA-Z!@#$%*()_+^&]+)\1{1,}).)*$ //[0-9a-zA-Z!@#$%*()_+^&] -- valid characters if (passwordSetting.MaxConsecutiveRepeatedChars > 0) { sbPasswordRegx.Append(string.Format(@"(?!.*\s)^(?i:(?!([0-9a-zA-Z{0}]+)\1{{{1},}}).)*$", passwordSetting.SpecialChars, passwordSetting.MaxConsecutiveRepeatedChars)); } else { sbPasswordRegx.Append(@"(?!.*\s)[0-9a-zA-Z" + passwordSetting.SpecialChars + "]*$"); } //more custom validation here .... return(Regex.IsMatch(strPassword, sbPasswordRegx.ToString())); }
public PasswordService(IOptions <PasswordSetting> passwordSetting) { _passwordSetting = passwordSetting.Value; }