public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            RequestState rs = state as RequestState;
            if (rs != null && rs.didCompress) {
                bool compressOK = object.Equals(headers[CompressionHelper.CompressKey], CompressionHelper.CompressedFlag);
                if (!compressOK) {
                    serverCanCompress = false;
                    checkedCompress = true;

                    // synchronously send the message now
                    rs.origStream.Position = rs.origPos;
                    ProcessMessage(rs.msg, rs.headers, rs.origStream, out headers, out stream);
                }
                else {
                    // decompress stuff
                    stream = CompressionHelper.DecompressStream(stream);

                    serverCanCompress = true;
                    checkedCompress = true;
                }
                rs.origStream.Close();
            }

            // process through the rest of the stacks
            sinkStack.AsyncProcessResponse(headers, stream);
        }
		public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders responseHeaders, Stream responseStream)
		{
			// parameters validation
			if (sinkStack == null)
				throw new ArgumentNullException("sinkStack");
			if (responseHeaders == null)
				throw new ArgumentNullException("responseHeaders");
			if (responseStream == null)
				throw new ArgumentNullException("responseStream");

			IMethodCallMessage methodCall = state as IMethodCallMessage;
			if (methodCall == null)
				throw new NotSupportedException();

			IMethodReturnMessage methodReturn;
			try
			{
				// deserialize response
				methodReturn = _formatter.DeserializeResponse(methodCall, responseHeaders, responseStream);
				responseStream.Close();
			}
			catch (Exception ex)
			{
				methodReturn = new ReturnMessage(ex, methodCall);
			}

			// dispatch response
			sinkStack.DispatchReplyMessage(methodReturn);
		}
Esempio n. 3
0
		public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
						  object state,
						  ITransportHeaders headers,
						  Stream stream)
		{
			throw new NotImplementedException ();
		}
Esempio n. 4
0
 public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
                                   object state,
                                   ITransportHeaders headers,
                                   Stream stream)
 {
   Console.WriteLine ("ClientTransport: AsyncProcessResponse");
   throw new NotSupportedException();
 }
Esempio n. 5
0
        } // AsyncProcessRequest

        /// <include file='doc\SoapFormatterSinks.uex' path='docs/doc[@for="SoapClientFormatterSink.AsyncProcessResponse"]/*' />
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, Object state,
                                         ITransportHeaders headers, Stream stream)
        {
            // previously we stored the outgoing message in state
            IMethodCallMessage mcm    = (IMethodCallMessage)state;
            IMessage           retMsg = DeserializeMessage(mcm, headers, stream);

            sinkStack.DispatchReplyMessage(retMsg);
        } // AsyncProcessRequest
Esempio n. 6
0
        /// <summary>
        /// Requests asynchronous processing of a response to a method call on the current sink.
        /// </summary>
        /// <param name="sinkStack">A stack of sinks that called this sink.</param>
        /// <param name="state">Information generated on the request side that is associated with this sink.</param>
        /// <param name="headers">The headers retrieved from the server response stream.</param>
        /// <param name="stream">The stream coming back from the transport sink.</param>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Gets the asynchronous processing state
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                SecureTransactionStage currentStage = (SecureTransactionStage)Convert.ToInt32((string)headers[CommonHeaderNames.SECURE_TRANSACTION_STATE]);
                switch (currentStage)
                {
                case SecureTransactionStage.SendingEncryptedResult:                         // Get the encrypted response from the server

                    lock (_lockObject)
                    {
                        if (asyncState.SecureTransactionID.Equals(_secureTransactionID))
                        {
                            stream = DecryptResponse(stream, headers);
                        }
                        else
                        {
                            throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_KeyChanged);
                        }
                    }
                    break;

                case SecureTransactionStage.UnknownTransactionID:                         // Bad transaction identifier

                    throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_InvalidTransactionID);

                default:

                case SecureTransactionStage.Uninitialized:                         // Secure transaction is not yet set up
                    break;
                }
            }
            catch (CryptoRemotingException)
            {
                lock (_lockObject)
                {
                    // If remote transaction identifier matches the local secure transaction identifier, reset the shared key
                    if (_provider == null || asyncState.SecureTransactionID.Equals(_secureTransactionID))
                    {
                        ClearSharedKey();
                    }

                    ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);
                }
            }
            finally
            {
                // Close the input stream
                asyncState.Stream.Close();
            }

            // Pass on to the next sink to continue processing
            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 7
