| | | 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 CoreWCF.IdentityModel; |
| | | 5 | | using CoreWCF.IdentityModel.Tokens; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Security |
| | | 8 | | { |
| | | 9 | | public class BinarySecretKeyIdentifierClause : BinaryKeyIdentifierClause |
| | | 10 | | { |
| | | 11 | | private InMemorySymmetricSecurityKey _symmetricKey; |
| | | 12 | | |
| | | 13 | | public BinarySecretKeyIdentifierClause(byte[] key) |
| | 0 | 14 | | : this(key, true) |
| | | 15 | | { |
| | 0 | 16 | | } |
| | | 17 | | |
| | | 18 | | public BinarySecretKeyIdentifierClause(byte[] key, bool cloneBuffer) |
| | 0 | 19 | | : this(key, cloneBuffer, null, 0) |
| | | 20 | | { |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | public BinarySecretKeyIdentifierClause(byte[] key, bool cloneBuffer, byte[] derivationNonce, int derivationLengt |
| | 0 | 24 | | : base(XD.TrustFeb2005Dictionary.BinarySecretClauseType.Value, key, cloneBuffer, derivationNonce, derivation |
| | | 25 | | { |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | public byte[] GetKeyBytes() |
| | | 29 | | { |
| | 0 | 30 | | return GetBuffer(); |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | public override bool CanCreateKey |
| | | 34 | | { |
| | 0 | 35 | | get { return true; } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | public override SecurityKey CreateKey() |
| | | 39 | | { |
| | 0 | 40 | | if (_symmetricKey == null) |
| | | 41 | | { |
| | 0 | 42 | | _symmetricKey = new InMemorySymmetricSecurityKey(GetBuffer(), false); |
| | | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | return _symmetricKey; |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause) |
| | | 49 | | { |
| | 0 | 50 | | BinarySecretKeyIdentifierClause that = keyIdentifierClause as BinarySecretKeyIdentifierClause; |
| | 0 | 51 | | return ReferenceEquals(this, that) || (that != null && that.Matches(GetRawBuffer())); |
| | | 52 | | } |
| | | 53 | | } |
| | | 54 | | } |