internal AuthorizationRule()
 {
     this._Action = AuthorizationRuleAction.Allow;
     this._ActionString = AuthorizationRuleAction.Allow.ToString();
     this._ElementName = "allow";
     this._delimiters = new char[] { ',' };
 }
Пример #2
0
		public AuthorizationRule (AuthorizationRuleAction action)
		{
			this.action = action;
			base[rolesProp] = new CommaDelimitedStringCollection ();
			base[usersProp] = new CommaDelimitedStringCollection ();
			base[verbsProp] = new CommaDelimitedStringCollection ();
		}
Пример #3
0
 /// <summary>
 /// Initialize is called after the filter is created but before running the action
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="action">Whether the match was allowed or denied</param>
 public void Initialize(string parameters, AuthorizationRuleAction action)
 {
     Parameters = parameters;
     Action     = action;
 }
	// Constructors
	public AuthorizationRule(AuthorizationRuleAction action) {}
Пример #5
0
 /// <summary>
 /// Método responsável por pesquisar a regra apartir dos dados informados
 /// </summary>
 /// <param name="pathId">Número de identificação do Path</param>
 /// <param name="action">Ação</param>
 /// <param name="type">Tipo</param>
 /// <returns>AuthorizationRule</returns>
 public static AuthorizationRule FindRule(Guid pathId, AuthorizationRuleAction action, AuthorizationRuleType type)
 {
     return(Provider.FindRule(pathId, action, type));
 }
 public override AuthorizationRule FindRule(Guid pathId, AuthorizationRuleAction action, AuthorizationRuleType type)
 {
     throw new NotImplementedException();
 }
Пример #7
0
 /// <summary>
 /// Pesquisa um regra.
 /// </summary>
 /// <param name="pathId"></param>
 /// <param name="action"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public abstract AuthorizationRule FindRule(Guid pathId, AuthorizationRuleAction action, AuthorizationRuleType type);
Пример #8
0
 public AuthorizationRule(AuthorizationRuleAction action)
 {
 }
Пример #9
0
        public static void Main()
        {
            // <Snippet1>
            // Get the Web application configuration.
            System.Configuration.Configuration configuration =
                WebConfigurationManager.OpenWebConfiguration(
                    "/aspnetTest");
            // </Snippet1>

            // <Snippet2>
            // Get the section.
            AuthorizationSection authorizationSection =
                (AuthorizationSection)configuration.GetSection(
                    "system.web/authorization");
            // </Snippet2>

            // <Snippet3>
            // Get the authorization rule collection.
            AuthorizationRuleCollection authorizationRuleCollection =
                authorizationSection.Rules;
            // </Snippet3>

            // <Snippet4>
            // Create an authorization rule object.
            AuthorizationRuleAction action =
                AuthorizationRuleAction.Deny;
            AuthorizationRule authorizationRule =
                new System.Web.Configuration.AuthorizationRule(action);
            // </Snippet4>


            // <Snippet5>
            // Create a new 'AuthorizationSection' object.
            AuthorizationSection newauthorizationSection =
                new System.Web.Configuration.AuthorizationSection();

            // </Snippet5>


            // <Snippet6>
            // Using the AuthorizationRuleCollection Add method.

            // Set the action property.
            authorizationRule.Action =
                AuthorizationRuleAction.Allow;
            // Define the new rule to add to the collection.
            authorizationRule.Users.Add("userName");
            authorizationRule.Roles.Add("admin");
            authorizationRule.Verbs.Add("POST");

            // Add the new rule to the collection.
            authorizationSection.Rules.Add(authorizationRule);
            // </Snippet6>

            // <Snippet7>
            // Using the AuthorizationRuleCollection Clear method.
            authorizationSection.Rules.Clear();
            // </Snippet7>

            // <Snippet8>
            // Using the AuthorizationRuleCollection RemoveAt method.
            authorizationRuleCollection.RemoveAt(0);
            // </Snippet8>

            // <Snippet9>
            // Get the rule collection index.
            System.Int32 ruleIndex =
                authorizationSection.Rules.IndexOf(authorizationRule);
            // </Snippet9>

            // <Snippet10>
            // Remove the rule from the collection.
            authorizationSection.Rules.Remove(authorizationRule);

            // </Snippet10>

            // <Snippet11>
            // Using the AuthorizationRuleCollection Set method.

            // Define the rule to add to the collection.

            // Define the collection index.
            System.Int32 rIndex = 0;

            // Set the rule in the collection.
            authorizationRuleCollection.Set(rIndex,
                                            authorizationRule);
            // </Snippet11>


            // <Snippet12>
            // Show how to access the Rules elements.
            StringBuilder rules = new StringBuilder();

            for (System.Int32 i = 0;
                 i < authorizationSection.Rules.Count - 1; i++)
            {
                rules.Append("Action: " +
                             authorizationSection.Rules[i].Action.ToString());

                // Get the Verbs.
                System.Int32 verbsCount =
                    authorizationSection.Rules[i].Verbs.Count;
                for (System.Int32 v = 0; v < verbsCount; v++)
                {
                    rules.AppendLine(
                        authorizationSection.Rules[i].Verbs[v]);
                }

                // Get the Roles.
                System.Int32 rolesCount =
                    authorizationSection.Rules[i].Roles.Count;
                for (System.Int32 r = 0; r < rolesCount; r++)
                {
                    rules.AppendLine(authorizationSection.Rules[i].Roles[r]);
                }

                // Get the Users.
                System.Int32 usersCount =
                    authorizationSection.Rules[i].Users.Count;
                for (System.Int32 u = 0; u < usersCount; u++)
                {
                    rules.AppendLine(authorizationSection.Rules[i].Users[u]);
                }
            }

            // </Snippet12>

            // <Snippet13>
            // Using the AuthorizationRuleCollection Get method.
            AuthorizationRule authRule =
                authorizationRuleCollection.Get(0);
            // </Snippet13>
        }
Пример #10
0
		protected internal override void Unmerge (ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
		{
			base.Unmerge (sourceElement, parentElement, saveMode);
			this.saveMode = saveMode;

			AuthorizationRule source = sourceElement as AuthorizationRule;
			if (source != null)
				this.action = source.Action;
		}
 public AuthorizationRule(AuthorizationRuleAction action) : this()
 {
     Action = action;
 }
 public AuthorizationRule(AuthorizationRuleAction action) : this() {
     Action = action;
 }
Пример #13
0
 /// <summary>
 /// Initialize is called after the filter is created but before running the action
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="action">Whether the match was allowed or denied</param>
 public void Initialize(string parameters, AuthorizationRuleAction action)
 {
     Parameters = parameters;
     Action = action;
 }
Пример #14
0
 internal XmlAuthorizationRule(AuthorizationRuleAction action)
 {
     Users     = new StringCollection();
     Roles     = new StringCollection();
     HttpVerbs = new StringCollection();
 }