Пример #1
0
        /// <summary>
        /// Process message 1 and create message 2 for the client
        /// </summary>
        /// <param name="data">Thread Data, input parameter (HttpRequestMessage) from the client</param>
        public void ProcessMessage(object data)
        {
            msg2Response = null;

            log.Debug("ProcessMessage(.) started.");

            try
            {
                if (data == null)
                {
                    HttpResponseException e = new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
                    options.LogThrownException(e);
                    throw e;
                }

                HttpRequestMessage request = (HttpRequestMessage)data;

                mClient = ClientDatabase.GetTransaction(request, Constants.msg1Str);
                if (mClient == null)
                {
                    Exception e = new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
                    options.LogThrownException(e);
                    throw e;
                }

                // kill client wait thread so we don't time out.
                mClient.killTimerThread();

                // NOTE: There is a potential race-condition where the client is removed from the database during the time that the cilent sends its response
                // Can choose to check to re-add the client here in that case


                log.Debug("\n ***** State: Starting Message 1/2 sequence for client: " + mClient.ID + "\n");

                Msg1 m1 = new Msg1();
                M2ResponseMessage m2Response = m1.ProcessMessage1(request, mClient.sigmaSequenceCheck);

                // Set Client State
                msg2Response = m2Response;
            }
            catch (HttpResponseException re)
            {
                options.LogCaughtException(re);
                httpRE = re;
            }
            catch (Exception ex)
            {
                options.LogCaughtException(ex);
                threadException = ex;
            }
            finally
            {
                log.Debug("ProcessMessage(.) returning.");
            }
        }
Пример #2
0
        /// <summary>
        /// Continue transaction for Message 3/4 sequence
        /// </summary>
        /// <param name="request">Client Message 3 response/4 request</param>
        public static async Task <M4ResponseMessage> Message3(HttpRequestMessage request)
        {
            log.Debug("Message3(.) started.");

            if (request == null)
            {
                HttpResponseException e = new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
                options.LogThrownException(e);
                throw e;
            }

            M4ResponseMessage m4Response = null;

            try
            {
                ClientTransaction mClient = GetTransaction(request, Constants.msg3Str);
                if (mClient == null)
                {
                    HttpResponseException e = new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
                    options.LogThrownException(e);
                    throw e;
                }

                // kill client wait thread so we don't time out.
                mClient.killTimerThread();

                // NOTE: There is a potential race-condition where the client is removed from the database during the time that the cilent sends its response
                // Can choose to check to re-add the client here in that case

                log.Info("\n ***** State: Starting Message 3/4 sequence for client: " + mClient.ID + "\n");

                Msg3 msg3 = new Msg3();
                m4Response = await msg3.ProcessMessage3(request, mClient.sigmaSequenceCheck);

                log.Debug("Message3(.) returning.");
            }
            catch (HttpResponseException)
            {
                throw;
            }
            catch (Exception e)
            {
                log.Debug("Error processing Message 3/4. " + e.Message);
            }

            // Return challenge to client
            return(m4Response);
        }