| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Runtime.Serialization; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF.IdentityModel.Tokens |
| | | 7 | | { |
| | | 8 | | [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/System.IdentityModel.Tokens")] |
| | | 9 | | public class SamlAuthorizationDecisionClaimResource |
| | | 10 | | { |
| | | 11 | | [DataMember] |
| | | 12 | | private string resource; |
| | | 13 | | |
| | | 14 | | [DataMember] |
| | | 15 | | private SamlAccessDecision accessDecision; |
| | | 16 | | |
| | | 17 | | [DataMember] |
| | | 18 | | private string actionNamespace; |
| | | 19 | | |
| | | 20 | | [DataMember] |
| | | 21 | | private string actionName; |
| | | 22 | | |
| | | 23 | | [OnDeserialized] |
| | | 24 | | private void OnDeserialized(StreamingContext ctx) |
| | | 25 | | { |
| | 0 | 26 | | if (string.IsNullOrEmpty(resource)) |
| | 0 | 27 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(resource)); |
| | 0 | 28 | | if (string.IsNullOrEmpty(actionName)) |
| | 0 | 29 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(actionName)); |
| | 0 | 30 | | } |
| | | 31 | | |
| | 0 | 32 | | public SamlAuthorizationDecisionClaimResource(string resource, SamlAccessDecision accessDecision, string actionN |
| | | 33 | | { |
| | 0 | 34 | | if (string.IsNullOrEmpty(resource)) |
| | 0 | 35 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(resource)); |
| | 0 | 36 | | if (string.IsNullOrEmpty(actionName)) |
| | 0 | 37 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(actionName)); |
| | | 38 | | |
| | 0 | 39 | | this.resource = resource; |
| | 0 | 40 | | this.accessDecision = accessDecision; |
| | 0 | 41 | | this.actionNamespace = actionNamespace; |
| | 0 | 42 | | this.actionName = actionName; |
| | 0 | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | public string Resource => resource; |
| | | 46 | | |
| | 0 | 47 | | public SamlAccessDecision AccessDecision => accessDecision; |
| | | 48 | | |
| | 0 | 49 | | public string ActionNamespace => actionNamespace; |
| | | 50 | | |
| | 0 | 51 | | public string ActionName => actionName; |
| | | 52 | | |
| | | 53 | | public override bool Equals(object obj) |
| | | 54 | | { |
| | 0 | 55 | | if (obj == null) |
| | 0 | 56 | | return false; |
| | | 57 | | |
| | 0 | 58 | | if (ReferenceEquals(this, obj)) |
| | 0 | 59 | | return true; |
| | | 60 | | |
| | 0 | 61 | | SamlAuthorizationDecisionClaimResource rhs = obj as SamlAuthorizationDecisionClaimResource; |
| | 0 | 62 | | if (rhs == null) |
| | 0 | 63 | | return false; |
| | | 64 | | |
| | 0 | 65 | | return ((ActionName == rhs.ActionName) && (ActionNamespace == rhs.ActionNamespace) && |
| | 0 | 66 | | (Resource == rhs.Resource) && (AccessDecision == rhs.AccessDecision)); |
| | | 67 | | } |
| | | 68 | | |
| | | 69 | | public override int GetHashCode() |
| | | 70 | | { |
| | 0 | 71 | | return (resource.GetHashCode() ^ accessDecision.GetHashCode()); |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | |
| | | 75 | | [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/System.IdentityModel.Tokens")] |
| | | 76 | | public enum SamlAccessDecision |
| | | 77 | | { |
| | | 78 | | [EnumMember] |
| | | 79 | | Permit, |
| | | 80 | | [EnumMember] |
| | | 81 | | Deny, |
| | | 82 | | [EnumMember] |
| | | 83 | | Indeterminate |
| | | 84 | | } |
| | | 85 | | } |