GetCertificateRequest.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 / infocard / Service / managed / Microsoft / InfoCards / GetCertificateRequest.cs / 1 / GetCertificateRequest.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
namespace Microsoft.InfoCards
{ 
    using System;
    using System.IO; 
    using System.Security.Cryptography.X509Certificates; 
    using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace;
 
    //
    // Summary
    // Requests the certificate for the specified recipient.
    // 
    internal class GetCertificateRequest : UIAgentRequest
    { 
        string m_recipientIdentifier;   // Stores the recipient identifier. 
        X509Certificate2 m_certificate; // Stores reference to the certificate.
 
        public GetCertificateRequest( IntPtr rpcHandle, Stream inArgs, Stream outArgs, ClientUIRequest parent )
            : base( rpcHandle, inArgs, outArgs, parent )
        {
        } 

        // 
        // Summary 
        // Reads the recipient identifier from the argument stream.
        // 
        protected override void OnMarshalInArgs()
        {
            BinaryReader reader = new BinaryReader( InArgs, System.Text.Encoding.Unicode );
 
            m_recipientIdentifier = Utility.DeserializeString( reader );
        } 
 
        //
        // Summary 
        // Retrieves the certificate from the cache.
        //
        protected override void OnProcess()
        { 
            m_certificate = ParentRequest.CertCacheFind( m_recipientIdentifier );
 
            if( null == m_certificate ) 
            {
                throw IDT.ThrowHelperError( new InfoCardArgumentException( SR.GetString( SR.NoCachedCertificateForRecipient ) ) ); 
            }
        }

        // 
        // Summary
        // Writes the encoded certificate to the argument stream. 
        // 
        protected override void OnMarshalOutArgs()
        { 
            BinaryWriter writer = new BinaryWriter( OutArgs, System.Text.Encoding.Unicode );

            Utility.SerializeBytes( writer, m_certificate.GetRawCertData() );
        } 
    }
} 

// 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