0
 public void AsyncProcessResponse(
     IClientResponseChannelSinkStack sinkStack,
     object state,
     ITransportHeaders headers,
     Stream stream)
 {
     // Send the request to the server.
     sinkStack.AsyncProcessResponse(headers, stream);
 }
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                         object state,
                                         ITransportHeaders headers,
                                         Stream stream)
        {
            IMessage replyMessage = (IMessage)_binaryCore.Deserializer.DeserializeMethodResponse(stream, null, (IMethodCallMessage)state);

            sinkStack.DispatchReplyMessage(replyMessage);
        }
Esempio n. 9
0
        void IClientChannelSink.AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state,
            ITransportHeaders headers, Stream stream)
        {
            // process response
            ProcessResponse(null, headers, ref stream, state);

            // forward to the next
            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 10
0
        /// <summary>
        /// Requests asynchronous processing of a response to a method call on the current sink.
        /// </summary>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state,
                                         ITransportHeaders headers, Stream stream)
        {
            // process response
            ProcessResponse(headers, ref stream);

            // forward to the next
            sinkStack.AsyncProcessResponse(headers, stream);
        }
 public void AsyncProcessResponse(
     IClientResponseChannelSinkStack stack,
     object state,
     ITransportHeaders headers,
     Stream stream
     )
 {
     stack.AsyncProcessResponse(headers, stream);
 }
Esempio n. 12
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                SecureTransaction transactType = (SecureTransaction)Convert.ToInt32((string)headers[CommonHeaders.Transaction]);
                switch (transactType)
                {
                case SecureTransaction.SendingEncryptedResult:
                {
                    lock (_transactionLock)
                    {
                        if (asyncState.ID.Equals(_transactID))
                        {
                            stream = DecryptResponse(stream, headers);
                        }
                        else
                        {
                            throw new SecureRemotingException("The key has changed since the message was decrypted.");
                        }
                    }
                    break;
                }

                case SecureTransaction.UnknownIdentifier:
                {
                    throw new SecureRemotingException("The server sink was unable to identify the client, most likely due to the connection information timing out.");
                }

                default:
                case SecureTransaction.Uninitialized:
                {
                    break;
                }
                }
            }
            catch (SecureRemotingException)
            {
                lock (_transactionLock)
                {
                    if (_provider == null || asyncState.ID.Equals(_transactID))
                    {
                        ClearSharedKey();
                    }
                    ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);
                }
            }
            finally
            {
                asyncState.Stream.Close();
            }

            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 13
0
    public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
                                      object state,
                                      ITransportHeaders headers,
                                      Stream stream)
    {
      IMessage reqMessage = (IMessage) state;
      IMessage replyMessage = (IMessage) IceChannelUtils.ProtocolReplyToMessage (stream, reqMessage);
      stream.Close();

      sinkStack.DispatchReplyMessage (replyMessage);
    }
Esempio n. 14
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                         object state,
                                         ITransportHeaders headers,
                                         Stream stream)
        {
            IMessage reqMessage   = (IMessage)state;
            IMessage replyMessage = (IMessage)IceChannelUtils.ProtocolReplyToMessage(stream, reqMessage);

            stream.Close();

            sinkStack.DispatchReplyMessage(replyMessage);
        }
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                         object state,
                                         ITransportHeaders headers,
                                         Stream stream)
        {
            // deflate the response
            stream =
                CompressionHelper.getUncompressedStreamCopy(stream);

            // forward the request
            sinkStack.AsyncProcessResponse(headers, stream);
        }
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                         object state,
                                         ITransportHeaders headers,
                                         Stream stream)
        {
            CallData             data             = (CallData)state;
            SoapMessageFormatter soapMsgFormatter = data.Formatter;
            IMessage             replyMessage     = (IMessage)DeserializeMessage(
                stream, headers, (IMethodCallMessage)data.Msg,
                soapMsgFormatter);

            sinkStack.DispatchReplyMessage(replyMessage);
        }
