| | | 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; |
| | | 5 | | using Microsoft.IdentityModel.Tokens; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.IdentityModel.Tokens.Saml |
| | | 8 | | { |
| | | 9 | | public class KeyInfo : Microsoft.IdentityModel.Xml.KeyInfo |
| | | 10 | | { |
| | | 11 | | public SecurityTokenReference SecurityTokenReference |
| | | 12 | | { |
| | 19 | 13 | | get; |
| | 3 | 14 | | set; |
| | | 15 | | } |
| | | 16 | | |
| | | 17 | | public BinarySecret BinarySecret |
| | | 18 | | { |
| | 4 | 19 | | get; |
| | 1 | 20 | | set; |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | public EncryptedKey EncryptedKey |
| | | 24 | | { |
| | 2 | 25 | | get; |
| | 0 | 26 | | set; |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | protected override bool MatchesKey(Microsoft.IdentityModel.Tokens.SecurityKey key) |
| | | 30 | | { |
| | | 31 | | X509SecurityKey x509SecurityKey = key as X509SecurityKey; |
| | 0 | 32 | | if (key != null) |
| | | 33 | | { |
| | 0 | 34 | | if (SecurityTokenReference != null) |
| | | 35 | | { |
| | 0 | 36 | | return SecurityTokenReference.MatchesKey(key); |
| | | 37 | | } |
| | | 38 | | } |
| | | 39 | | |
| | 0 | 40 | | return base.MatchesKey(key); |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | public override bool Equals(object obj) |
| | | 44 | | { |
| | | 45 | | // Check if obj is null or not the same type |
| | 0 | 46 | | if (obj == null || GetType() != obj.GetType()) |
| | 0 | 47 | | return false; |
| | | 48 | | |
| | | 49 | | // Check if it's the same instance |
| | 0 | 50 | | if (ReferenceEquals(this, obj)) |
| | 0 | 51 | | return true; |
| | | 52 | | |
| | 0 | 53 | | KeyInfo other = (KeyInfo)obj; |
| | | 54 | | |
| | | 55 | | // Call base class Equals |
| | 0 | 56 | | if (!base.Equals(obj)) |
| | 0 | 57 | | return false; |
| | | 58 | | |
| | | 59 | | // Compare SecurityTokenReference |
| | 0 | 60 | | if (!Object.Equals(SecurityTokenReference, other.SecurityTokenReference)) |
| | 0 | 61 | | return false; |
| | | 62 | | |
| | | 63 | | // Compare BinarySecret |
| | 0 | 64 | | if (!Object.Equals(BinarySecret, other.BinarySecret)) |
| | 0 | 65 | | return false; |
| | | 66 | | |
| | | 67 | | // Compare EncryptedKey |
| | 0 | 68 | | if (!Object.Equals(EncryptedKey, other.EncryptedKey)) |
| | 0 | 69 | | return false; |
| | | 70 | | |
| | 0 | 71 | | return true; |
| | | 72 | | } |
| | | 73 | | |
| | | 74 | | public override int GetHashCode() |
| | | 75 | | { |
| | 0 | 76 | | return base.GetHashCode() * 23 + HashCode.Combine(SecurityTokenReference, BinarySecret, EncryptedKey); |
| | | 77 | | } |
| | | 78 | | } |
| | | 79 | | } |
| | | 80 | | |