Пример #1
0
		// 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;
		}
        private static void Validate(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("forms");
            }
            FormsAuthenticationConfiguration configuration = (FormsAuthenticationConfiguration)value;

            if (System.Web.Util.StringUtil.StringStartsWith(configuration.LoginUrl, @"\\") || ((configuration.LoginUrl.Length > 1) && (configuration.LoginUrl[1] == ':')))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Auth_bad_url"), configuration.ElementInformation.Properties["loginUrl"].Source, configuration.ElementInformation.Properties["loginUrl"].LineNumber);
            }
            if (System.Web.Util.StringUtil.StringStartsWith(configuration.DefaultUrl, @"\\") || ((configuration.DefaultUrl.Length > 1) && (configuration.DefaultUrl[1] == ':')))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Auth_bad_url"), configuration.ElementInformation.Properties["defaultUrl"].Source, configuration.ElementInformation.Properties["defaultUrl"].LineNumber);
            }
        }
Пример #3
0
 private static void Initialize()
 {
     if (!_initialized)
         lock (_syncObj)
             if (!_initialized)
             {
                 try
                 {
                     _forms = ((AuthenticationSection)
                         WebConfigurationManager.GetSection("system.web/authentication")).Forms;
                 }
                 catch (Exception ex)
                 {
                     _initException = ex;
                 }
                 _initialized = true;
             }
     if (_initException != null)
         throw _initException;
 }
Пример #4
0
 private string TicketCompatibilityMode(FormsAuthenticationConfiguration formsSection)
 {
     #if NET35
     return "n/a";
     #else
     return formsSection.TicketCompatibilityMode.ToString();
     #endif
 }