Esempio n. 17
0
        public void AsyncProcessResponse(
            IClientResponseChannelSinkStack sinkStack,
            object state,
            ITransportHeaders headers,
            Stream stream)
        {
            Exception ex = GetExceptionIfNecessary(ref headers, ref stream);

            if (ex != null)
            {
                sinkStack.DispatchException(ex);
            }
            else
            {
                sinkStack.AsyncProcessResponse(headers, stream);
            }
        }
Esempio n. 18
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                         object state,
                                         ITransportHeaders headers,
                                         Stream stream)
        {
            // decompress the stream if necessary
            String xcompress = (String)headers["X-Compress"];

            if (xcompress != null && xcompress == "yes")
            {
                stream = CompressionHelper.GetUncompressedStreamCopy(stream);
            }


            // forward the request
            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 19
0
        public void AsyncProcessResponse(
            IClientResponseChannelSinkStack stack,
            object state,
            ITransportHeaders headers,
            Stream stream
            )
        {
            #region Check response stream hash
            string hash = headers[HashHelper.C_HASH_ITEM] as string;
            //Debug.WriteLine("Client Side : response stream hash is " + hash);
            bool check = HashHelper.CheckHash(ref stream, hash);
            if (!check)
            {
                throw new Exception("Client Side : response stream header checksum error");
            }
            #endregion

            stack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 20
0
		public void AsyncProcessResponse(
			IClientResponseChannelSinkStack sinkStack_in,
			object state_in,
			ITransportHeaders headers_in,
			Stream stream_in
		) {
			#region uncompress...
			if (isHeaderCompressed_(headers_in)) {
				stream_in
					= CompressionHelper.GetUncompressedStreamCopy(
						stream_in
					);
			} 
			#endregion

			sinkStack_in.AsyncProcessResponse(
				headers_in,
				stream_in
			);
		} 
Esempio n. 21
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                         object state,
                                         ITransportHeaders headers,
                                         Stream stream)
        {
            if (headers["X-Encrypt"] != null && headers["X-Encrypt"].Equals("yes"))
            {
                byte[] IV =
                    Convert.FromBase64String((String)headers["X-EncryptIV"]);

                stream = EncryptionHelper.ProcessInboundStream(
                    stream,
                    _encryptionAlgorithm,
                    _encryptionKey,
                    IV);
            }

            // forward the request
            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 22
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state,
                                         ITransportHeaders headers, Stream stream)
        {
            // client side formatter is the last sink in the chain accessing the serialised message, therefore this method is called on the return path
            AsyncProcessingData asyncData  = (AsyncProcessingData)state; // retrieve the request msg stored on the channelSinkStack
            IMessage            requestMsg = asyncData.RequestMsg;

            try {
                IMessage responseMsg;
                try {
                    GiopClientConnectionDesc conDesc = (GiopClientConnectionDesc)asyncData.ConDesc;
                    responseMsg = DeserialiseResponse(stream, headers,
                                                      requestMsg, conDesc);
                } finally {
                    m_conManager.RequestOnConnectionCompleted(requestMsg); // release the connection, because this interaction is complete
                }
                sinkStack.DispatchReplyMessage(responseMsg);               // dispatch the result message to the message handling reply sink chain
            } catch (Exception e) {
                sinkStack.DispatchException(e);                            // dispatch the exception to the message handling reply sink chain
            }
        }
Esempio n. 23
0
        public void AsyncProcessResponse(
            IClientResponseChannelSinkStack sinkStack_in,
            object state_in,
            ITransportHeaders headers_in,
            Stream stream_in
            )
        {
            #region uncompress...
            if (isHeaderCompressed_(headers_in))
            {
                stream_in
                    = CompressionHelper.GetUncompressedStreamCopy(
                          stream_in
                          );
            }
            #endregion

            sinkStack_in.AsyncProcessResponse(
                headers_in,
                stream_in
                );
        }
Esempio n. 24
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders responseHeaders, Stream responseStream)
        {
            // parameters validation
            if (sinkStack == null)
            {
                throw new ArgumentNullException("sinkStack");
            }
            if (responseHeaders == null)
            {
                throw new ArgumentNullException("responseHeaders");
            }
            if (responseStream == null)
            {
                throw new ArgumentNullException("responseStream");
            }

            IMethodCallMessage methodCall = state as IMethodCallMessage;

            if (methodCall == null)
            {
                throw new NotSupportedException();
            }

            IMethodReturnMessage methodReturn;

            try
            {
                // deserialize response
                methodReturn = _formatter.DeserializeResponse(methodCall, responseHeaders, responseStream);
                responseStream.Close();
            }
            catch (Exception ex)
            {
                methodReturn = new ReturnMessage(ex, methodCall);
            }

            // dispatch response
            sinkStack.DispatchReplyMessage(methodReturn);
        }
        /// <summary>
        /// Verarbeitet eine Antwort-Nachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="state">Asynchroner Verarbeitungsstatus</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Asychronen Verarbeitungsstatus abrufen
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                lock (_lockObject)
                {
                    //Todo: Was ist hier zu tun?
                }
            }
            finally
            {
            }

            ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);

            asyncState.Stream.Close();

            // Verarbeitung in der nächsten Kanalsenke fortsetzen
            sinkStack.AsyncProcessResponse(headers, stream);
        }
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
                                  object state, ITransportHeaders headers, Stream stream)
 {
     if (_asyncMessage != null)
     {
         try{
             object objCacheLimit = headers["X-Cache"];
             if (objCacheLimit != null && Convert.ToInt32(objCacheLimit) > 0)
             {
                 byte[] response = ExtractContents(stream);
                 cache.CacheResults(_asyncMessage, _asyncHeaders,
                                    new RemotingResult(response, headers, DateTime.UtcNow + TimeSpan.FromSeconds(Convert.ToInt32(objCacheLimit))), true);
                 sinkStack.AsyncProcessResponse(headers, new MemoryStream(response));
             }
         }
         catch (Exception) {
             sinkStack.AsyncProcessResponse(headers, stream);
         }
     }
     else
     {
         sinkStack.AsyncProcessResponse(headers, stream);
     }
 }
 void IClientChannelSink.AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, System.IO.Stream stream)
 {
     nextSink.AsyncProcessResponse(sinkStack, state, headers, stream);
 }
