protected override Uri GetTargetBackEndServerUrl()
        {
            Uri uri = base.GetTargetBackEndServerUrl();

            if (base.AnchoredRoutingTarget.BackEndServer.Version < Server.E15MinVersion)
            {
                throw new HttpException(500, string.Format("Version < E14 and a WOPI request?  Should not happen....  AnchorMailbox: {0}", base.AnchoredRoutingTarget.AnchorMailbox));
            }
            if (uri.Query.Length == 0)
            {
                throw new HttpException(400, "Unexpected query string format");
            }
            if (!string.IsNullOrEmpty(this.targetMailboxId))
            {
                UriBuilder uriBuilder = new UriBuilder(uri);
                uriBuilder.Path  = WopiRequestPathHandler.StripEmailAddress(HttpUtility.UrlDecode(uriBuilder.Path), this.targetMailboxId);
                uriBuilder.Query = uri.Query.Substring(1) + "&UserEmail=" + HttpUtility.UrlEncode(this.targetMailboxId);
                uri = uriBuilder.Uri;
            }
            if (HttpProxySettings.DFPOWAVdirProxyEnabled.Value)
            {
                return(UrlUtilities.FixDFPOWAVdirUrlForBackEnd(uri, HttpUtility.ParseQueryString(uri.Query)["vdir"]));
            }
            return(uri);
        }
        // Token: 0x0600073D RID: 1853 RVA: 0x0002A870 File Offset: 0x00028A70
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            string mailboxId = WopiRequestPathHandler.GetMailboxId(base.ClientRequest);

            if (!string.IsNullOrEmpty(mailboxId))
            {
                this.targetMailboxId = mailboxId;
                AnchorMailbox result;
                if (AnchorMailboxFactory.TryCreateFromMailboxGuid(this, mailboxId, out result))
                {
                    return(result);
                }
                if (SmtpAddress.IsValidSmtpAddress(mailboxId))
                {
                    base.Logger.Set(3, "Url-SMTP");
                    return(new SmtpAnchorMailbox(mailboxId, this));
                }
            }
            return(base.ResolveAnchorMailbox());
        }
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url);

            uriBuilder.Scheme = "https";
            uriBuilder.Port   = 444;
            string userEmailAddress = WopiRequestPathHandler.GetUserEmailAddress(base.ClientRequest);

            if (string.IsNullOrEmpty(userEmailAddress))
            {
                return(base.ResolveAnchorMailbox());
            }
            this.targetMailboxId = userEmailAddress;
            AnchorMailbox result;

            if (AnchorMailboxFactory.TryCreateFromMailboxGuid(this, userEmailAddress, out result))
            {
                return(result);
            }
            base.Logger.Set(HttpProxyMetadata.RoutingHint, "Url-SMTP");
            return(new SmtpAnchorMailbox(userEmailAddress, this));
        }
Пример #4
0
        // Token: 0x060005F1 RID: 1521 RVA: 0x000210E0 File Offset: 0x0001F2E0
        protected virtual bool AllowAnonymousRequest(HttpRequest httpRequest)
        {
            if (HttpProxyGlobals.ProtocolType == 14)
            {
                return(false);
            }
            if (HttpProxyGlobals.ProtocolType == 21)
            {
                return(true);
            }
            if (HttpProxyGlobals.ProtocolType == 22)
            {
                return(true);
            }
            UriBuilder uriBuilder = new UriBuilder(httpRequest.Url);
            string     text       = null;

            if (UrlUtilities.TryGetExplicitLogonUser(httpRequest, ref text))
            {
                uriBuilder.Path = UrlUtilities.GetPathWithExplictLogonHint(httpRequest.Url, text);
            }
            return(WopiRequestPathHandler.IsWopiRequest(httpRequest.HttpMethod, httpRequest.Url, AuthCommon.IsFrontEnd) || AnonymousCalendarProxyRequestHandler.IsAnonymousCalendarRequest(httpRequest) || OwaExtensibilityProxyRequestHandler.IsOwaExtensibilityRequest(httpRequest) || UrlUtilities.IsOwaDownloadRequest(uriBuilder.Uri) || OwaCobrandingRedirProxyRequestHandler.IsCobrandingRedirRequest(httpRequest) || E4eProxyRequestHandler.IsE4ePayloadRequest(httpRequest) || httpRequest.IsWsSecurityRequest() || PsgwProxyRequestHandler.IsPsgwRequest(httpRequest));
        }
