Beispiel #1
0
 internal static bool TryGetRedirectUri(Uri uri, string canonicalHostname, out Uri redirectUri, out bool isVanityDomainRedirect)
 {
     redirectUri            = null;
     isVanityDomainRedirect = false;
     if (!HttpRedirectCommon.UriIsHttps(uri))
     {
         UriBuilder uriBuilder = new UriBuilder(uri);
         uriBuilder.Scheme = "https";
         uriBuilder.Port   = 443;
         if (string.IsNullOrEmpty(uriBuilder.Path) || uriBuilder.Path == "/")
         {
             uriBuilder.Path = "/owa/";
         }
         if (VanityDomainRedirectModule.IsMissingTrailingSlashRequired(uriBuilder.Path))
         {
             UriBuilder uriBuilder2 = uriBuilder;
             uriBuilder2.Path += "/";
         }
         if (VanityDomainRedirectModule.IsVanityDomain(uri, canonicalHostname))
         {
             isVanityDomainRedirect = true;
             uriBuilder.Host        = canonicalHostname;
             string text  = null;
             string text2 = null;
             string host  = uri.Host;
             int    num   = host.IndexOf('.');
             if (num >= 0)
             {
                 text2 = host.Substring(0, num);
                 text  = host.Substring(num + 1);
             }
             string text3 = null;
             if (!string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(text2))
             {
                 text3 = "realm=" + text + "&vd=" + text2;
             }
             if (!string.IsNullOrEmpty(uriBuilder.Query))
             {
                 uriBuilder.Query = uriBuilder.Query.Substring(1) + "&" + text3;
             }
             else
             {
                 uriBuilder.Query = text3;
             }
         }
         redirectUri = uriBuilder.Uri;
         return(true);
     }
     if (VanityDomainRedirectModule.IsMissingTrailingSlashRequired(uri.LocalPath))
     {
         UriBuilder uriBuilder3 = new UriBuilder(uri);
         UriBuilder uriBuilder4 = uriBuilder3;
         uriBuilder4.Path += "/";
         redirectUri       = uriBuilder3.Uri;
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        private void OnBeginRequestInternal(HttpApplication httpApplication)
        {
            HttpContext context     = httpApplication.Context;
            Uri         url         = context.Request.Url;
            Uri         redirectUri = null;

            if (HttpsRedirectModule.TryGetRedirectUri(url, out redirectUri))
            {
                HttpRedirectCommon.RedirectRequestToNewUri(httpApplication, HttpRedirectCommon.HttpRedirectType.Permanent, redirectUri, "HttpsRedirectUri=");
            }
        }
Beispiel #3
0
        private void OnBeginRequestInternal(HttpApplication httpApplication)
        {
            HttpContext context     = httpApplication.Context;
            Uri         url         = context.Request.Url;
            Uri         redirectUri = null;
            bool        flag        = false;

            if (VanityDomainRedirectModule.TryGetRedirectUri(url, VanityDomainRedirectModule.CanonicalHostNameSetting.Value, out redirectUri, out flag))
            {
                HttpRedirectCommon.RedirectRequestToNewUri(httpApplication, HttpRedirectCommon.HttpRedirectType.Permanent, redirectUri, flag ? "VanityDomainRedirectUri=" : "HttpsRedirectUri=");
            }
        }
Beispiel #4
0
 internal static bool TryGetRedirectUri(Uri uri, out Uri redirectUri)
 {
     redirectUri = null;
     if (HttpRedirectCommon.UriIsHttps(uri))
     {
         return(false);
     }
     redirectUri = new UriBuilder(uri)
     {
         Scheme = "https",
         Port   = 443
     }.Uri;
     return(true);
 }
        private void OnBeginRequestInternal(HttpApplication httpApplication)
        {
            HttpContext context     = httpApplication.Context;
            Uri         url         = context.Request.Url;
            Uri         redirectUri = null;

            if (string.IsNullOrEmpty(AutodiscoverRedirectModule.CanonicalSecureHostNameSetting.Value))
            {
                return;
            }
            if (AutodiscoverRedirectModule.TryGetRedirectUri(url, AutodiscoverRedirectModule.CanonicalSecureHostNameSetting.Value, out redirectUri))
            {
                HttpRedirectCommon.RedirectRequestToNewUri(httpApplication, HttpRedirectCommon.HttpRedirectType.Temporary, redirectUri, "AutodiscoverRedirectUri=");
            }
        }
 internal static bool TryGetRedirectUri(Uri uri, string canonicalSecureHostName, out Uri redirectUri)
 {
     redirectUri = null;
     if (HttpRedirectCommon.UriIsHttps(uri))
     {
         return(false);
     }
     redirectUri = new UriBuilder(uri)
     {
         Host   = canonicalSecureHostName,
         Scheme = "https",
         Port   = 443
     }.Uri;
     return(true);
 }
Beispiel #7
0
        private void OnBeginRequestInternal(HttpApplication httpApplication)
        {
            HttpContext context = httpApplication.Context;
            HttpRequest request = context.Request;

            if (context.Request.IsSecureConnection)
            {
                string       text = request.Url.AbsolutePath ?? string.Empty;
                string       requestPathAndQuery = request.Url.PathAndQuery ?? string.Empty;
                string       text2    = request.Url.AbsoluteUri ?? string.Empty;
                HttpResponse response = context.Response;
                if (OwaJavascriptRedirectModule.gallatinSplashPageEnabled && OwaJavascriptRedirectModule.gallatinSplashPageRequiredForUrl.Equals(text2, StringComparison.OrdinalIgnoreCase))
                {
                    context.Server.TransferRequest("/owa/auth/outlookcn.aspx");
                    return;
                }
                if (string.IsNullOrEmpty(text) || text == "/")
                {
                    if (OfflineClientRequestUtilities.IsRequestForAppCachedVersion(context))
                    {
                        string arg = Uri.EscapeUriString(Uri.UnescapeDataString("/owa/" + context.Request.Url.Query));
                        response.StatusCode  = 200;
                        response.ContentType = "text/html";
                        response.Write(string.Format("<!DOCTYPE html><html><head><script type=\"text/javascript\">window.location.replace(\"{0}\" + window.location.hash);</script></head><body></body></html>", arg));
                        response.AppendToLog("OwaJavascriptRedirectUri=/owa/");
                        httpApplication.CompleteRequest();
                        return;
                    }
                    HttpRedirectCommon.RedirectRequestToNewUri(httpApplication, HttpRedirectCommon.HttpRedirectType.Permanent, new UriBuilder(text2)
                    {
                        Path = "/owa/"
                    }.Uri, "Owa301RedirectUri=");
                    return;
                }
                else
                {
                    string empty = string.Empty;
                    if (OwaJavascriptRedirectModule.TryGetOwa302PathAndQuery(text, requestPathAndQuery, out empty))
                    {
                        response.AppendToLog("Owa302RedirectUri=" + empty);
                        response.Redirect(empty);
                    }
                }
            }
        }