Esempio n. 28
0
 public void AsyncProcessResponse(
     IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     throw new RemotingException("AsyncProcessRequest is not enabled yet");
 }
Esempio n. 29
0
        /// <summary>
        /// Verarbeitet eine Antwort-Nachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="state">Asynchroner Verarbeitungsstatus</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Asychronen Verarbeitungsstatus abrufen
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                // Aktuellen Verarbeitungsschritt der Sicherheitstransaktion ermitteln
                SecureTransactionStage currentStage = (SecureTransactionStage)Convert.ToInt32((string)headers[CommonHeaderNames.SECURE_TRANSACTION_STATE]);

                // Verarbeitungsschritt auswerten
                switch (currentStage)
                {
                    case SecureTransactionStage.SendingEncryptedResult: // Verschlüsselte Daten vom Server eingtroffen

                        lock (_lockObject)
                        {
                            // Wenn die Antwort auch tatsächlich zur aktuellen Sicherheitstransaktion gehört ...
                            if (asyncState.SecureTransactionID.Equals(_secureTransactionID))
                                // Datenstrom entschlüsseln
                                stream = DecryptResponse(stream, headers);
                            // Andernfalls ...
                            else
                                // Ausnahme werfen
                                throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_KeyChanged);
                        }
                        break;

                    case SecureTransactionStage.UnknownTransactionID: // Unbekannte Transaktionskennung

                        // Ausnahme werfen
                        throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_InvalidTransactionID);

                    default:

                    case SecureTransactionStage.Uninitialized: // Keine Sicherheitstransaktion eingerichtet
                        break;
                }
            }
            catch (CryptoRemotingException)
            {
                lock (_lockObject)
                {
                    // Wenn die gesendete Transaktionskennung mit der lokalen übereinstimmt ...
                    if (_provider == null || asyncState.SecureTransactionID.Equals(_secureTransactionID))
                        // Gemeinamen Schlüssel löschen
                        ClearSharedKey();

                    // Nachricht weiterverarbeiten
                    ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);
                }
            }
            finally
            {
                // Datenstrom schließen
                asyncState.Stream.Close();
            }
            // Verarbeitung in der nächsten Kanalsenke fortsetzen
            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 30
