| | | 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 System.Globalization; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.IdentityModel.Tokens |
| | | 8 | | { |
| | | 9 | | public sealed class EncryptedKeyIdentifierClause : BinaryKeyIdentifierClause |
| | | 10 | | { |
| | | 11 | | public EncryptedKeyIdentifierClause(byte[] encryptedKey, string encryptionMethod) |
| | 0 | 12 | | : this(encryptedKey, encryptionMethod, null) |
| | | 13 | | { |
| | 0 | 14 | | } |
| | | 15 | | |
| | | 16 | | public EncryptedKeyIdentifierClause(byte[] encryptedKey, string encryptionMethod, SecurityKeyIdentifier encrypti |
| | 0 | 17 | | : this(encryptedKey, encryptionMethod, encryptingKeyIdentifier, null) |
| | | 18 | | { |
| | 0 | 19 | | } |
| | | 20 | | |
| | | 21 | | public EncryptedKeyIdentifierClause(byte[] encryptedKey, string encryptionMethod, SecurityKeyIdentifier encrypti |
| | 0 | 22 | | : this(encryptedKey, encryptionMethod, encryptingKeyIdentifier, carriedKeyName, true, null, 0) |
| | | 23 | | { |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | public EncryptedKeyIdentifierClause(byte[] encryptedKey, string encryptionMethod, SecurityKeyIdentifier encrypti |
| | 0 | 27 | | : this(encryptedKey, encryptionMethod, encryptingKeyIdentifier, carriedKeyName, true, derivationNonce, deriv |
| | | 28 | | { |
| | 0 | 29 | | } |
| | | 30 | | |
| | | 31 | | internal EncryptedKeyIdentifierClause(byte[] encryptedKey, string encryptionMethod, SecurityKeyIdentifier encryp |
| | 0 | 32 | | : base("http://www.w3.org/2001/04/xmlenc#EncryptedKey", encryptedKey, cloneBuffer, derivationNonce, derivati |
| | | 33 | | { |
| | 0 | 34 | | CarriedKeyName = carriedKeyName; |
| | 0 | 35 | | EncryptionMethod = encryptionMethod ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(name |
| | 0 | 36 | | EncryptingKeyIdentifier = encryptingKeyIdentifier; |
| | 0 | 37 | | } |
| | | 38 | | |
| | 0 | 39 | | public string CarriedKeyName { get; } |
| | | 40 | | |
| | 0 | 41 | | public SecurityKeyIdentifier EncryptingKeyIdentifier { get; } |
| | | 42 | | |
| | 0 | 43 | | public string EncryptionMethod { get; } |
| | | 44 | | |
| | | 45 | | public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause) |
| | | 46 | | { |
| | 0 | 47 | | EncryptedKeyIdentifierClause that = keyIdentifierClause as EncryptedKeyIdentifierClause; |
| | 0 | 48 | | return ReferenceEquals(this, that) || (that != null && that.Matches(GetRawBuffer(), EncryptionMethod, Carrie |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | public bool Matches(byte[] encryptedKey, string encryptionMethod, string carriedKeyName) |
| | | 52 | | { |
| | 0 | 53 | | return Matches(encryptedKey) && EncryptionMethod == encryptionMethod && CarriedKeyName == carriedKeyName; |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | public byte[] GetEncryptedKey() |
| | | 57 | | { |
| | 0 | 58 | | return GetBuffer(); |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | public override string ToString() |
| | | 62 | | { |
| | 0 | 63 | | return string.Format(CultureInfo.InvariantCulture, "EncryptedKeyIdentifierClause(EncryptedKey = {0}, Method |
| | 0 | 64 | | Convert.ToBase64String(GetRawBuffer()), EncryptionMethod); |
| | | 65 | | } |
| | | 66 | | } |
| | | 67 | | } |