Пример #5
0
        private IHttpHandler SelectHandlerForUnauthenticatedRequest(HttpContext httpContext)
        {
            IHttpHandler result;

            try
            {
                IHttpHandler httpHandler = null;
                if (HttpProxyGlobals.ProtocolType == ProtocolType.Autodiscover)
                {
                    if (httpContext.Request.HttpMethod.Equals("GET", StringComparison.OrdinalIgnoreCase))
                    {
                        if (ProtocolHelper.IsOAuthMetadataRequest(httpContext.Request.Url.AbsolutePath))
                        {
                            httpHandler = new AuthMetadataHttpHandler(httpContext);
                        }
                        else if (ProtocolHelper.IsAutodiscoverV2Request(httpContext.Request.Url.AbsolutePath))
                        {
                            httpHandler = new AutodiscoverProxyRequestHandler();
                        }
                    }
                    else
                    {
                        httpHandler = new AutodiscoverProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Ews)
                {
                    string httpMethod = httpContext.Request.HttpMethod;
                    if (!httpMethod.Equals("GET", StringComparison.OrdinalIgnoreCase) && !httpMethod.Equals("HEAD", StringComparison.OrdinalIgnoreCase))
                    {
                        httpHandler = new EwsProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Ecp)
                {
                    if (EDiscoveryExportToolProxyRequestHandler.IsEDiscoveryExportToolProxyRequest(httpContext.Request))
                    {
                        httpHandler = new EDiscoveryExportToolProxyRequestHandler();
                    }
                    else if (BEResourceRequestHandler.CanHandle(httpContext.Request))
                    {
                        httpHandler = new BEResourceRequestHandler();
                    }
                    else if (EcpProxyRequestHandler.IsCrossForestDelegatedRequest(httpContext.Request))
                    {
                        httpHandler = new EcpProxyRequestHandler
                        {
                            IsCrossForestDelegated = true
                        };
                    }
                    else if (!httpContext.Request.Path.StartsWith("/ecp/auth/", StringComparison.OrdinalIgnoreCase) && !httpContext.Request.Path.Equals("/ecp/ping.ecp", StringComparison.OrdinalIgnoreCase))
                    {
                        httpHandler = new Return401RequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.RpcHttp)
                {
                    httpHandler = new RpcHttpRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Xrop)
                {
                    httpHandler = new XRopProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.E4e)
                {
                    httpHandler = new E4eProxyRequestHandler();
                }
                else if (AnonymousCalendarProxyRequestHandler.IsAnonymousCalendarRequest(httpContext.Request))
                {
                    httpHandler = new AnonymousCalendarProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Owa && WopiRequestPathHandler.IsWopiRequest(httpContext.Request, AuthCommon.IsFrontEnd))
                {
                    httpHandler = new WopiProxyRequestHandler();
                }
                else if (OwaExtensibilityProxyRequestHandler.IsOwaExtensibilityRequest(httpContext.Request))
                {
                    httpHandler = new OwaExtensibilityProxyRequestHandler();
                }
                else if (OwaCobrandingRedirProxyRequestHandler.IsCobrandingRedirRequest(httpContext.Request))
                {
                    httpHandler = new OwaCobrandingRedirProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Owa && OwaResourceProxyRequestHandler.CanHandle(httpContext.Request))
                {
                    httpHandler = new OwaResourceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.PowerShellGateway)
                {
                    httpHandler = new PsgwProxyRequestHandler();
                }
                result = httpHandler;
            }
            finally
            {
                long currentLatency = LatencyTracker.FromHttpContext(httpContext).GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency);
                if (currentLatency > 100L)
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), "SelectHandler", currentLatency);
                }
            }
            return(result);
        }
Пример #6
0
 protected virtual bool AllowAnonymousRequest(HttpRequest httpRequest)
 {
     return(HttpProxyGlobals.ProtocolType != ProtocolType.Mapi && (WopiRequestPathHandler.IsWopiRequest(httpRequest, AuthCommon.IsFrontEnd) || AnonymousCalendarProxyRequestHandler.IsAnonymousCalendarRequest(httpRequest) || OwaExtensibilityProxyRequestHandler.IsOwaExtensibilityRequest(httpRequest) || OwaCobrandingRedirProxyRequestHandler.IsCobrandingRedirRequest(httpRequest) || E4eProxyRequestHandler.IsE4ePayloadRequest(httpRequest) || httpRequest.IsWsSecurityRequest() || PsgwProxyRequestHandler.IsPsgwRequest(httpRequest)));
 }