0
		public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack, object state,
			ITransportHeaders headers, Stream stream)
		{
			// Should never be called
			throw new NotSupportedException ();
		}
Esempio n. 31
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, Object state,
                                  ITransportHeaders headers, Stream stream)
 {
     // We don't have to implement this since we are always last in the chain.
     throw new NotSupportedException();
 } // AsyncProcessRequest
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state,
                                  ITransportHeaders headers, Stream stream)
 {
     // перенаправляем вызов следующему приемнику в стеке
     sinkStack.AsyncProcessResponse(headers, stream);
 }
Esempio n. 33
0
        /// <summary>
        /// Verarbeitet eine Antwort-Nachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="state">Asynchroner Verarbeitungsstatus</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Asychronen Verarbeitungsstatus abrufen
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                // Aktuellen Verarbeitungsschritt der Sicherheitstransaktion ermitteln
                SecureTransactionStage currentStage = (SecureTransactionStage)Convert.ToInt32((string)headers[CommonHeaderNames.SECURE_TRANSACTION_STATE]);

                // Verarbeitungsschritt auswerten
                switch (currentStage)
                {
                case SecureTransactionStage.SendingEncryptedResult:     // Verschlüsselte Daten vom Server eingtroffen

                    lock (_lockObject)
                    {
                        // Wenn die Antwort auch tatsächlich zur aktuellen Sicherheitstransaktion gehört ...
                        if (asyncState.SecureTransactionID.Equals(_secureTransactionID))
                        {
                            // Datenstrom entschlüsseln
                            stream = DecryptResponse(stream, headers);
                        }
                        // Andernfalls ...
                        else
                        {
                            // Ausnahme werfen
                            throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_KeyChanged);
                        }
                    }
                    break;

                case SecureTransactionStage.UnknownTransactionID:                         // Unbekannte Transaktionskennung

                    // Ausnahme werfen
                    throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_InvalidTransactionID);

                default:

                case SecureTransactionStage.Uninitialized:     // Keine Sicherheitstransaktion eingerichtet
                    break;
                }
            }
            catch (CryptoRemotingException)
            {
                lock (_lockObject)
                {
                    // Wenn die gesendete Transaktionskennung mit der lokalen übereinstimmt ...
                    if (_provider == null || asyncState.SecureTransactionID.Equals(_secureTransactionID))
                    {
                        // Gemeinamen Schlüssel löschen
                        ClearSharedKey();
                    }

                    // Nachricht weiterverarbeiten
                    ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);
                }
            }
            finally
            {
                // Datenstrom schließen
                asyncState.Stream.Close();
            }
            // Verarbeitung in der nächsten Kanalsenke fortsetzen
            sinkStack.AsyncProcessResponse(headers, stream);
        }
        /// <summary>Requests asynchronous processing of a response to a method call on the current sink.</summary>
        /// <param name="sinkStack">A stack of sinks that called this sink.</param>
        /// <param name="state">Information generated on the request side that is associated with this sink.</param>
        /// <param name="headers">The headers retrieved from the server response stream.</param>
        /// <param name="stream">The stream coming back from the transport sink.</param>
        public void AsyncProcessResponse(
			IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Get the async state we put on the stack
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                // Decrypt the response if possible
                SecureTransaction transactType = (SecureTransaction)Convert.ToInt32((string)headers[CommonHeaders.Transaction]);
                switch(transactType)
                {
                        // The only valid value; the server is sending results encrypted,
                        // so we need to decrypt them
                    case SecureTransaction.SendingEncryptedResult:
                        lock(_transactionLock)
                        {
                            if (asyncState.ID.Equals(_transactID)) stream = DecryptResponse(stream, headers);
                            else throw new SecureRemotingException("The key has changed since the message was decrypted.");
                        }
                        break;

                        // The server has no record of the client, so error out.
                        // If this were synchronous, we could try again, first renewing
                        // the connection information.  The best we can do here is null
                        // out our current connection information so that the next time
                        // through we'll create a new provider and identifier.
                    case SecureTransaction.UnknownIdentifier:
                        throw new SecureRemotingException(
                            "The server sink was unable to identify the client, " +
                            "most likely due to the connection information timing out.");

                        // Something happened and the response is not encrypted, i.e. there
                        // are no transport headers, or at least no transaction header, or it has
                        // been explicitly set by the server to Uninitialized.
                        // Regardless, do nothing.
                    default:
                    case SecureTransaction.Uninitialized:
                        break;
                }
            }
            catch(SecureRemotingException)
            {
                // We got back a secure remoting exceptionIt would be difficult to retry this as an
                // asynchronous call as we need to have the output ready to go before
                // we return.  Thus, we'll make a synchronous one by calling ProcessMessage()
                // just as if we were the previous sink.  Luckily, we kept all of the
                // necessary information sitting around.
                lock(_transactionLock) // This is a big, big lock, as are many locks in this app!  Oh well.
                {
                    if (_provider == null || asyncState.ID.Equals(_transactID)) ClearSharedKey();
                    ProcessMessage(
                        asyncState.Message, asyncState.Headers, asyncState.Stream,
                        out headers, out stream);
                }
            }
            finally
            {
                // Close the old stream just in case it hasn't been closed yet.
                asyncState.Stream.Close();
            }

            // Process through the rest of the sinks.
            sinkStack.AsyncProcessResponse(headers, stream);
        }
 /// <summary>
 /// Not supported. As this sink should be the first in the chain it only implmenets IMessageSink.
 /// </summary>
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, System.IO.Stream stream)
 {
     // Should not be called if first in chain.
     throw new NotSupportedException();
 }
