• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Configuration.MachineKeySection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.Configuration.MachineKeySection的典型用法代码示例。如果您正苦于以下问题:C# MachineKeySection类的具体用法?C# MachineKeySection怎么用?C# MachineKeySection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MachineKeySection类属于System.Web.Configuration命名空间,在下文中一共展示了MachineKeySection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MachineKeyMasterKeyProvider

 // the only required parameter is 'machineKeySection'; other parameters are just used for unit testing
 internal MachineKeyMasterKeyProvider(MachineKeySection machineKeySection, string applicationId = null, string applicationName = null, CryptographicKey autogenKeys = null, KeyDerivationFunction keyDerivationFunction = null) {
     _machineKeySection = machineKeySection;
     _applicationId = applicationId;
     _applicationName = applicationName;
     _autogenKeys = autogenKeys;
     _keyDerivationFunction = keyDerivationFunction;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:8,代码来源:MachineKeyMasterKeyProvider.cs


示例2: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null) throw new ArgumentException("config");
            if (String.IsNullOrEmpty(name)) name = DEFAULT_PROVIDER_NAME;
            
            base.Initialize(name, config);

            applicationName = ConfigurationHelper.GetConfigStringValueOrDefault(config, ConfigurationHelper.CONFIG_APPLICATION_NAME_FIELD, System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            description = ConfigurationHelper.GetConfigStringValueOrDefault(config, ConfigurationHelper.CONFIG_DESCRIPTION_FIELD, "Couch DB Membership Provider");
            enablePasswordReset = ConfigurationHelper.GetConfigBoolValueOrDefault(config, ConfigurationHelper.CONFIG_ENABLE_PASSWORD_RESET, false);
            enablePasswordRetrieval = false;
            maxInvalidPasswordAttempts = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_MAX_INVALID_PASSWORD_ATTEMPTS, 5);
            minRequiredNonAlphanumericCharacters = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_MIN_REQUIRED_NON_ALPHANUMERIC_CHARACTERS, 0);
            minRequiredPasswordLength = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_MIN_REQUIRED_PASSWORD_LENGTH, 8);
            passwordAttemptWindow = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_PASSWORD_ATTEMPT_WINDOW, 10);
            passwordFormat = MembershipPasswordFormat.Hashed;
            passwordStrengthRegularExpression = ConfigurationHelper.GetConfigStringValueOrDefault(config, ConfigurationHelper.CONFIG_PASSWORD_STRENGTH_REGULAR_EXPRESSION, String.Empty);
            requiresQuestionAndAnswer = ConfigurationHelper.GetConfigBoolValueOrDefault(config, ConfigurationHelper.CONFIG_REQUIRES_QUESTION_AND_ANSWER, false);
            requiresUniqueEmail = true;
            providerName = name;

            couchDbServerName = ConfigurationHelper.MembershipCouchDbServerName;
            couchDbServerPort = ConfigurationHelper.MembershipCouchDbServerPort;
            couchDbDatabaseName = ConfigurationHelper.MembershipCouchDbDatabaseName;

            if (String.IsNullOrEmpty(couchDbDatabaseName))
                throw new ProviderException(Strings.CouchDbConfigurationDatabaseNameMissing);

            machineKeySection = (MachineKeySection)WebConfigurationManager.GetWebApplicationSection("system.web/machineKey");
            if(machineKeySection == null)
                throw new ProviderException(Strings.HashedPasswordsRequireMachineKey);

            if (machineKeySection.ValidationKey.ToLower().Contains("Autogenerate".ToLower()))
                throw new ProviderException(Strings.HashedPasswordsRequireMachineKey);
        }
开发者ID:amezcua,项目名称:CouchDB.NET,代码行数:35,代码来源:CouchDbMembershipProvider.cs


示例3: UniMembershipProvider

 public UniMembershipProvider()
 {
     pApplicationName = "unicloud";
     pName = "UniMembershipProvider";
     Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
     machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");
 }
开发者ID:unicloud,项目名称:AFRP,代码行数:7,代码来源:UniMembershipProvider.cs


