Exemplo n.º 1
0
        public bool ProcessAuthentication()
        {
            if (TD.HttpContextBeforeProcessAuthenticationIsEnabled())
            {
                TD.HttpContextBeforeProcessAuthentication(this.eventTraceActivity);
            }

            HttpStatusCode statusCode = ValidateAuthentication();

            if (statusCode == HttpStatusCode.OK)
            {
                bool authenticationSucceeded = false;
                statusCode = HttpStatusCode.Forbidden;
                try
                {
                    this.securityProperty   = OnProcessAuthentication();
                    authenticationSucceeded = true;
                    return(true);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    if (e.Data.Contains(HttpChannelUtilities.HttpStatusCodeKey))
                    {
                        if (e.Data[HttpChannelUtilities.HttpStatusCodeKey] is HttpStatusCode)
                        {
                            statusCode = (HttpStatusCode)e.Data[HttpChannelUtilities.HttpStatusCodeKey];
                        }
                    }

                    throw;
                }
                finally
                {
                    if (!authenticationSucceeded)
                    {
                        SendResponseAndClose(statusCode);
                    }
                }
            }
            else
            {
                SendResponseAndClose(statusCode);
                return(false);
            }
        }