本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}