Exemplo n.º 1
0
 public override void SendAsync(ServerAsyncEventArgs e)
 {
     try
     {
         Server <C> .Connection <C> tcpConnection = base.GetTcpConnection(e.RemoteEndPoint);
         base.OnBeforeSend(tcpConnection, e);
         if (tcpConnection == null)
         {
             e.Completed   = new ServerAsyncEventArgs.CompletedEventHandler(base.Send_Completed);
             e.SocketError = SocketError.NotConnected;
             e.OnCompleted(null);
         }
         else
         {
             SspiContext sspiContext = tcpConnection.SspiContext;
             SecPkgContext_StreamSizes streamSizes = sspiContext.StreamSizes;
             int count = e.Count;
             if (e.OffsetOffset < streamSizes.cbHeader)
             {
                 throw new NotImplementedException("Ineffective way not implemented. Need to move buffer for SECBUFFER_STREAM_HEADER.");
             }
             e.OffsetOffset -= streamSizes.cbHeader;
             e.Count         = streamSizes.cbHeader + count + streamSizes.cbTrailer;
             e.ReAllocateBuffer(true);
             SecBufferDescEx secBufferDescEx = new SecBufferDescEx(new SecBufferEx[]
             {
                 new SecBufferEx
                 {
                     BufferType = BufferType.SECBUFFER_STREAM_HEADER,
                     Buffer     = e.Buffer,
                     Size       = streamSizes.cbHeader,
                     Offset     = e.Offset
                 },
                 new SecBufferEx
                 {
                     BufferType = BufferType.SECBUFFER_DATA,
                     Buffer     = e.Buffer,
                     Size       = count,
                     Offset     = e.Offset + streamSizes.cbHeader
                 },
                 new SecBufferEx
                 {
                     BufferType = BufferType.SECBUFFER_STREAM_TRAILER,
                     Buffer     = e.Buffer,
                     Size       = streamSizes.cbTrailer,
                     Offset     = e.Offset + streamSizes.cbHeader + count
                 },
                 new SecBufferEx
                 {
                     BufferType = BufferType.SECBUFFER_VERSION
                 }
             });
             Sspi.EncryptMessage(ref sspiContext.Handle, ref secBufferDescEx, 0u, null);
             e.Count = secBufferDescEx.Buffers[0].Size + secBufferDescEx.Buffers[1].Size + secBufferDescEx.Buffers[2].Size;
             e.ReAllocateBuffer(true);
             base.SendAsync(tcpConnection, e);
         }
     }
     catch (SspiException error)
     {
         e.SocketError = SocketError.Fault;
         this.OnFailed(new ServerInfoEventArgs(this.realEndPoint, error));
     }
 }
Exemplo n.º 2
0
 public StreamSizes(SecPkgContext_StreamSizes interopStreamSizes)
 {
     Header         = interopStreamSizes.cbHeader;
     Trailer        = interopStreamSizes.cbTrailer;
     MaximumMessage = interopStreamSizes.cbMaximumMessage;
 }
Exemplo n.º 3
0
 public StreamSizes(SecPkgContext_StreamSizes interopStreamSizes)
 {
     Header = interopStreamSizes.cbHeader;
     Trailer = interopStreamSizes.cbTrailer;
     MaximumMessage = interopStreamSizes.cbMaximumMessage;
 }