Esempio n. 36
0
 public void AsyncProcessResponse(
     IClientResponseChannelSinkStack sinkStack,
     object state,
     ITransportHeaders headers,
     Stream stream)
 {
     // Send the request to the server.
     sinkStack.AsyncProcessResponse(headers, stream);
 }
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders responseHeaders, Stream responseStream)
 {
     // never called because the client transport sink is always last in the chain
     throw new NotSupportedException();
 }
Esempio n. 38
0
        /// <summary>
        /// Verarbeitet eine Antwort-Nachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="state">Asynchroner Verarbeitungsstatus</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Asychronen Verarbeitungsstatus abrufen
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {

                lock (_lockObject)
                {
                    //Todo: Was ist hier zu tun?
                }

            }
            finally
            {
            }

            ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);

            asyncState.Stream.Close();

            // Verarbeitung in der nächsten Kanalsenke fortsetzen
            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 39
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // process response como no lo he visto ejecutarse, mas vale prevenir.
            if (!stream.CanWrite)
            {
                try
                {
                    AbrirStream(ref stream);
                }
                catch
                {
                    AbrirStream(ref stream,
                        System.Convert.ToInt32( (string)headers["TamañoComprimido"]) );
                }
            }
            ProcessResponse(null, headers, ref stream, state);

            try
            {
                sinkStack.AsyncProcessResponse(headers, stream);
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
Esempio n. 40
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, System.IO.Stream stream)
 {
 }