示例4: Encrypt_RoundTrip

		public void Encrypt_RoundTrip (MachineKeySection section)
		{
			byte [] data = new byte [14];
			byte [] encdata = MachineKeySectionUtils.Encrypt (section, data);
			byte [] decdata = MachineKeySectionUtils.Decrypt (section, encdata);
			Assert.AreEqual (data, decdata, "roundtrip");

			// changing length (missing first byte)
			byte [] cut = new byte [encdata.Length - 1];
			Array.Copy (encdata, 1, cut, 0, cut.Length);
			Assert.IsNull (MachineKeySectionUtils.Decrypt (section, cut), "bad length");

			// changing last byte (padding)
			byte be = encdata [encdata.Length - 1];
			encdata [encdata.Length - 1] = ChangeByte (be);
			byte[] result = MachineKeySectionUtils.Decrypt (section, encdata);
			// this will return null if a bad padding is detected - OTOH since we're using a random key and we
			// encrypt a random IV it's possible the decrypted stuff will randomly have a "valid" padding (there's
			// only so much possible values and the bots runs those tests pretty often and give false positive)
			// To avoid this we fallback to ensure the data is invalid (if should be empty)
			int total = 0;
			if (result != null) {
				for (int i=0; i < result.Length; i++)
					total += result [i];
			}
			Assert.IsTrue (result == null || total != 0, "bad padding");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:27,代码来源:MachineKeySectionUtilsTest.cs


示例5: Decryption_RC2

		public void Decryption_RC2 ()
		{
			MachineKeySection section = new MachineKeySection ();
			Assert.AreEqual ("Auto", section.Decryption, "before");

			section.Decryption = "alg:RC2";
			Assert.AreEqual ("alg:RC2", section.Decryption, "after");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:MachineKeySectionTest.cs


示例6: AccountManagement

 public AccountManagement()
 {
     // Get encryption and decryption key information from the configuration.
     Configuration cfg =
         WebConfigurationManager.OpenWebConfiguration(
             System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
     machineKey = (MachineKeySection) cfg.GetSection("system.web/machineKey");
     formsConfig = (AuthenticationSection) cfg.GetSection("system.web/authentication");
 }
开发者ID:czechdude,项目名称:Meshop,代码行数:9,代码来源:AccountManagement.cs


示例7: Decryption_InvalidName

		public void Decryption_InvalidName ()
		{
			MachineKeySection section = new MachineKeySection ();
			Assert.AreEqual ("Auto", section.Decryption, "before");

			section.Decryption = "alg:UnexistingType";
			// looks like the problem is found (much) later
			Assert.AreEqual ("alg:UnexistingType", section.Decryption, "Decryption");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:MachineKeySectionTest.cs


示例8: GetMachineKeySection

 protected override MachineKeySection GetMachineKeySection()
 {
     var mk = new MachineKeySection();
       mk.DecryptionKey = "0A5D40CA5C48726556180200D9DBE44A8FE58A8E6A3E8CC153BFC631833BA0FE";
       mk.ValidationKey = "7D30287B722BF7141915476F0609FFD604CBB5243D8574F85BA5B496FA58D3EE49A8CE1E07E958F145967495A56E5B6298082070C0488F7B4FC42EDE9956422E";
       mk.Validation = MachineKeyValidation.SHA1;
       mk.Decryption = "AES";
       return mk;
 }
开发者ID:cedar-technologies,项目名称:CQRS-ES_MembershipProvider,代码行数:9,代码来源:TestHelpers.cs


示例9: GetMachineKey_MachineKeyConfigured_ReturnsMachineKey

        public void GetMachineKey_MachineKeyConfigured_ReturnsMachineKey()
        {
            var config = new MachineKeySection { ValidationKey = MachineKeyValidation };
            var helper = new MachineKeyConfigurationHelper(config);

            var key = helper.GetMachineKey();

            Assert.AreEqual(_expectedMachineKey, key);
        }
开发者ID:modulexcite,项目名称:NWebsec.SessionSecurity,代码行数:9,代码来源:MachineKeyConfigurationHelperTests.cs


示例10: UniMembershipProvider

 public UniMembershipProvider()
 {
     _pApplicationName = "unicloud";
     _pName = "UniMembershipProvider";
     var cfg = WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);
     _machineKey = (MachineKeySection) cfg.GetSection("system.web/machineKey");
     _userRepository = UniContainer.Resolve<IUserRepository>();
     _userRoleRepository = UniContainer.Resolve<IUserRoleRepository>();
 }
开发者ID:unicloud,项目名称:FRP,代码行数:9,代码来源:UniMembershipProvider.cs


示例11: DefaultValues

		public void DefaultValues ()
		{
			MachineKeySection section = new MachineKeySection ();
			Assert.AreEqual (MachineKeyCompatibilityMode.Framework20SP1, section.CompatibilityMode, "CompatibilityMode");
			Assert.AreEqual ("Auto", section.Decryption, "Decryption");
			Assert.AreEqual ("AutoGenerate,IsolateApps", section.DecryptionKey, "DecryptionKey");
			Assert.AreEqual (MachineKeyValidation.HMACSHA256, section.Validation, "Validation");
			Assert.AreEqual ("HMACSHA256", section.ValidationAlgorithm, "ValidationAlgorithm");
			Assert.AreEqual ("AutoGenerate,IsolateApps", section.ValidationKey, "ValidationKey");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:10,代码来源:MachineKeySectionTest.cs


示例12: SecurityExtensions

        /// <summary>
        /// 静态构造方法。
        /// </summary>
        static SecurityExtensions()
        {
            var config = WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);

            MachineKey = (MachineKeySection)config.GetSection("system.web/machineKey");

            if (MachineKey.Decryption == "Auto")
            {
                MachineKey.DecryptionKey = KeyCreator.CreateKey(0x18);
                MachineKey.ValidationKey = KeyCreator.CreateKey(0x40);
            }
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:15,代码来源:SecurityExtensions.cs


示例13: AspNetCryptoServiceProvider

        // This constructor is used only for testing purposes and by the singleton provider
        // and should not otherwise be called during ASP.NET request processing.
        internal AspNetCryptoServiceProvider(MachineKeySection machineKeySection = null, ICryptoAlgorithmFactory cryptoAlgorithmFactory = null, IMasterKeyProvider masterKeyProvider = null, IDataProtectorFactory dataProtectorFactory = null, KeyDerivationFunction keyDerivationFunction = null) {
            _machineKeySection = machineKeySection;
            _cryptoAlgorithmFactory = cryptoAlgorithmFactory;
            _masterKeyProvider = masterKeyProvider;
            _dataProtectorFactory = dataProtectorFactory;
            _keyDerivationFunction = keyDerivationFunction;

            // This CryptoServiceProvider is active if specified as such in the <system.web/machineKey> section
            IsDefaultProvider = (machineKeySection != null && machineKeySection.CompatibilityMode >= MachineKeyCompatibilityMode.Framework45);

            // The DataProtectorCryptoService is active if specified as such in config
            _isDataProtectorEnabled = (machineKeySection != null && !String.IsNullOrWhiteSpace(machineKeySection.DataProtectorType));
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:AspNetCryptoServiceProvider.cs


示例14: NullableStringProperties

		// It test all existing (as of r61933) configuration
		// sections that use PropertyHelper.NonEmptyStringValidator.
		public void NullableStringProperties ()
		{
			new AnonymousIdentificationSection ().CookieName = null;
			new AnonymousIdentificationSection ().CookiePath = null;
			new AssemblyInfo (null);
			new BufferModeSettings (null, 0x10000, 0x1000, 10,
			TimeSpan.FromMinutes (1),
			TimeSpan.FromSeconds (30), 10);
			new BuildProvider (null, null);
			new ClientTarget (null, null);
			new CodeSubDirectory (null);
			new EventMappingSettings (null, null);
			new ExpressionBuilder (null, null);
			FormsAuthenticationConfiguration fac =
			new FormsAuthenticationConfiguration ();
			// I don't like this test though.
			fac.DefaultUrl = null;
			fac.LoginUrl = null;
			fac.Name = null;
			fac.Path = null;
			new HttpHandlerAction (null, null, null);
			new HttpModuleAction (null, null);
			MachineKeySection mks = new MachineKeySection ();
			// algorithms are limited
			// mks.Decryption = null;
			mks.DecryptionKey = null;
			mks.ValidationKey = null;
			new MembershipSection ().DefaultProvider = null;
			new NamespaceInfo (null);
			new OutputCacheProfile (null);
			new ProfileSettings (null);
			RoleManagerSection rms = new RoleManagerSection ();
			rms.CookieName = null;
			rms.CookiePath = null;
			rms.DefaultProvider = null;
			new RuleSettings (null, null, null);
			new SqlCacheDependencyDatabase (null, null);
			new TagMapInfo (null, null);
			new TagPrefixInfo (null, null, null, null, null);
			new TransformerInfo (null, null);
			new TrustLevel (null, null);
			new TrustSection ().Level = null;
			new UrlMapping (null, null);
			// WebControlsSection.ClientScriptsLocation is not settable
			new WebPartsPersonalization ().DefaultProvider = null;
		}
开发者ID:nobled,项目名称:mono,代码行数:48,代码来源:NullableStringValidatorTest.cs


示例15: Encrypt_RoundTrip

		public void Encrypt_RoundTrip (MachineKeySection section)
		{
			byte [] data = new byte [14];
			byte [] encdata = MachineKeySectionUtils.Encrypt (section, data);
			byte [] decdata = MachineKeySectionUtils.Decrypt (section, encdata);
			Assert.AreEqual (data, decdata, "roundtrip");

			// changing length (missing first byte)
			byte [] cut = new byte [encdata.Length - 1];
			Array.Copy (encdata, 1, cut, 0, cut.Length);
			Assert.IsNull (MachineKeySectionUtils.Decrypt (section, cut), "bad length");

			// changing last byte (padding)
			byte be = encdata [encdata.Length - 1];
			encdata [encdata.Length - 1] = ChangeByte (be);
			Assert.IsNull (MachineKeySectionUtils.Decrypt (section, encdata), "bad padding");
		}
开发者ID:runefs,项目名称:Marvin,代码行数:17,代码来源:MachineKeySectionUtilsTest.cs


示例16: Validation_RoundTrip_Custom_RIPEMD160

		public void Validation_RoundTrip_Custom_RIPEMD160 ()
		{
			MachineKeySection section = new MachineKeySection ();
			section.ValidationAlgorithm = "alg:HMACRIPEMD160";
			Validation_RoundTrip (section);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:6,代码来源:MachineKeySectionUtilsTest.cs


示例17: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "ELMemebershipProvider";

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "ELinq Membership provider");
            }

            base.Initialize(name, config);

            maxInvalidPasswordAttempts = config.Get<int>( "maxInvalidPasswordAttempts",5);
            passwordAttemptWindow = config.Get<int>("passwordAttemptWindow",10);
            minRequiredNonAlphanumericCharacters = config.Get<int>("minRequiredNonAlphanumericCharacters",1);
            minRequiredPasswordLength = config.Get<int>("minRequiredPasswordLength",7);
            passwordStrengthRegularExpression =config.Get<string>("passwordStrengthRegularExpression", "");
            enablePasswordReset =config.Get<bool>("enablePasswordReset",true);
            enablePasswordRetrieval = config.Get<bool>("enablePasswordRetrieval",true);
            requiresQuestionAndAnswer = config.Get<bool>("requiresQuestionAndAnswer",false);
            requiresUniqueEmail =config.Get<bool>("requiresUniqueEmail",true);

            switch (config.Get<string>("passwordFormat", "Clear"))
            {
                case "Hashed":
                    passwordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    passwordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    passwordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new ProviderException("Password format not supported.");
            }

            //Encryption skipped
            var cfg =
                            WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            _machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (_machineKey.ValidationKey.Contains("AutoGenerate"))
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                    throw new ProviderException("Hashed or Encrypted passwords are not supported with auto-generated keys.");

            var connectionStringName = config["connectionStringName"];

            UnitOfWork.Configure(connectionStringName);

            ApplicationName = config["applicationName"];
            if (ApplicationName.IsNullOrEmpty())
                ApplicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
            else if(ApplicationName != "/")
            {
                var site = UnitOfWork.Current.CreateRepository<Site>().FirstOrDefault(p => p.Id == ApplicationName && p.Status == Enums.SiteStatus.Enable);
                if(site == null)
                    throw new ProviderException("ApplicationName not exists.");
            }
        }
开发者ID:netcasewqs,项目名称:elinq-membership,代码行数:64,代码来源:ELMembershipProvider.cs


示例18: Validation_RoundTrip_MD5

		public void Validation_RoundTrip_MD5 ()
		{
			MachineKeySection section = new MachineKeySection ();
			section.Validation = MachineKeyValidation.MD5;
			Validation_RoundTrip (section);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:6,代码来源:MachineKeySectionUtilsTest.cs


示例19: Validation_RoundTrip_HMACSHA512

		public void Validation_RoundTrip_HMACSHA512 ()
		{
			MachineKeySection section = new MachineKeySection ();
			section.Validation = MachineKeyValidation.HMACSHA512;
			Validation_RoundTrip (section);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:6,代码来源:MachineKeySectionUtilsTest.cs


示例20: EncryptSign_RoundTrip_HMACSHA384

		public void EncryptSign_RoundTrip_HMACSHA384 ()
		{
			MachineKeySection section = new MachineKeySection ();
			section.Validation = MachineKeyValidation.HMACSHA384;
			EncryptSign_RoundTrip (section);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:6,代码来源:MachineKeySectionUtilsTest.cs



注:本文中的System.Web.Configuration.MachineKeySection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Configuration.RegexWorker类代码示例发布时间:2022-05-26
下一篇:
C# Compilation.ExpressionBuilderContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap