public static void FromLegacy(
            this MembershipRebootConfiguration config,
            INotificationService notificationService,
            IPasswordPolicy passwordPolicy)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (notificationService != null)
            {
                config.AddEventHandler(new NotificationServiceEventHandler(notificationService));
                if (config.SecuritySettings.RequireAccountVerification)
                {
                    config.AddEventHandler(new NotificationServiceAccountCreatedEventHandler(notificationService));
                }
            }

            if (passwordPolicy != null)
            {
                config.RegisterPasswordValidator(new DelegateValidator(
                                                     (svc, acct, password) =>
                {
                    if (!passwordPolicy.ValidatePassword(password))
                    {
                        return(new ValidationResult("Invalid password: " + passwordPolicy.PolicyMessage));
                    }
                    return(null);
                }));
            }
        }
        public static void FromLegacy(
            this MembershipRebootConfiguration config, 
            INotificationService notificationService, 
            IPasswordPolicy passwordPolicy)
        {
            if (config == null) throw new ArgumentNullException("config");
            
            if (notificationService != null)
            {
                config.AddEventHandler(new NotificationServiceEventHandler(notificationService));
                if (config.SecuritySettings.RequireAccountVerification)
                {
                    config.AddEventHandler(new NotificationServiceAccountCreatedEventHandler(notificationService));
                }
            }

            if (passwordPolicy != null)
            {
                config.RegisterPasswordValidator(new DelegateValidator(
                    (svc, acct, password) =>
                    {
                        if (!passwordPolicy.ValidatePassword(password))
                        {
                            return new ValidationResult("Invalid password: " + passwordPolicy.PolicyMessage);
                        }
                        return null;
                    }));
            }
        }
コード例 #3
0
        protected internal virtual void ValidatePassword(string tenant, string username, string password)
        {
            if (passwordPolicy != null)
            {
                if (!passwordPolicy.ValidatePassword(password))
                {
                    Tracing.Verbose(String.Format("[ValidatePassword] Failed: {0}, {1}, {2}", tenant, username, passwordPolicy.PolicyMessage));

                    throw new ValidationException("Invalid password: " + passwordPolicy.PolicyMessage);
                }
            }
        }