当前位置: 首页>>代码示例>>C#>>正文


C# ChannelBinding.DangerousGetHandle方法代码示例

本文整理汇总了C#中System.Security.Authentication.ExtendedProtection.ChannelBinding.DangerousGetHandle方法的典型用法代码示例。如果您正苦于以下问题:C# ChannelBinding.DangerousGetHandle方法的具体用法?C# ChannelBinding.DangerousGetHandle怎么用?C# ChannelBinding.DangerousGetHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Authentication.ExtendedProtection.ChannelBinding的用法示例。


在下文中一共展示了ChannelBinding.DangerousGetHandle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckChannelBinding

 public void CheckChannelBinding(ChannelBinding channelBinding)
 {
     if (channelBinding != null)
     {
         Assert.True(!channelBinding.IsInvalid, "Channel binding token should be marked as a valid SafeHandle.");
         Assert.True(channelBinding.Size > 0, "Number of bytes in a valid channel binding token should be greater than zero.");
         var bytes = new byte[channelBinding.Size];
         Marshal.Copy(channelBinding.DangerousGetHandle(), bytes, 0, channelBinding.Size);
         Assert.Equal(channelBinding.Size, bytes.Length);
     }
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:11,代码来源:TransportContextTest.cs

示例2: formatChannelBindingForHash

        //
        // Adapted from ComputeGssBindHash() in ds\security\protocols\sspcommon\sspbindings.cxx
        //
        // The formatted binding is:
        //   1. the initiator type and length
        //   2. the initiator data, if any
        //   3. the acceptor type and length
        //   4. the acceptor data, if any
        //   5. the application data length
        //   6. the application data, if any
        //
        private static byte[] formatChannelBindingForHash(ChannelBinding binding)
        {
            int initiatorType = Marshal.ReadInt32(binding.DangerousGetHandle(), InitiatorTypeOffset);
            int initiatorLength = Marshal.ReadInt32(binding.DangerousGetHandle(), InitiatorLengthOffset);
            int acceptorType = Marshal.ReadInt32(binding.DangerousGetHandle(), AcceptorTypeOffset);
            int acceptorLength = Marshal.ReadInt32(binding.DangerousGetHandle(), AcceptorLengthOffset);
            int applicationDataLength = Marshal.ReadInt32(binding.DangerousGetHandle(), ApplicationDataLengthOffset);

            byte[] formattedData = new byte[MinimumFormattedBindingLength + initiatorLength + acceptorLength + applicationDataLength];

            BitConverter.GetBytes(initiatorType).CopyTo(formattedData, 0);
            BitConverter.GetBytes(initiatorLength).CopyTo(formattedData, SizeOfInt);

            int offset = 2 * SizeOfInt;
            if (initiatorLength > 0)
            {
                int initiatorOffset = Marshal.ReadInt32(binding.DangerousGetHandle(), InitiatorOffsetOffset);
                Marshal.Copy(IntPtrHelper.Add(binding.DangerousGetHandle(), initiatorOffset), formattedData, offset, initiatorLength);
                offset += initiatorLength;
            }

            BitConverter.GetBytes(acceptorType).CopyTo(formattedData, offset);
            BitConverter.GetBytes(acceptorLength).CopyTo(formattedData, offset + SizeOfInt);

            offset += 2 * SizeOfInt;
            if (acceptorLength > 0)
            {
                int acceptorOffset = Marshal.ReadInt32(binding.DangerousGetHandle(), AcceptorOffsetOffset);
                Marshal.Copy(IntPtrHelper.Add(binding.DangerousGetHandle(), acceptorOffset), formattedData, offset, acceptorLength);
                offset += acceptorLength;
            }

            BitConverter.GetBytes(applicationDataLength).CopyTo(formattedData, offset);

            offset += SizeOfInt;
            if (applicationDataLength > 0)
            {
                int applicationDataOffset = Marshal.ReadInt32(binding.DangerousGetHandle(), ApplicationDataOffsetOffset);
                Marshal.Copy(IntPtrHelper.Add(binding.DangerousGetHandle(), applicationDataOffset), formattedData, offset, applicationDataLength);
            }

            return formattedData;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:54,代码来源:_DigestClient.cs

示例3: ExtendedProtectionPolicy

        protected ExtendedProtectionPolicy(SerializationInfo info, StreamingContext context)
        {
            policyEnforcement = (PolicyEnforcement)info.GetInt32(policyEnforcementName);
            protectionScenario = (ProtectionScenario)info.GetInt32(protectionScenarioName);
            customServiceNames = (ServiceNameCollection)info.GetValue(customServiceNamesName, typeof(ServiceNameCollection));

            byte[] channelBindingData = (byte[])info.GetValue(customChannelBindingName, typeof(byte[]));
            if (channelBindingData != null)
            {
                customChannelBinding = SafeLocalFreeChannelBinding.LocalAlloc(channelBindingData.Length);
                Marshal.Copy(channelBindingData, 0, customChannelBinding.DangerousGetHandle(), channelBindingData.Length);
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:13,代码来源:ExtendedProtectionPolicy.cs

示例4: Initialize

 private unsafe void Initialize(ChannelBinding source)
 {
     this.AllocateMemory(source.Size);
     byte* numPtr = (byte*) source.DangerousGetHandle().ToPointer();
     byte* numPtr2 = (byte*) this.handle.ToPointer();
     for (int i = 0; i < source.Size; i++)
     {
         numPtr2[i] = numPtr[i];
     }
     this.size = source.Size;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:ChannelBindingUtility.cs

示例5: Initialize

            unsafe void Initialize(ChannelBinding source)
            {
                //allocates the memory pointed to by this.handle
                //and sets this.size after allocation succeeds.
                AllocateMemory(source.Size);

                byte* sourceBuffer = (byte*)source.DangerousGetHandle().ToPointer();
                byte* destinationBuffer = (byte*)this.handle.ToPointer();

                for (int i = 0; i < source.Size; i++)
                {
                    destinationBuffer[i] = sourceBuffer[i];
                }

                this.size = source.Size;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:16,代码来源:ChannelBindingUtility.cs


注:本文中的System.Security.Authentication.ExtendedProtection.ChannelBinding.DangerousGetHandle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。