Esempio n. 41
0
 /// <summary>
 /// Requests asynchronous processing of a response to a method call on the current sink.
 /// </summary>
 /// <param name="sinkStack"><see cref="IClientResponseChannelSinkStack"/> to process the response.</param>
 /// <param name="state">State object.</param>
 /// <param name="headers"><see cref="ITransportHeaders"/> of the response message.</param>
 /// <param name="stream"><see cref="Stream"/> with the serialized response message.</param>
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     // we're the last sink in the chain, so we don't have to implement this
     throw new NotImplementedException();
 }
Esempio n. 42
0
		public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
						  object state,
						  ITransportHeaders headers,
						  Stream stream)
		{
			IMessage replyMessage = (IMessage)_binaryCore.Deserializer.DeserializeMethodResponse (stream, null, (IMethodCallMessage)state);
			sinkStack.DispatchReplyMessage (replyMessage);
		}
Esempio n. 43
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     throw new RemotingException("Wrong sequence in config file - clientProviders");
 }
Esempio n. 44
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     throw new NotSupportedException();
 }
Esempio n. 45
0
        /// <summary>
        /// Requests asynchronous processing of a response to a method call on the current sink.
        /// </summary>
        /// <param name="sinkStack">A stack of sinks that called this sink.</param>
        /// <param name="state">Information generated on the request side that is associated with this sink.</param>
        /// <param name="headers">The headers retrieved from the server response stream.</param>
        /// <param name="stream">The stream coming back from the transport sink.</param>
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            // Gets the asynchronous processing state
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                SecureTransactionStage currentStage = (SecureTransactionStage)Convert.ToInt32((string)headers[CommonHeaderNames.SECURE_TRANSACTION_STATE]);
                switch (currentStage)
                {
                    case SecureTransactionStage.SendingEncryptedResult: // Get the encrypted response from the server

                        lock (_lockObject)
                        {
                            if (asyncState.SecureTransactionID.Equals(_secureTransactionID))
                                stream = DecryptResponse(stream, headers);
                            else
                                throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_KeyChanged);
                        }
                        break;

                    case SecureTransactionStage.UnknownTransactionID: // Bad transaction identifier

                        throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_InvalidTransactionID);

                    default:

                    case SecureTransactionStage.Uninitialized: // Secure transaction is not yet set up
                        break;
                }
            }
            catch (CryptoRemotingException)
            {
                lock (_lockObject)
                {
                    // If remote transaction identifier matches the local secure transaction identifier, reset the shared key
                    if (_provider == null || asyncState.SecureTransactionID.Equals(_secureTransactionID))
                        ClearSharedKey();

                    ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);
                }
            }
            finally
            {
                // Close the input stream
                asyncState.Stream.Close();
            }

            // Pass on to the next sink to continue processing
            sinkStack.AsyncProcessResponse(headers, stream);
        }
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     IMethodCallMessage mcm = (IMethodCallMessage) state;
     IMessage msg = this.DeserializeMessage(mcm, headers, stream);
     sinkStack.DispatchReplyMessage(msg);
 }
 void IClientChannelSink.AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, System.IO.Stream stream)
 {
     nextSink.AsyncProcessResponse(sinkStack, state, headers, stream);
 }
Esempio n. 48
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     throw new WrongConfigSequenceException();
 }
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack
     , object state
     , ITransportHeaders headers
     , Stream stream)
 {
     var methodCallMessage = (IMethodCallMessage)state;
     var responseMessage = DeserializeResponseMessage(methodCallMessage, headers, stream);
     sinkStack.DispatchReplyMessage(responseMessage);
 }
