Пример #1
0
 /// <summary>Checks the validity of the specified access rights.</summary>
 /// <param name="value">The access rights to check.</param>
 protected override void ValidateRights(IEnumerable <AccessRights> value)
 {
     base.ValidateRights(value);
     if (!SharedAccessAuthorizationRule.IsValidCombinationOfRights(value))
     {
         throw new ArgumentException("Manage permission should also include Send and Listen.");
     }
 }
Пример #2
0
        /// <summary>Determines whether the specified object is equal to the current object.</summary>
        /// <param name="obj">The object to compare with the current object.</param>
        /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
        public override bool Equals(object obj)
        {
            if (!base.Equals(obj))
            {
                return(false);
            }
            SharedAccessAuthorizationRule sharedAccessAuthorizationRule = (SharedAccessAuthorizationRule)obj;

            if (!string.Equals(this.KeyName, sharedAccessAuthorizationRule.KeyName, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.PrimaryKey, sharedAccessAuthorizationRule.PrimaryKey, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            return(string.Equals(this.SecondaryKey, sharedAccessAuthorizationRule.SecondaryKey, StringComparison.OrdinalIgnoreCase));
        }
        /// <summary>Adds the specified <see cref="T:Microsoft.ServiceBus.Messaging.AuthorizationRule" /> into the collection.</summary>
        /// <param name="item">The <see cref="T:Microsoft.ServiceBus.Messaging.AuthorizationRule" /> to be added.</param>
        public void Add(Mossharbor.AzureWorkArounds.ServiceBus.AuthorizationRule item)
        {
            SharedAccessAuthorizationRule sharedAccessAuthorizationRule;

            if (item is SharedAccessAuthorizationRule)
            {
                SharedAccessAuthorizationRule sharedAccessAuthorizationRule1 = item as SharedAccessAuthorizationRule;
                if (this.nameToSharedAccessAuthorizationRuleMap.TryGetValue(sharedAccessAuthorizationRule1.KeyName, out sharedAccessAuthorizationRule))
                {
                    this.nameToSharedAccessAuthorizationRuleMap.Remove(sharedAccessAuthorizationRule1.KeyName);
                    this.innerCollection.Remove(sharedAccessAuthorizationRule);
                }
                this.nameToSharedAccessAuthorizationRuleMap.Add(sharedAccessAuthorizationRule1.KeyName, sharedAccessAuthorizationRule1);
            }
            this.innerCollection.Add(item);
        }
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            IEnumerable <XElement> authRules = RuleDescription.SimpleStreamAxis(reader, new string[] { "AuthorizationRule" }).ToArray();

            foreach (var authRule in authRules)
            {
                var actionTypeAttrib = authRule?.Attributes()?.FirstOrDefault(p => p.Name.LocalName.Equals("type"));
                switch (actionTypeAttrib?.Value?.ToLower())
                {
                case "sharedaccessauthorizationrule":
                    //var expression = authRule?.Elements(XName.Get("{http://schemas.microsoft.com/netservices/2010/10/servicebus/connect}AuthorizationRule"));
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(SharedAccessAuthorizationRule));
                    var stringReader = new StringReader(authRule.ToString());
                    SharedAccessAuthorizationRule rule = (SharedAccessAuthorizationRule)xs.Deserialize(stringReader);
                    this.Add(rule);
                    break;
                }
            }
        }
Пример #5
0
 /// <summary>Initializes a new instance of the <see cref="T:Microsoft.ServiceBus.Messaging.SharedAccessAuthorizationRule" /> class.</summary>
 /// <param name="keyName">The authorization rule key name.</param>
 /// <param name="rights">The list of rights.</param>
 public SharedAccessAuthorizationRule(string keyName, IEnumerable <AccessRights> rights) : this(keyName, SharedAccessAuthorizationRule.GenerateRandomKey(), SharedAccessAuthorizationRule.GenerateRandomKey(), rights)
 {
 }
 /// <summary>Gets the rule associated with the specified key.</summary>
 /// <param name="keyName">The name of the key.</param>
 /// <param name="rule">The rule associated with the specified key.</param>
 /// <returns>true if the
 /// <see cref="T:Microsoft.ServiceBus.Messaging.AuthorizationRules" /> contains an element with the specified key; otherwise, false.</returns>
 public bool TryGetSharedAccessAuthorizationRule(string keyName, out SharedAccessAuthorizationRule rule)
 {
     return(this.nameToSharedAccessAuthorizationRuleMap.TryGetValue(keyName, out rule));
 }