BinarySecretKeyIdentifierClause.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / BinarySecretKeyIdentifierClause.cs / 1 / BinarySecretKeyIdentifierClause.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.ServiceModel.Security 
{
    using System.IdentityModel.Tokens; 
    using System.ServiceModel; 
    using System.ServiceModel.Security.Tokens;
 
    public class BinarySecretKeyIdentifierClause : BinaryKeyIdentifierClause
    {
        InMemorySymmetricSecurityKey symmetricKey;
 
        public BinarySecretKeyIdentifierClause(byte[] key)
            : this(key, true) 
        { 
        }
 
        public BinarySecretKeyIdentifierClause(byte[] key, bool cloneBuffer)
            : this(key, cloneBuffer, null, 0)
        {
        } 

        public BinarySecretKeyIdentifierClause(byte[] key, bool cloneBuffer, byte[] derivationNonce, int derivationLength) 
            : base(XD.TrustFeb2005Dictionary.BinarySecretClauseType.Value, key, cloneBuffer, derivationNonce, derivationLength) 
        {
        } 

        public byte[] GetKeyBytes()
        {
            return GetBuffer(); 
        }
 
        public override bool CanCreateKey 
        {
            get { return true; } 
        }

        public override SecurityKey CreateKey()
        { 
            if (this.symmetricKey == null)
                this.symmetricKey = new InMemorySymmetricSecurityKey(GetBuffer(), false); 
 
            return this.symmetricKey;
        } 

        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            BinarySecretKeyIdentifierClause that = keyIdentifierClause as BinarySecretKeyIdentifierClause; 

            // PreSharp Bug: Parameter 'that' to this public method must be validated: A null-dereference can occur here. 
#pragma warning suppress 56506 
            return ReferenceEquals(this, that) || (that != null && that.Matches(this.GetRawBuffer()));
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK