예제 #1
0
        public static SiteMinder WithNoSpam(this SiteMinder siteMinder, int?maxAttemptsWithinDuration = null,
                                            TimeSpan?withinDuration = null)
        {
            var fileStorage = new XmlFileStorageProvider <IpAddressRequest>();

            fileStorage.Initialise(new[] { GetXmlFolder() });
            var ruleSet = CreateRule <IpAddressBlockerRuleSetHandler, IpAddressRequest> .On <IpAddressRequest>()
                          .With(a => a.MaxAttemptsWithinDuration = maxAttemptsWithinDuration.GetValueOrDefault(100))
                          .With(a => a.Duration         = withinDuration.GetValueOrDefault(TimeSpan.FromDays(-1)))
                          .With(a => a.StorageMechanism = fileStorage)
                          .Build();

            return(siteMinder.AddRule <IpBlockerRuleSet, IpAddressBlockerRuleSetHandler, IpAddressRequest>(x => ruleSet));
        }
        public void InitializeTest()
        {
            ConfigurationSettings      settings     = GetConfigurationSettings(XmlString);
            ConfigurationSectionData   sectionData  = settings.ConfigurationSections[applConfig1];
            XmlFileStorageProviderData providerData = (XmlFileStorageProviderData)sectionData.StorageProvider;

            providerData.SectionName = applConfig1;
            XmlFileStorageProvider provider = new XmlFileStorageProvider();

            provider.CurrentSectionName = applConfig1;
            RuntimeConfigurationView configurationView = new RuntimeConfigurationView(context);

            provider.Initialize(configurationView);
        }
 public XmlFileStorageProviderTests()
 {
     _storageProvider = new XmlFileStorageProvider <IpAddressRequest>();
     _storageProvider.Initialise(new[] { _temp });
     File.Delete(_storageProvider.FileName);
 }
 public void InitializeTest()
 {
     ConfigurationSettings settings = GetConfigurationSettings(XmlString);
     ConfigurationSectionData sectionData = settings.ConfigurationSections[applConfig1];
     XmlFileStorageProviderData providerData = (XmlFileStorageProviderData)sectionData.StorageProvider;
     providerData.SectionName = applConfig1;
     XmlFileStorageProvider provider = new XmlFileStorageProvider();
     provider.CurrentSectionName = applConfig1;
     RuntimeConfigurationView configurationView = new RuntimeConfigurationView(context);
     provider.Initialize(configurationView);
 }