private static Uri FindRedirectOwaUrlCrossSite(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause)
        {
            failureCause     = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None;
            isSameAuthMethod = false;
            bool            isSameAuthExternalService = false;
            OwaService      clientExternalService     = null;
            ServiceTopology currentServiceTopology    = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 390);
            string          mailboxServerFQDN         = backEndServer.Fqdn;

            new List <OwaService>();
            currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService)
            {
                if (ServiceTopology.IsOnSite(owaService, targetSite, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 401) && owaService.ClientAccessType == ClientAccessType.External)
                {
                    int major = OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major;
                    if (major == expectedMajorVersion)
                    {
                        bool flag = false;
                        if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None && (owaService.AuthenticationMethod & AuthenticationMethod.Fba) != AuthenticationMethod.None))
                        {
                            flag = true;
                            if (!isSameAuthExternalService)
                            {
                                clientExternalService     = null;
                                isSameAuthExternalService = true;
                            }
                        }
                        if (flag || !isSameAuthExternalService)
                        {
                            if (clientExternalService == null)
                            {
                                clientExternalService = owaService;
                                return;
                            }
                            if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 432) < 0)
                            {
                                clientExternalService = owaService;
                            }
                        }
                    }
                }
            }, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlCrossSite", 396);
            if (clientExternalService != null)
            {
                isSameAuthMethod = isSameAuthExternalService;
                return(clientExternalService.Url);
            }
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound;
            return(null);
        }
        // Token: 0x06000556 RID: 1366 RVA: 0x0001D77C File Offset: 0x0001B97C
        private static Uri FindRedirectOwaUrlOnSiteForMismatchVersion(Site targetSite, int expectedMajorVersion, AuthenticationMethod internalAutheticationMethod, AuthenticationMethod externalAuthenticationMethod, BackEndServer backEndServer, out bool isSameAuthMethod, out FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause failureCause)
        {
            failureCause     = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.None;
            isSameAuthMethod = true;
            bool            isSameAuthInternalService = false;
            bool            isSameAuthExternalService = false;
            OwaService      clientInternalService     = null;
            OwaService      clientExternalService     = null;
            string          mailboxServerFQDN         = backEndServer.Fqdn;
            ServiceTopology currentServiceTopology    = ServiceTopology.GetCurrentServiceTopology("d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 578);

            new List <OwaService>();
            currentServiceTopology.ForEach <OwaService>(delegate(OwaService owaService)
            {
                if (ServiceTopology.IsOnSite(owaService, targetSite, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 587))
                {
                    if (owaService.ClientAccessType == 1)
                    {
                        if (OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major == expectedMajorVersion)
                        {
                            bool flag = false;
                            if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & 4) != null && (owaService.AuthenticationMethod & 4) != null))
                            {
                                flag = true;
                                if (!isSameAuthExternalService)
                                {
                                    clientExternalService     = null;
                                    isSameAuthExternalService = true;
                                }
                            }
                            if (flag || !isSameAuthExternalService)
                            {
                                if (clientExternalService == null)
                                {
                                    clientExternalService = owaService;
                                    return;
                                }
                                if (ServiceTopology.CasMbxServicesFirst(owaService, clientExternalService, mailboxServerFQDN, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 618) < 0)
                                {
                                    clientExternalService = owaService;
                                    return;
                                }
                            }
                        }
                    }
                    else if (owaService.ClientAccessType == null && OwaServerVersion.CreateFromVersionNumber(owaService.ServerVersionNumber).Major == expectedMajorVersion && clientExternalService == null)
                    {
                        bool flag = false;
                        if (owaService.AuthenticationMethod == internalAutheticationMethod || ((internalAutheticationMethod & 4) != null && (owaService.AuthenticationMethod & 4) != null))
                        {
                            flag = true;
                            if (!isSameAuthInternalService)
                            {
                                clientInternalService     = null;
                                isSameAuthInternalService = true;
                            }
                        }
                        if (flag || !isSameAuthInternalService)
                        {
                            if (clientInternalService == null)
                            {
                                clientInternalService = owaService;
                                return;
                            }
                            if (ServiceTopology.CasMbxServicesFirst(owaService, clientInternalService, mailboxServerFQDN, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 657) > 0)
                            {
                                clientInternalService = owaService;
                            }
                        }
                    }
                }
            }, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RequestHandlers\\FbaFormPostProxyRequestHandler.cs", "FindRedirectOwaUrlOnSiteForMismatchVersion", 582);
            if (clientExternalService != null)
            {
                isSameAuthMethod = isSameAuthExternalService;
                return(clientExternalService.Url);
            }
            if (clientInternalService != null)
            {
                isSameAuthMethod = isSameAuthInternalService;
                return(clientInternalService.Url);
            }
            failureCause = FbaFormPostProxyRequestHandler.LegacyRedirectFailureCause.NoCasFound;
            return(null);
        }