private void InitPasswordSettings()
        {
            var passwordSettings = PasswordSettings.Load();

            UserPasswordMinLength   = passwordSettings.MinLength;
            UserPasswordDigits      = passwordSettings.Digits;
            UserPasswordSpecSymbols = passwordSettings.SpecSymbols;
            UserPasswordUpperCase   = passwordSettings.UpperCase;
        }
Esempio n. 2
0
        protected string GetMailConstantsAsInlineScript()
        {
            var sbScript = new StringBuilder();

            sbScript
            .AppendFormat("ASC.Mail.Constants.CHECK_NEWS_TIMEOUT = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailCheckNewsTimeout()))
            .AppendFormat("ASC.Mail.Constants.CRM_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsCrmAvailable()))
            .AppendFormat("ASC.Mail.Constants.PEOPLE_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsPeopleAvailable()))
            .AppendFormat("ASC.Mail.Constants.CALENDAR_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsCalndarAvailable()))
            .AppendFormat("ASC.Mail.Constants.COMMON_DOMAIN_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsMailCommonDomainAvailable()))
            .AppendFormat("ASC.Mail.Constants.PRINT_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsMailPrintAvailable()))
            .AppendFormat("ASC.Mail.Constants.FAQ_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailFaqUri()))
            .AppendFormat("ASC.Mail.Constants.SUPPORT_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailSupportUri()))
            .AppendFormat("ASC.Mail.Constants.DOWNLOAD_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailDownloadHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.VIEW_DOCUMENT_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailViewDocumentHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.EDIT_DOCUMENT_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailEditDocumentHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.CONTACT_PHOTO_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailContactPhotoHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.Errors = {0};\r\n",
                          JsonConvert.SerializeObject(GetErrorConstants()))
            .AppendFormat("ASC.Mail.Constants.Alerts = {0};\r\n",
                          JsonConvert.SerializeObject(GetAlerts()))
            .AppendFormat("ASC.Mail.Constants.MAIL_DAEMON_EMAIL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailDaemonEmail()))
            .AppendFormat("ASC.Mail.Constants.FiLTER_BY_GROUP_LOCALIZE = {0};\r\n",
                          JsonConvert.SerializeObject(CustomNamingPeople.Substitute <MailResource>("FilterByGroup").HtmlEncode()))
            .AppendFormat("ASC.Mail.Constants.NEED_PROXY_HTTP_URL = {0};\r\n",
                          JsonConvert.SerializeObject(SetupInfo.IsVisibleSettings("ProxyHttpContent")))
            .AppendFormat("ASC.Mail.Constants.PROXY_HTTP_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetProxyHttpUrl()))
            .AppendFormat("ASC.Mail.Constants.PASSWORD_SETTINGS = {0};\r\n",
                          JsonConvert.SerializeObject(PasswordSettings.Load()))
            .AppendFormat("ASC.Mail.Constants.MAXIMUM_MESSAGE_BODY_SIZE = {0};\r\n",
                          JsonConvert.SerializeObject(GetMaximumMessageBodySize()))
            .AppendFormat("ASC.Mail.Constants.MS_MIGRATION_LINK_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsMSExchangeMigrationLinkAvailable()))
            .AppendFormat("ASC.Mail.Constants.ENABLE_MAIL_SERVER = {0};\r\n",
                          JsonConvert.SerializeObject(IsEnableMailServer()))
            .AppendFormat("ASC.Mail.Constants.LinkToTariff = {0};\r\n",
                          JsonConvert.SerializeObject(LinkToTariff()))
            .AppendFormat("ASC.Mail.Constants.IMAP_SYNC_START_DATE = {0};\r\n",
                          JsonConvert.SerializeObject(GetImapSyncStartDate()));


            return(sbScript.ToString());
        }
        public static string GeneratePassword()
        {
            var ps = PasswordSettings.Load();

            var maxLength = PasswordSettings.MaxLength
                            - (ps.Digits ? 1 : 0)
                            - (ps.UpperCase ? 1 : 0)
                            - (ps.SpecSymbols ? 1 : 0);
            var minLength = Math.Min(ps.MinLength, maxLength);

            return(string.Format("{0}{1}{2}{3}",
                                 GeneratePassword(minLength, minLength, Noise[0..^ 4]),
        public static void CheckPasswordPolicy(string password)
        {
            if (String.IsNullOrWhiteSpace(password))
            {
                throw new Exception(Resource.ErrorPasswordEmpty);
            }

            var passwordSettingsObj = PasswordSettings.Load();

            if (!PasswordSettings.CheckPasswordRegex(passwordSettingsObj, password))
            {
                throw new Exception(GenerateErrorMessage(passwordSettingsObj));
            }
        }
        protected string GetMailConstantsAsInlineScript()
        {
            var sbScript = new StringBuilder();

            sbScript
            .AppendFormat("ASC.Mail.Constants.CHECK_NEWS_TIMEOUT = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailCheckNewsTimeout()))
            .AppendFormat("ASC.Mail.Constants.CRM_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsCrmAvailable()))
            .AppendFormat("ASC.Mail.Constants.PEOPLE_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsPeopleAvailable()))
            .AppendFormat("ASC.Mail.Constants.CALENDAR_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsCalndarAvailable()))
            .AppendFormat("ASC.Mail.Constants.COMMON_DOMAIN_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsMailCommonDomainAvailable()))
            .AppendFormat("ASC.Mail.Constants.PRINT_AVAILABLE = {0};\r\n",
                          JsonConvert.SerializeObject(IsMailPrintAvailable()))
            .AppendFormat("ASC.Mail.Constants.FAQ_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailFaqUri()))
            .AppendFormat("ASC.Mail.Constants.SUPPORT_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailSupportUri()))
            .AppendFormat("ASC.Mail.Constants.DOWNLOAD_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailDownloadHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.DOWNLOAD_ALL_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailDownloadAllHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.VIEW_DOCUMENT_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailViewDocumentHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.EDIT_DOCUMENT_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailEditDocumentHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.CONTACT_PHOTO_HANDLER_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailContactPhotoHandlerUri()))
            .AppendFormat("ASC.Mail.Constants.Errors = {0};\r\n",
                          JsonConvert.SerializeObject(GetErrorConstants()))
            .AppendFormat("ASC.Mail.Constants.Alerts = {0};\r\n",
                          JsonConvert.SerializeObject(GetAlerts()))
            .AppendFormat("ASC.Mail.Constants.MAIL_DAEMON_EMAIL = {0};\r\n",
                          JsonConvert.SerializeObject(GetMailDaemonEmail()))
            .AppendFormat("ASC.Mail.Constants.FiLTER_BY_GROUP_LOCALIZE = {0};\r\n",
                          JsonConvert.SerializeObject(CustomNamingPeople.Substitute <MailResource>("FilterByGroup")))
            .AppendFormat("ASC.Mail.Constants.NEED_PROXY_HTTP_URL = {0};\r\n",
                          JsonConvert.SerializeObject(SetupInfo.IsVisibleSettings("ProxyHttpContent")))
            .AppendFormat("ASC.Mail.Constants.PROXY_HTTP_URL = {0};\r\n",
                          JsonConvert.SerializeObject(GetProxyHttpUrl()))
            .AppendFormat("ASC.Mail.Constants.PASSWORD_SETTINGS = {0};\r\n",
                          JsonConvert.SerializeObject(PasswordSettings.Load()));

            return(sbScript.ToString());
        }
        public static string GeneratePassword()
        {
            var ps = PasswordSettings.Load();

            var maxLength = PasswordSettings.MaxLength
                            - (ps.Digits ? 1 : 0)
                            - (ps.UpperCase ? 1 : 0)
                            - (ps.SpecSymbols ? 1 : 0);
            var minLength = Math.Min(ps.MinLength, maxLength);

            return(String.Format("{0}{1}{2}{3}",
                                 GeneratePassword(minLength, minLength, Noise.Substring(0, Noise.Length - 4)),
                                 ps.Digits ? GeneratePassword(1, 1, Noise.Substring(0, 10)) : String.Empty,
                                 ps.UpperCase ? GeneratePassword(1, 1, Noise.Substring(10, 20).ToUpper()) : String.Empty,
                                 ps.SpecSymbols ? GeneratePassword(1, 1, Noise.Substring(Noise.Length - 4, 4).ToUpper()) : String.Empty));
        }
Esempio n. 7
0
        /// <summary>
        /// Get valid password or throw exception.
        /// </summary>
        /// <param name="password">String contains valid password according to portal settings</param>
        /// <returns>trimmed password or exception</returns>
        public static string GetValidPassword(string password)
        {
            var trimPwd = password.Trim();

            if (string.IsNullOrEmpty(trimPwd))
            {
                throw new ArgumentException(Resource.ErrorPasswordEmpty);
            }

            var pwdSettings = PasswordSettings.Load();

            if (!PasswordSettings.CheckPasswordRegex(pwdSettings, trimPwd))
            {
                throw new ArgumentException(UserManagerWrapper.GetPasswordHelpMessage(pwdSettings));
            }

            return(trimPwd);
        }
Esempio n. 8
0
        /// <summary>
        /// Get valid password or throw exception.
        /// </summary>
        /// <param name="password">String contains valid password according to portal settings</param>
        /// <returns>trimmed password or exception</returns>
        public static string GetValidPassword(string password)
        {
            var trimPwd = password.Trim();

            if (string.IsNullOrEmpty(trimPwd))
            {
                throw new ArgumentException(Resource.ErrorPasswordEmpty);
            }

            var pwdSettings = PasswordSettings.Load();

            if (!PasswordSettings.CheckPasswordRegex(pwdSettings, trimPwd) ||
                RegxNoneAscii.IsMatch(trimPwd) ||
                RegxWhiteSpaces.IsMatch(trimPwd))
            {
                throw new ArgumentException(GeneratePasswordErrorMessage(pwdSettings));
            }

            return(trimPwd);
        }
Esempio n. 9
0
        public string GetRandomPassword()
        {
            var Noise = "1234567890mnbasdflkjqwerpoiqweyuvcxnzhdkqpsdk_-()=";

            var ps = PasswordSettings.Load();

            var maxLength = PasswordSettings.MaxLength
                            - (ps.Digits ? 1 : 0)
                            - (ps.UpperCase ? 1 : 0)
                            - (ps.SpecSymbols ? 1 : 0);
            var minLength = Math.Min(ps.MinLength, maxLength);

            var password = String.Format("{0}{1}{2}{3}",
                                         GeneratePassword(minLength, minLength, Noise.Substring(0, Noise.Length - 4)),
                                         ps.Digits ? GeneratePassword(1, 1, Noise.Substring(0, 10)) : String.Empty,
                                         ps.UpperCase ? GeneratePassword(1, 1, Noise.Substring(10, 20).ToUpper()) : String.Empty,
                                         ps.SpecSymbols ? GeneratePassword(1, 1, Noise.Substring(Noise.Length - 4, 4).ToUpper()) : String.Empty);

            return(password);
        }
        public static string GetPasswordHelpMessage()
        {
            var info             = new StringBuilder();
            var passwordSettings = PasswordSettings.Load();

            info.AppendFormat("{0} ", Resource.ErrorPasswordMessageStart);
            info.AppendFormat(Resource.ErrorPasswordLength, passwordSettings.MinLength, PasswordSettings.MaxLength);
            if (passwordSettings.UpperCase)
            {
                info.AppendFormat(", {0}", Resource.ErrorPasswordNoUpperCase);
            }
            if (passwordSettings.Digits)
            {
                info.AppendFormat(", {0}", Resource.ErrorPasswordNoDigits);
            }
            if (passwordSettings.SpecSymbols)
            {
                info.AppendFormat(", {0}", Resource.ErrorPasswordNoSpecialSymbols);
            }

            return(info.ToString());
        }
        public object GetPasswordSettings()
        {
            var UserPasswordSettings = PasswordSettings.Load();

            return(UserPasswordSettings);
        }
Esempio n. 12
0
 public static string GetPasswordHelpMessage()
 {
     return(GetPasswordHelpMessage(PasswordSettings.Load()));
 }