Esempio n. 50
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     stream = Zip.Decompress(stream);
     sinkStack.AsyncProcessResponse(headers, stream);
 }
		public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders responseHeaders, Stream responseStream)
		{
			// never called because the client transport sink is always last in the chain
			throw new NotSupportedException();
		}
		/// <summary>
		/// Not supported. As this sink should be the first in the chain it only implmenets IMessageSink.
		/// </summary>
		public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, System.IO.Stream stream) {
			// Should not be called if first in chain.
			throw new NotSupportedException();
		}
Esempio n. 53
0
 void IClientChannelSink.AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     throw new NotSupportedException();
 }
Esempio n. 54
0
		public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
						  object state,
						  ITransportHeaders headers,
						  Stream stream)
		{
			CallData data = (CallData) state;
			SoapMessageFormatter soapMsgFormatter = data.Formatter;
			IMessage replyMessage = (IMessage) DeserializeMessage (
				stream, headers, (IMethodCallMessage) data.Msg,
				soapMsgFormatter);
			sinkStack.DispatchReplyMessage (replyMessage);
			
		}
Esempio n. 55
0
 /// <summary></summary>
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
 {
     throw new RemotingException("Wrong sequence in config file - clientProviders");
 }
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState asyncState = (AsyncProcessingState)state;

            try
            {
                SecureTransaction transactType = (SecureTransaction)Convert.ToInt32((string)headers[CommonHeaders.Transaction]);
                switch (transactType)
                {
                    case SecureTransaction.SendingEncryptedResult:
                        {
                            lock (_transactionLock)
                            {
                                if (asyncState.ID.Equals(_transactID))
                                {
                                    stream = DecryptResponse(stream, headers);
                                }
                                else
                                {
                                    throw new SecureRemotingException("The key has changed since the message was decrypted.");
                                }
                            }
                            break;
                        }
                    case SecureTransaction.UnknownIdentifier:
                        {
                            throw new SecureRemotingException("The server sink was unable to identify the client, most likely due to the connection information timing out.");
                        }
                    default:
                    case SecureTransaction.Uninitialized:
                        {
                            break;
                        }
                }
            }
            catch (SecureRemotingException)
            {
                lock (_transactionLock)
                {
                    if (_provider == null || asyncState.ID.Equals(_transactID))
                    {
                        ClearSharedKey();
                    }
                    ProcessMessage(asyncState.Message, asyncState.Headers, asyncState.Stream, out headers, out stream);
                }
            }
            finally
            {
                asyncState.Stream.Close();
            }

            sinkStack.AsyncProcessResponse(headers, stream);
        }
Esempio n. 57
0
        } // ProcessResponseException

        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, Object state,
                                         ITransportHeaders headers, Stream stream)
        {
            // We don't have to implement this since we are always last in the chain.
        } // AsyncProcessRequest
Esempio n. 58
0
		public void AsyncProcessResponse(
			IClientResponseChannelSinkStack sinkStack_in,
			object state_in,
			ITransportHeaders headers_in,
			Stream stream_in
		) {
			#region decrypt...
			if (isHeaderEncrypted(headers_in)) {
				stream_in
					= EncryptionHelper.Decrypt(
						stream_in,
						false,
						this.keyspath_,
						this.clientid_
					);
			} 
			#endregion

			sinkStack_in.AsyncProcessResponse(
				headers_in,
				stream_in
			);
		} 
Esempio n. 59
0
 public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, Object state,
                                  ITransportHeaders headers, Stream stream)
 {
     // previously we stored the outgoing message in state
     IMethodCallMessage mcm = (IMethodCallMessage)state;  
     IMessage retMsg = DeserializeMessage(mcm, headers, stream);
     sinkStack.DispatchReplyMessage(retMsg);
 } // AsyncProcessRequest
 public void AsyncProcessResponse(IClientResponseChannelSinkStack myClientChannelSinkStack, Object state,
                                  ITransportHeaders headers, Stream stream)
 {
 }