Пример #7
0
        // Token: 0x060005F5 RID: 1525 RVA: 0x00021738 File Offset: 0x0001F938
        private IHttpHandler SelectHandlerForUnauthenticatedRequest(HttpContext httpContext)
        {
            IHttpHandler result;

            try
            {
                if (HttpProxySettings.NeedHandleAsAuthenticatedRequest(httpContext.Request.Headers, httpContext.Request.Cookies, httpContext.SkipAuthorization))
                {
                    result = this.SelectHandlerForAuthenticatedRequest(httpContext);
                }
                else
                {
                    UriBuilder uriBuilder = new UriBuilder(httpContext.Request.Url);
                    string     text       = null;
                    if (UrlUtilities.TryGetExplicitLogonUser(httpContext.Request, ref text))
                    {
                        uriBuilder.Path = UrlUtilities.GetPathWithExplictLogonHint(httpContext.Request.Url, text);
                    }
                    IHttpHandler httpHandler = null;
                    if (HttpProxyGlobals.ProtocolType == 9)
                    {
                        httpHandler = new AutodiscoverProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 2)
                    {
                        if (RequestPathParser.IsEwsUnauthenticatedRequestProxyHandlerAllowed(httpContext.Request))
                        {
                            httpHandler = new EwsProxyRequestHandler();
                        }
                    }
                    else if (HttpProxyGlobals.ProtocolType == 27)
                    {
                        if (RequestPathParser.IsRestUnauthenticatedRequestProxyHandlerAllowed(httpContext.Request))
                        {
                            httpHandler = new RestProxyRequestHandler();
                        }
                    }
                    else if (HttpProxyGlobals.ProtocolType == 1)
                    {
                        if (EDiscoveryExportToolProxyRequestHandler.IsEDiscoveryExportToolProxyRequest(httpContext.Request))
                        {
                            httpHandler = new EDiscoveryExportToolProxyRequestHandler();
                        }
                        else if (BEResourceRequestHandler.CanHandle(httpContext.Request))
                        {
                            httpHandler = new BEResourceRequestHandler();
                        }
                        else if (EcpProxyRequestHandler.IsCrossForestDelegatedRequest(httpContext.Request))
                        {
                            httpHandler = new EcpProxyRequestHandler
                            {
                                IsCrossForestDelegated = true
                            };
                        }
                        else if (!httpContext.Request.Path.StartsWith("/ecp/auth/", StringComparison.OrdinalIgnoreCase) && !httpContext.Request.Path.Equals("/ecp/ping.ecp", StringComparison.OrdinalIgnoreCase))
                        {
                            httpHandler = new Return401RequestHandler();
                        }
                    }
                    else if (HttpProxyGlobals.ProtocolType == 8)
                    {
                        httpHandler = new RpcHttpRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 12)
                    {
                        httpHandler = new XRopProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 15)
                    {
                        httpHandler = new E4eProxyRequestHandler();
                    }
                    else if (AnonymousCalendarProxyRequestHandler.IsAnonymousCalendarRequest(httpContext.Request))
                    {
                        httpHandler = new AnonymousCalendarProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 4 && WopiRequestPathHandler.IsWopiRequest(httpContext.Request.HttpMethod, httpContext.Request.Url, AuthCommon.IsFrontEnd))
                    {
                        httpHandler = new WopiProxyRequestHandler();
                    }
                    else if (OwaExtensibilityProxyRequestHandler.IsOwaExtensibilityRequest(httpContext.Request))
                    {
                        httpHandler = new OwaExtensibilityProxyRequestHandler();
                    }
                    else if (UrlUtilities.IsOwaDownloadRequest(uriBuilder.Uri))
                    {
                        httpHandler = new OwaDownloadProxyRequestHandler();
                    }
                    else if (OwaCobrandingRedirProxyRequestHandler.IsCobrandingRedirRequest(httpContext.Request))
                    {
                        httpHandler = new OwaCobrandingRedirProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 4 && OwaResourceProxyRequestHandler.CanHandle(httpContext.Request))
                    {
                        httpHandler = new OwaResourceProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 19)
                    {
                        httpHandler = new PsgwProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 21)
                    {
                        httpHandler = new MailboxDeliveryProxyRequestHandler();
                    }
                    else if (HttpProxyGlobals.ProtocolType == 22)
                    {
                        httpHandler = new ComplianceServiceProxyRequestHandler();
                    }
                    result = httpHandler;
                }
            }
            finally
            {
                long currentLatency = LatencyTracker.FromHttpContext(httpContext).GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency);
                if (currentLatency > 100L)
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), "SelectHandler", currentLatency);
                }
            }
            return(result);
        }