예제 #1
0
        // Token: 0x060005D2 RID: 1490 RVA: 0x000205F8 File Offset: 0x0001E7F8
        private string GetCrossPremiseRedirectUrl(string domainName, string externalDirectoryOrgId, string externalEmailAddress)
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            string value = UrlUtilities.IsConsumerRequestForO365(base.HttpContext) ? OwaProxyRequestHandler.SilentRedirection : OwaProxyRequestHandler.ManualRedirection;

            nameValueCollection.Add("redirectType", value);
            nameValueCollection.Add("extDomain", domainName);
            nameValueCollection.Add("extDirOrgId", externalDirectoryOrgId);
            if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).AddExternalEmailAddressToRedirectURL.Enabled)
            {
                nameValueCollection.Add("extEmail", externalEmailAddress);
            }
            return(AspNetHelper.GetCafeErrorPageRedirectUrl(base.HttpContext, nameValueCollection));
        }
        // Token: 0x060005A7 RID: 1447 RVA: 0x0001F708 File Offset: 0x0001D908
        private string GetCrossSiteRedirectUrl(string targetSiteDistinguishedName, string path, string query)
        {
            NameValueCollection nameValueCollection = new NameValueCollection();

            nameValueCollection.Add("redirectType", 0.ToString());
            nameValueCollection.Add("targetSiteDistinguishedName", targetSiteDistinguishedName);
            if (!string.IsNullOrEmpty(path))
            {
                nameValueCollection.Add("path", path);
            }
            if (!string.IsNullOrEmpty(query))
            {
                nameValueCollection.Add("query", query);
            }
            return(AspNetHelper.GetCafeErrorPageRedirectUrl(base.HttpContext, nameValueCollection));
        }
        // Token: 0x0600055A RID: 1370 RVA: 0x0001D8CC File Offset: 0x0001BACC
        private void HandleFbaFormPost(BackEndServer backEndServer)
        {
            HttpContext      httpContext      = base.HttpContext;
            HttpResponse     response         = httpContext.Response;
            Uri              uri              = null;
            string           text             = httpContext.Items["destination"] as string;
            bool             flag             = false;
            bool             flag2            = false;
            bool             flag3            = true;
            string           fqdn             = backEndServer.Fqdn;
            int              version          = backEndServer.Version;
            OwaServerVersion owaServerVersion = null;
            bool             flag4            = false;
            Site             site             = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "HandleFbaFormPost", 761).GetSite(fqdn, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "HandleFbaFormPost", 762);

            if (site != null && !site.Equals(HttpProxyGlobals.LocalSite.Member))
            {
                flag3 = false;
            }
            if (!FbaFormPostProxyRequestHandler.DisableSSORedirects)
            {
                owaServerVersion = OwaServerVersion.CreateFromVersionNumber(version);
                if (UrlUtilities.IsEcpUrl(text) && owaServerVersion.Major < (int)ExchangeObjectVersion.Exchange2010.ExchangeBuild.Major)
                {
                    flag  = false;
                    flag2 = false;
                }
                else if (!flag3 && !UserAgentParser.IsMonitoringRequest(base.ClientRequest.UserAgent))
                {
                    if (owaServerVersion.Major >= (int)ExchangeObjectVersion.Exchange2007.ExchangeBuild.Major)
                    {
                        FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause legacyRedirectFailureCause = FbaFormPostProxyRequestHandler.NeedCrossSiteRedirect(backEndServer, site, HttpProxyGlobals.LocalSite.Member, owaServerVersion, UrlUtilities.IsEcpUrl(text), out uri, out flag4);
                        string authority = base.ClientRequest.Url.Authority;
                        string b         = (uri == null) ? string.Empty : uri.Authority;
                        flag2 = (legacyRedirectFailureCause != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound && !string.Equals(authority, b, StringComparison.OrdinalIgnoreCase) && (legacyRedirectFailureCause != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None || uri != null));
                        if (uri == null && owaServerVersion.Major == (int)ExchangeObjectVersion.Exchange2007.ExchangeBuild.Major)
                        {
                            flag = (FbaFormPostProxyRequestHandler.NeedOnSiteLegacyRedirect(backEndServer, null, HttpProxyGlobals.LocalSite.Member, owaServerVersion, out uri, out flag4) != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None || uri != null);
                        }
                    }
                }
                else
                {
                    flag = (FbaFormPostProxyRequestHandler.NeedOnSiteLegacyRedirect(backEndServer, site, HttpProxyGlobals.LocalSite.Member, owaServerVersion, out uri, out flag4) != FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None || uri != null);
                }
            }
            if (flag2 || flag)
            {
                if (uri != null)
                {
                    string authority2 = base.ClientRequest.Url.Authority;
                    string authority3 = uri.Authority;
                    if (string.Compare(authority2, authority3, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        throw new HttpException(403, "Redirect loop detected");
                    }
                }
                using (SecureNameValueCollection secureNameValueCollection = new SecureNameValueCollection())
                {
                    int num = (int)base.HttpContext.Items["flags"];
                    secureNameValueCollection.AddUnsecureNameValue("destination", base.HttpContext.Items["destination"] as string);
                    secureNameValueCollection.AddUnsecureNameValue("username", base.HttpContext.Items["username"] as string);
                    secureNameValueCollection.AddUnsecureNameValue("flags", num.ToString(CultureInfo.InvariantCulture));
                    using (SecureString secureString = base.HttpContext.Items["password"] as SecureString)
                    {
                        secureNameValueCollection.AddSecureNameValue("password", secureString);
                        if (!flag)
                        {
                            if (flag2)
                            {
                                if (uri == null)
                                {
                                    throw new HttpException(302, AspNetHelper.GetCafeErrorPageRedirectUrl(httpContext, new NameValueCollection
                                    {
                                        {
                                            "CafeError",
                                            ErrorFE.FEErrorCodes.NoLegacyCAS.ToString()
                                        }
                                    }));
                                }
                                Uri uri2 = uri;
                                if (this.explicitLogonUser != null)
                                {
                                    uri2 = UrlUtilities.AppendSmtpAddressToUrl(uri, this.explicitLogonUser);
                                }
                                if (flag4)
                                {
                                    if (uri.Scheme == Uri.UriSchemeHttps)
                                    {
                                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                                        {
                                            ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - SSO redirecting to {0}", uri.ToString());
                                        }
                                        this.RedirectUsingSSOFBA(secureNameValueCollection, uri, response, owaServerVersion.Major);
                                        response.End();
                                        return;
                                    }
                                    throw new HttpException(302, AspNetHelper.GetCafeErrorPageRedirectUrl(httpContext, new NameValueCollection
                                    {
                                        {
                                            "CafeError",
                                            ErrorFE.FEErrorCodes.NoFbaSSL.ToString()
                                        }
                                    }));
                                }
                                else
                                {
                                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                                    {
                                        ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - redirecting to {0}", uri2.ToString());
                                    }
                                    base.PfdTracer.TraceRedirect("FbaAuth", uri2.ToString());
                                    response.Redirect(FbaFormPostProxyRequestHandler.CheckRedirectUrlForNewline(uri2.ToString()));
                                }
                            }
                            return;
                        }
                        if (uri == null)
                        {
                            throw new HttpException(302, AspNetHelper.GetCafeErrorPageRedirectUrl(httpContext, new NameValueCollection
                            {
                                {
                                    "CafeError",
                                    ErrorFE.FEErrorCodes.NoLegacyCAS.ToString()
                                }
                            }));
                        }
                        if (!flag4)
                        {
                            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                            {
                                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - redirecting to {0}", uri.ToString());
                            }
                            base.PfdTracer.TraceRedirect("FbaAuth", uri.ToString());
                            response.Redirect(FbaFormPostProxyRequestHandler.CheckRedirectUrlForNewline(uri.ToString()));
                            return;
                        }
                        if (uri.Scheme == Uri.UriSchemeHttps)
                        {
                            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                            {
                                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - SSO redirecting to {0}", uri.ToString());
                            }
                            this.RedirectUsingSSOFBA(secureNameValueCollection, uri, response, owaServerVersion.Major);
                            response.End();
                            return;
                        }
                        throw new HttpException(302, AspNetHelper.GetCafeErrorPageRedirectUrl(httpContext, new NameValueCollection
                        {
                            {
                                "CafeError",
                                ErrorFE.FEErrorCodes.NoFbaSSL.ToString()
                            }
                        }));
                    }
                }
            }
            try
            {
                FbaModule.SetCadataCookies(base.HttpApplication);
            }
            catch (MissingSslCertificateException)
            {
                throw new HttpException(302, AspNetHelper.GetCafeErrorPageRedirectUrl(httpContext, new NameValueCollection
                {
                    {
                        "CafeError",
                        ErrorFE.FEErrorCodes.NoFbaSSL.ToString()
                    }
                }));
            }
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "FbaFormPostProxyRequestHandler - redirecting to {0}", text);
            }
            base.PfdTracer.TraceRedirect("FbaAuth", text);
            response.Redirect(FbaFormPostProxyRequestHandler.CheckRedirectUrlForNewline(text), false);
        }