| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Data; |
| | 7 | | using System.Xml.Linq; |
| | 8 | |
|
| | 9 | | namespace Azure.Messaging.ServiceBus.Management |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Specifies the authorization rule. |
| | 13 | | /// </summary> |
| | 14 | | public abstract class AuthorizationRule : IEquatable<AuthorizationRule> |
| | 15 | | { |
| 72 | 16 | | internal AuthorizationRule() |
| | 17 | | { |
| 72 | 18 | | } |
| | 19 | |
|
| | 20 | | internal abstract AuthorizationRule Clone(); |
| | 21 | |
|
| | 22 | | /// <summary>Gets or sets the claim type.</summary> |
| | 23 | | /// <value>The claim type.</value> |
| | 24 | | public abstract string ClaimType { get; } |
| | 25 | |
|
| | 26 | | /// <summary>Gets or sets the claim value which is either ‘Send’, ‘Listen’, or ‘Manage’.</summary> |
| | 27 | | /// <value>The claim value which is either ‘Send’, ‘Listen’, or ‘Manage’.</value> |
| | 28 | | internal abstract string ClaimValue { get; } |
| | 29 | |
|
| | 30 | | /// <summary>Gets or sets the list of rights.</summary> |
| | 31 | | /// <value>The list of rights.</value> |
| | 32 | | [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Ju |
| | 33 | | public abstract List<AccessRights> Rights { get; set; } |
| | 34 | |
|
| | 35 | | /// <summary>Gets or sets the authorization rule key name.</summary> |
| | 36 | | /// <value>The authorization rule key name.</value> |
| | 37 | | public abstract string KeyName { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary>Gets or sets the date and time when the authorization rule was created.</summary> |
| | 40 | | /// <value>The date and time when the authorization rule was created.</value> |
| 0 | 41 | | public DateTimeOffset CreatedTime { get; internal set; } |
| | 42 | |
|
| | 43 | | /// <summary>Gets or sets the date and time when the authorization rule was modified.</summary> |
| | 44 | | /// <value>The date and time when the authorization rule was modified.</value> |
| 0 | 45 | | public DateTimeOffset ModifiedTime { get; internal set; } |
| | 46 | |
|
| | 47 | | /// <summary>Determines whether the specified object is equal to the current object.</summary> |
| | 48 | | public abstract bool Equals(AuthorizationRule other); |
| | 49 | |
|
| | 50 | | internal static AuthorizationRule ParseFromXElement(XElement xElement) |
| | 51 | | { |
| 40 | 52 | | XAttribute attribute = xElement.Attribute(XName.Get("type", ManagementClientConstants.XmlSchemaInstanceNames |
| 40 | 53 | | if (attribute == null) |
| | 54 | | { |
| 0 | 55 | | return null; |
| | 56 | | } |
| | 57 | |
|
| 40 | 58 | | switch (attribute.Value) |
| | 59 | | { |
| | 60 | | case "SharedAccessAuthorizationRule": |
| 40 | 61 | | return SharedAccessAuthorizationRule.ParseFromXElement(xElement); |
| | 62 | | default: |
| 0 | 63 | | return null; |
| | 64 | | } |
| | 65 | | } |
| | 66 | |
|
| | 67 | | internal abstract XElement Serialize(); |
| | 68 | |
|
| | 69 | | /// <inheritdoc/> |
| | 70 | | public abstract override bool Equals(object obj); |
| | 71 | |
|
| | 72 | | /// <inheritdoc/> |
| | 73 | | public override int GetHashCode() => |
| 0 | 74 | | base.GetHashCode(); |
| | 75 | | } |
| | 76 | | } |