Exemplo n.º 1
0
        private static SecuritySettings GenerateSecuritySettings()
        {
            SecuritySettings settings = new SecuritySettings();
            settings.DefaultAuthorizationProviderName = "Authorization Provider";
            settings.DefaultAuthenticationProviderName = "Authentication Provider";
            settings.DefaultProfileProviderName = "Profile Provider";
            settings.DefaultRolesProviderName = "Roles Provider";
            settings.DefaultSecurityCacheProviderName = "Security Cache Provider1";

            AuthorizationRuleProviderData providerData = new AuthorizationRuleProviderData("RuleProvider");
            providerData.Rules.Add(new AuthorizationRuleData("Rule1", "I:TestUser OR R:Admin"));
            settings.AuthorizationProviders.Add(providerData);

            settings.AuthorizationProviders.Add(new CustomAuthorizationProviderData("Authorization Provider", typeof (MockAuthorizationProvider).AssemblyQualifiedName));
            settings.AuthorizationProviders.Add(new CustomAuthorizationProviderData("provider1", typeof(MockAuthorizationProvider).AssemblyQualifiedName ));
            settings.AuthorizationProviders.Add(new CustomAuthorizationProviderData("provider2", typeof(Mock2AuthorizationProvider).AssemblyQualifiedName ));

            settings.AuthenticationProviders.Add(new CustomAuthenticationProviderData("Authentiction Provider", typeof (MockAuthenticationProvider).AssemblyQualifiedName));

            settings.RolesProviders.Add(new CustomRolesProviderData("Roles Provider", typeof (MockRolesProvider).AssemblyQualifiedName));

            settings.ProfileProviders.Add(new CustomProfileProviderData("Profile Provider", typeof (MockProfileProvider).AssemblyQualifiedName));

            settings.SecurityCacheProviders.Add(new CustomSecurityCacheProviderData("Security Cache Provider1", typeof (MockSecurityCacheProvider).AssemblyQualifiedName));

            return settings;
        }
        public void CanDeserializeSerializedConfiguration()
        {
            SecuritySettings settings = new SecuritySettings();

            CachingStoreProviderData securityCacheData1 = new CachingStoreProviderData(securityCacheName1, sliding1, absolute1, manager1);

            settings.SecurityCacheProviders.Add(securityCacheData1);
            settings.DefaultSecurityCacheProviderName = securityCacheName1;

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>();
            sections[SecuritySettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            SecuritySettings roSettigs = (SecuritySettings)configurationSource.GetSection(SecuritySettings.SectionName);

            Assert.IsNotNull(roSettigs);
            Assert.AreEqual(1, roSettigs.SecurityCacheProviders.Count);

            Assert.IsNotNull(roSettigs.SecurityCacheProviders.Get(securityCacheName1));
            Assert.AreSame(typeof(CachingStoreProviderData), roSettigs.SecurityCacheProviders.Get(securityCacheName1).GetType());
            Assert.AreEqual(absolute1, ((CachingStoreProviderData)roSettigs.SecurityCacheProviders.Get(securityCacheName1)).AbsoluteExpiration);
            Assert.AreEqual(manager1, ((CachingStoreProviderData)roSettigs.SecurityCacheProviders.Get(securityCacheName1)).CacheManager);
            Assert.AreEqual(sliding1, ((CachingStoreProviderData)roSettigs.SecurityCacheProviders.Get(securityCacheName1)).SlidingExpiration);
        }
 public void SetUp()
 {
     provider = new SecuritySettingsManageabilityProvider(new Dictionary<Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     section = new SecuritySettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add(SecuritySettings.SectionName, section);
 }
        public void Setup()
        {
            AuthorizationRuleProviderData ruleProvider = new AuthorizationRuleProviderData();
            ruleProvider.Name = "Rule Provider";

            SecuritySettings settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(ruleProvider);

            registrations = settings.GetRegistrations(null);
        }
        public void Setup()
        {
            AzManAuthorizationProviderData azManProviderdata = new AzManAuthorizationProviderData();
            azManProviderdata.Name = "AzMan Provider";

            SecuritySettings settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(azManProviderdata);

            registrations = settings.GetRegistrations(null);
        }
        public void Setup()
        {
            CachingStoreProviderData securityCacheProvider = new CachingStoreProviderData();
            securityCacheProvider.Name = "Caching Store Provider";

            SecuritySettings settings = new SecuritySettings();
            settings.SecurityCacheProviders.Add(securityCacheProvider);

            registrations = settings.GetRegistrations(null);
        }
Exemplo n.º 7
0
        private static SecuritySettings GenerateSecuritySettings()
        {
            SecuritySettings settings = new SecuritySettings();

            AdRolesProviderData providerData = new AdRolesProviderData("AdRolesProviderName", "LDAP", "entlibbldwchr:389", "CN=EntLibUsers,O=EntLib,C=US");
            providerData.AccountName = "CN";
            providerData.TypeName = typeof(AdRolesProvider).AssemblyQualifiedName;
            settings.RolesProviders.Add( providerData );

            return settings;
        }
		private DictionaryConfigurationSource GetConfigurationSource()
		{
			DictionaryConfigurationSource sections = new DictionaryConfigurationSource();

			SecuritySettings securityConfig = new SecuritySettings();
			securityConfig.DefaultAuthorizationProviderName = "provider1";
			securityConfig.AuthorizationProviders.Add(new MockAuthorizationProviderData("provider1"));
			securityConfig.AuthorizationProviders.Add(new MockAuthorizationProvider2Data("provider2"));
			sections.Add(SecuritySettings.SectionName, securityConfig);

			return sections;
		}
		private DictionaryConfigurationSource GetConfigurationSource()
		{
			DictionaryConfigurationSource sections = new DictionaryConfigurationSource();

			SecuritySettings securityConfig = new SecuritySettings();
			securityConfig.DefaultSecurityCacheProviderName = "provider1";
			securityConfig.SecurityCacheProviders.Add(new MockSecurityCacheProviderData("provider1", typeof(MockSecurityCacheProvider)));
			sections.Add(SecuritySettings.SectionName, securityConfig);

			InstrumentationConfigurationSection instrumentationConfig = new InstrumentationConfigurationSection(true, true, true);
			sections.Add(InstrumentationConfigurationSection.SectionName, instrumentationConfig);

			return sections;
		}
        protected override void Arrange()
        {
            updatableConfigurationSource = new ConfigurationSourceUpdatable();

            ruleProvider = new AuthorizationRuleProviderData();
            ruleProvider.Name = "ruleProvider";

            settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(ruleProvider);

            updatableConfigurationSource.Add(SecuritySettings.SectionName, settings);

            container = new UnityContainer();
            containerConfigurator = new UnityContainerConfigurator(container);
            EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource);
        }
        public void CanBuildCustomSecurityCacheProviderFromGivenConfiguration()
        {
            CustomSecurityCacheProviderData customData
                = new CustomSecurityCacheProviderData("custom", typeof(MockCustomSecurityCacheProvider));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            SecuritySettings settings = new SecuritySettings();
            settings.SecurityCacheProviders.Add(customData);
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            configurationSource.Add(SecuritySettings.SectionName, settings);

            ISecurityCacheProvider custom
                = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance<ISecurityCacheProvider>("custom");

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomSecurityCacheProvider), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomSecurityCacheProvider)custom).customValue);
        }
        public void CanBuildCustomAuthorizationProviderFromGivenConfiguration()
        {
            CustomAuthorizationProviderData customData
                = new CustomAuthorizationProviderData("custom", typeof(MockCustomAuthorizationProvider));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            SecuritySettings settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(customData);
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            configurationSource.Add(SecuritySettings.SectionName, settings);

            IAuthorizationProvider custom
                = EnterpriseLibraryFactory.BuildUp<IAuthorizationProvider>("custom", configurationSource);

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomAuthorizationProvider), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomAuthorizationProvider)custom).customValue);
        }
        protected override void Arrange()
        {
            base.Arrange();

            ConfigurationSourceBuilder builder = new ConfigurationSourceBuilder();
            builder.ConfigureSecurity()
                .AuthorizeUsingCustomProviderNamed("custom authz", typeof(IAuthorizationProvider))
                .AuthorizeUsingRuleProviderNamed("ruleProvider")
                .SpecifyRule("rule1", "true")
                .SpecifyRule("rule2", "false")
                .CacheSecurityInCacheStoreNamed("cache Storage").WithOptions.UseSharedCacheManager("cache");

            DictionaryConfigurationSource source = new DictionaryConfigurationSource();
            builder.UpdateConfigurationWithReplace(source);


            securitySettings = (SecuritySettings)source.GetSection(SecuritySettings.SectionName);
        }
        public void CanBuildCustomSecurityCacheProviderFromSavedConfiguration()
        {
            CustomSecurityCacheProviderData customData
                = new CustomSecurityCacheProviderData("custom", typeof(MockCustomSecurityCacheProvider));
            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            SecuritySettings settings = new SecuritySettings();
            settings.SecurityCacheProviders.Add(customData);

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>(1);
            sections[SecuritySettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            ISecurityCacheProvider custom
                = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance<ISecurityCacheProvider>("custom");

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomSecurityCacheProvider), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomSecurityCacheProvider)custom).customValue);
        }
        public void Setup()
        {
            SecuritySettings data = new SecuritySettings();
            data.DefaultAuthenticationProviderName = "provider2";

            CustomAuthenticationProviderData provider1Data =
                new CustomAuthenticationProviderData();
            provider1Data.Name = "provider1";
            provider1Data.TypeName = typeof(MockAuthenticationProvider).AssemblyQualifiedName;
            data.AuthenticationProviders.Add(provider1Data);

            CustomAuthenticationProviderData provider2Data =
                new CustomAuthenticationProviderData();
            provider2Data.Name = "provider2";
            provider2Data.TypeName = typeof(Mock2AuthenticationProvider).AssemblyQualifiedName;
            // provider2Data.Default = true;
            data.AuthenticationProviders.Add(provider2Data);

            ConfigurationDictionary dictionary = new ConfigurationDictionary();
            dictionary[SecuritySettings.SectionName] = data;
            ConfigurationContext context = ConfigurationManager.CreateContext(dictionary);
            this.factory = new AuthenticationProviderFactory(context);
        }
        public void Setup()
        {
            SecuritySettings settings = new SecuritySettings();
            settings.DefaultProfileProviderName = "provider2";

            CustomProfileProviderData provider1Data =
                new CustomProfileProviderData();
            provider1Data.Name = "provider1";
            provider1Data.TypeName = typeof(MockProfileProvider).AssemblyQualifiedName;
            settings.ProfileProviders.Add(provider1Data);

            CustomProfileProviderData provider2Data =
                new CustomProfileProviderData();
            // provider2Data.Default = true;
            provider2Data.Name = "provider2";
            provider2Data.TypeName = typeof(Mock2ProfileProvider).AssemblyQualifiedName;
            settings.ProfileProviders.Add(provider2Data);

            ConfigurationDictionary dictionary = new ConfigurationDictionary();
            dictionary[SecuritySettings.SectionName] = settings;
            ConfigurationContext context = ConfigurationManager.CreateContext(dictionary);
            this.factory = new ProfileProviderFactory(context);
        }
        public void Setup()
        {
            CustomAuthorizationProviderData customAuthZProvider = new CustomAuthorizationProviderData();
            customAuthZProvider.Name = "Custom authZ Provider";
            customAuthZProvider.Type = typeof(FaultyType);

            settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(customAuthZProvider);
        }
        public void Setup()
        {
            CustomAuthorizationProviderData ruleProvider = new CustomAuthorizationProviderData();
            ruleProvider.Name = "Custom Auth Provider";
            ruleProvider.Type = typeof(MockCustomAuthorizationProvider);

            SecuritySettings settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(ruleProvider);

            registrations = settings.GetRegistrations(null);
        }
        public void Setup()
        {
            CustomSecurityCacheProviderData securityCacheProviderData = new CustomSecurityCacheProviderData();
            securityCacheProviderData.Name = "Custom Cache Provider";
            securityCacheProviderData.Type = typeof(MockCustomSecurityCacheProvider);

            SecuritySettings settings = new SecuritySettings();
            settings.SecurityCacheProviders.Add(securityCacheProviderData);

            registrations = settings.GetRegistrations(null);
        }
        public void Setup()
        {
            CustomSecurityCacheProviderData securityCacheProviderData = new CustomSecurityCacheProviderData();
            securityCacheProviderData.Name = "Custom Cache Provider";
            securityCacheProviderData.Type = typeof(FaultyType);

            settings = new SecuritySettings();
            settings.SecurityCacheProviders.Add(securityCacheProviderData);
        }
Exemplo n.º 21
0
        private static SecuritySettings GenerateSecuritySettings()
        {
            SecuritySettings settings = new SecuritySettings();
            settings.DefaultSecurityCacheProviderName = "Security Cache Provider1";
            settings.SecurityCacheProviders.Add( new CachingStoreProviderData("Security Cache Provider1",5, 120,"InMemoryPersistence"));

            return settings;
        }
 public ConfigureSecuritySettingsBuilder(IConfigurationSourceBuilder configurationSuorceBuilder)
 {
     securitySettings = new SecuritySettings();
     configurationSuorceBuilder.AddSection(SecuritySettings.SectionName, securitySettings);
 }
 public void Setup()
 {
     SecuritySettings settings = new SecuritySettings();
     registrations = settings.GetRegistrations(null);
 }