| | 1 | | // Copyright (c) Microsoft. All rights reserved. |
| | 2 | | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.ServiceBus.Management |
| | 5 | | { |
| | 6 | | using System; |
| | 7 | | using System.Collections.Generic; |
| | 8 | | using System.Xml.Linq; |
| | 9 | |
|
| | 10 | | public abstract class AuthorizationRule : IEquatable<AuthorizationRule> |
| | 11 | | { |
| 0 | 12 | | internal AuthorizationRule() |
| | 13 | | { |
| 0 | 14 | | } |
| | 15 | |
|
| | 16 | | /// <summary>Gets or sets the claim type.</summary> |
| | 17 | | /// <value>The claim type.</value> |
| | 18 | | public abstract string ClaimType { get; } |
| | 19 | |
|
| | 20 | | /// <summary>Gets or sets the list of rights.</summary> |
| | 21 | | /// <value>The list of rights.</value> |
| | 22 | | public abstract List<AccessRights> Rights { get; set; } |
| | 23 | |
|
| | 24 | | /// <summary>Gets or sets the authorization rule key name.</summary> |
| | 25 | | /// <value>The authorization rule key name.</value> |
| | 26 | | public abstract string KeyName { get; set; } |
| | 27 | |
|
| | 28 | | /// <summary>Gets or sets the date and time when the authorization rule was created.</summary> |
| | 29 | | /// <value>The date and time when the authorization rule was created.</value> |
| 0 | 30 | | public DateTime CreatedTime { get; internal set; } |
| | 31 | |
|
| | 32 | | /// <summary>Gets or sets the date and time when the authorization rule was modified.</summary> |
| | 33 | | /// <value>The date and time when the authorization rule was modified.</value> |
| 0 | 34 | | public DateTime ModifiedTime { get; internal set; } |
| | 35 | |
|
| | 36 | | /// <summary>Gets or sets the claim value which is either ‘Send’, ‘Listen’, or ‘Manage’.</summary> |
| | 37 | | /// <value>The claim value which is either ‘Send’, ‘Listen’, or ‘Manage’.</value> |
| | 38 | | internal abstract string ClaimValue { get; } |
| | 39 | |
|
| | 40 | | public abstract bool Equals(AuthorizationRule comparand); |
| | 41 | |
|
| | 42 | | internal static AuthorizationRule ParseFromXElement(XElement xElement) |
| | 43 | | { |
| 0 | 44 | | var attribute = xElement.Attribute(XName.Get("type", ManagementClientConstants.XmlSchemaInstanceNamespace)); |
| 0 | 45 | | if (attribute == null) |
| | 46 | | { |
| 0 | 47 | | return null; |
| | 48 | | } |
| | 49 | |
|
| 0 | 50 | | switch (attribute.Value) |
| | 51 | | { |
| | 52 | | case "SharedAccessAuthorizationRule": |
| 0 | 53 | | return SharedAccessAuthorizationRule.ParseFromXElement(xElement); |
| | 54 | | default: |
| 0 | 55 | | return null; |
| | 56 | | } |
| | 57 | | } |
| | 58 | |
|
| | 59 | | internal abstract XElement Serialize(); |
| | 60 | | } |
| | 61 | | } |