| | | 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] |
| | | 9 | | public class SamlNameIdentifierClaimResource |
| | | 10 | | { |
| | | 11 | | [DataMember] |
| | | 12 | | private readonly string nameQualifier; |
| | | 13 | | |
| | | 14 | | [DataMember] |
| | | 15 | | private readonly string format; |
| | | 16 | | |
| | | 17 | | [DataMember] |
| | | 18 | | private readonly string name; |
| | | 19 | | |
| | | 20 | | [OnDeserialized] |
| | | 21 | | private void OnDeserialized(StreamingContext ctx) |
| | | 22 | | { |
| | 0 | 23 | | if (string.IsNullOrEmpty(name)) |
| | 0 | 24 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(name)); |
| | 0 | 25 | | } |
| | | 26 | | |
| | 0 | 27 | | public SamlNameIdentifierClaimResource(string name, string nameQualifier, string format) |
| | | 28 | | { |
| | 0 | 29 | | if (string.IsNullOrEmpty(name)) |
| | 0 | 30 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(name)); |
| | | 31 | | |
| | 0 | 32 | | this.name = name; |
| | 0 | 33 | | this.nameQualifier = nameQualifier; |
| | 0 | 34 | | this.format = format; |
| | 0 | 35 | | } |
| | | 36 | | |
| | 0 | 37 | | public string NameQualifier => nameQualifier; |
| | | 38 | | |
| | 0 | 39 | | public string Format => format; |
| | | 40 | | |
| | 0 | 41 | | public string Name => name; |
| | | 42 | | |
| | | 43 | | public override bool Equals(object obj) |
| | | 44 | | { |
| | 0 | 45 | | if (obj == null) |
| | 0 | 46 | | return false; |
| | | 47 | | |
| | 0 | 48 | | if (ReferenceEquals(this, obj)) |
| | 0 | 49 | | return true; |
| | | 50 | | |
| | 0 | 51 | | SamlNameIdentifierClaimResource rhs = obj as SamlNameIdentifierClaimResource; |
| | 0 | 52 | | if (rhs == null) |
| | 0 | 53 | | return false; |
| | | 54 | | |
| | 0 | 55 | | return ((nameQualifier == rhs.nameQualifier) && (format == rhs.format) && (name == rhs.name)); |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | public override int GetHashCode() |
| | | 59 | | { |
| | 0 | 60 | | return name.GetHashCode(); |
| | | 61 | | } |
| | | 62 | | } |
| | | 63 | | } |