Ejemplo n.º 1
0
        // Token: 0x060004E9 RID: 1257 RVA: 0x0001B2AC File Offset: 0x000194AC
        private static string GetBackendFqdnFromE4eCookie(HttpRequest request, RequestDetailsLogger logger)
        {
            HttpCookie httpCookie = request.Cookies["X-E4eBackEnd"];

            if (httpCookie == null)
            {
                return(null);
            }
            string value = httpCookie.Value;

            if (string.IsNullOrEmpty(value))
            {
                logger.AppendGenericError("E4eBeCookieNullOrEmpty", "The E4E backend cookie hint was found but is null or empty.");
                return(null);
            }
            string[] array = httpCookie.Value.Split(new char[]
            {
                '~'
            });
            if (array.Length != 2)
            {
                logger.AppendGenericError("E4eBeCookieBadValue", string.Format("The E4E backend cookie hint was found but does not have expected value. Actual value [{0}]", value));
                return(null);
            }
            string value2           = array[0];
            string result           = array[1];
            string itemIdFromCookie = E4eProxyRequestHandler.GetItemIdFromCookie(request);

            if (string.IsNullOrEmpty(itemIdFromCookie) || !itemIdFromCookie.Equals(value2, StringComparison.OrdinalIgnoreCase))
            {
                logger.AppendGenericInfo("E4eBeCookieStale", string.Format("The E4E backend cookie hint was found but does not match current item id. Cookie value [{0}], current item ID [{1}]", value, itemIdFromCookie));
                return(null);
            }
            return(result);
        }
Ejemplo n.º 2
0
        // Token: 0x060004E0 RID: 1248 RVA: 0x0001B06C File Offset: 0x0001926C
        private static bool IsE4ePostOrRetrievePayloadRequest(HttpRequest request)
        {
            bool flag  = request.HttpMethod.Equals(HttpMethod.Post.ToString(), StringComparison.OrdinalIgnoreCase) && E4eProxyRequestHandler.IsE4ePayloadRequest(request);
            bool flag2 = E4eProxyRequestHandler.IsRESTAPIUploadRequset(request);
            bool flag3 = E4eProxyRequestHandler.IsE4eRetrieveRequest(request);

            return(flag || flag2 || flag3);
        }
Ejemplo n.º 3
0
 // Token: 0x060004ED RID: 1261 RVA: 0x0001B554 File Offset: 0x00019754
 private void UpdateBackoffCache()
 {
     if (E4eProxyRequestHandler.IsE4ePostOrRetrievePayloadRequest(base.ClientRequest))
     {
         string serverResponseCookieValue  = this.GetServerResponseCookieValue("X-E4eBudgetType");
         string serverResponseCookieValue2 = this.GetServerResponseCookieValue("X-E4eEmailAddress");
         string serverResponseCookieValue3 = this.GetServerResponseCookieValue("X-E4eBackOffUntilUtc");
         E4eBackoffListCache.Instance.UpdateCache(serverResponseCookieValue, serverResponseCookieValue2, serverResponseCookieValue3);
     }
 }
Ejemplo n.º 4
0
        // Token: 0x060004DC RID: 1244 RVA: 0x0001ADF8 File Offset: 0x00018FF8
        protected override bool HandleBackEndCalculationException(Exception exception, AnchorMailbox anchorMailbox, string label)
        {
            HttpProxyException ex = exception as HttpProxyException;

            if (ex != null && ex.ErrorCode == 3009)
            {
                HttpException exception2 = new HttpException(302, E4eProxyRequestHandler.GetErrorUrl(E4eProxyRequestHandler.E4eErrorType.OrgNotExisting));
                return(base.HandleBackEndCalculationException(exception2, anchorMailbox, label));
            }
            return(base.HandleBackEndCalculationException(exception, anchorMailbox, label));
        }
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (E4eProxyRequestHandler.IsErrorPageRequest(base.ClientRequest))
            {
                return(new AnonymousAnchorMailbox(this));
            }
            if (E4eProxyRequestHandler.IsE4eInvalidStoreRequest(base.ClientRequest))
            {
                this.ThrowRedirectException(E4eProxyRequestHandler.GetErrorUrl(E4eProxyRequestHandler.E4eErrorType.InvalidStoreRequest));
            }
            bool flag = E4eProxyRequestHandler.IsE4ePostPayloadRequest(base.ClientRequest);

            this.GetSenderInfo(flag);
            string text = this.senderEmailAddress;

            if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text))
            {
                string recipientEmailAddress = base.ClientRequest.QueryString["RecipientEmailAddress"];
                if (flag)
                {
                    if (E4eBackoffListCache.Instance.ShouldBackOff(text, recipientEmailAddress))
                    {
                        PerfCounters.HttpProxyCountersInstance.RejectedConnectionCount.Increment();
                        this.ThrowRedirectException(E4eProxyRequestHandler.GetErrorUrl(E4eProxyRequestHandler.E4eErrorType.ThrottlingRestriction));
                    }
                    else
                    {
                        PerfCounters.HttpProxyCountersInstance.AcceptedConnectionCount.Increment();
                    }
                }
                return(new SmtpWithDomainFallbackAnchorMailbox(text, this)
                {
                    UseServerCookie = true
                });
            }
            if (BEResourceRequestHandler.IsResourceRequest(base.ClientRequest.Url.LocalPath))
            {
                return(new AnonymousAnchorMailbox(this));
            }
            string text2 = string.Format("The sender's email address is not valid. Email={0}, SMTP={1}", this.senderEmailAddress, text);

            base.Logger.AppendGenericError("Invalid sender email address", text2);
            throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.EndpointNotFound, text2);
        }
Ejemplo n.º 6
0
 // Token: 0x060004DE RID: 1246 RVA: 0x0001AE80 File Offset: 0x00019080
 protected override void CopySupplementalCookiesToClientResponse()
 {
     this.UpdateBackoffCache();
     if (!string.IsNullOrEmpty(this.senderEmailAddress))
     {
         HttpCookie httpCookie = new HttpCookie("X-SenderEmailAddress", this.senderEmailAddress);
         httpCookie.HttpOnly = true;
         httpCookie.Secure   = base.ClientRequest.IsSecureConnection;
         base.ClientResponse.Cookies.Add(httpCookie);
     }
     if (!string.IsNullOrEmpty(this.senderOrganization))
     {
         HttpCookie httpCookie2 = new HttpCookie("X-SenderOrganization", this.senderOrganization);
         httpCookie2.HttpOnly = true;
         httpCookie2.Secure   = base.ClientRequest.IsSecureConnection;
         base.ClientResponse.Cookies.Add(httpCookie2);
     }
     if (!string.IsNullOrWhiteSpace(this.routingEmailAddress))
     {
         HttpCookie httpCookie3 = new HttpCookie("X-RoutingEmailAddress", this.routingEmailAddress);
         httpCookie3.HttpOnly = true;
         httpCookie3.Secure   = base.ClientRequest.IsSecureConnection;
         base.ClientResponse.Cookies.Add(httpCookie3);
         HttpCookie httpCookie4 = new HttpCookie("DefaultAnchorMailbox", this.routingEmailAddress);
         httpCookie4.HttpOnly = true;
         httpCookie4.Secure   = base.ClientRequest.IsSecureConnection;
         base.ClientResponse.Cookies.Add(httpCookie4);
     }
     if (base.AnchoredRoutingTarget != null && E4eProxyRequestHandler.IsE4ePostOrRetrievePayloadRequest(base.ClientRequest) && this.IsBackEndCookieAndHeaderFlightEnabled())
     {
         string itemIdFromCookie = E4eProxyRequestHandler.GetItemIdFromCookie(base.ServerResponse);
         if (itemIdFromCookie != null)
         {
             string     fqdn        = base.AnchoredRoutingTarget.BackEndServer.Fqdn;
             string     value       = string.Format("{0}{1}{2}", itemIdFromCookie, '~', fqdn);
             HttpCookie httpCookie5 = new HttpCookie("X-E4eBackEnd", value);
             httpCookie5.HttpOnly = true;
             httpCookie5.Secure   = base.ClientRequest.IsSecureConnection;
             base.ClientResponse.Cookies.Add(httpCookie5);
         }
     }
     base.CopySupplementalCookiesToClientResponse();
 }
Ejemplo n.º 7
0
        // Token: 0x060004DB RID: 1243 RVA: 0x0001ABB0 File Offset: 0x00018DB0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (E4eProxyRequestHandler.IsAnonymousErrorPageRequest(base.ClientRequest) || E4eProxyRequestHandler.IsAnonymousAppRedirectPageRequest(base.ClientRequest) || E4eProxyRequestHandler.IsAnonymousAppFeedbackRequest(base.ClientRequest))
            {
                return(new AnonymousAnchorMailbox(this));
            }
            if (E4eProxyRequestHandler.IsE4eInvalidStoreRequest(base.ClientRequest))
            {
                this.ThrowRedirectException(E4eProxyRequestHandler.GetErrorUrl(E4eProxyRequestHandler.E4eErrorType.InvalidStoreRequest));
            }
            bool flag  = E4eProxyRequestHandler.IsE4ePostOrRetrievePayloadRequest(base.ClientRequest);
            bool flag2 = this.IsWACRequest();

            this.GetSenderInfo(flag, flag2);
            string text = this.routingEmailAddress;

            if (E4eProxyRequestHandler.IsRESTAPIUploadRequset(base.ClientRequest) && string.IsNullOrEmpty(text))
            {
                return(new AnonymousAnchorMailbox(this));
            }
            if (string.IsNullOrEmpty(text) || !SmtpAddress.IsValidSmtpAddress(text))
            {
                if (BEResourceRequestHandler.IsResourceRequest(base.ClientRequest.Url.LocalPath))
                {
                    return(new AnonymousAnchorMailbox(this));
                }
                string text2 = string.Format("The routing email address is not valid. Email={0}", text);
                base.Logger.AppendGenericError("Invalid routing email address", text2);
                throw new HttpProxyException(HttpStatusCode.NotFound, 3001, text2);
            }
            else
            {
                if (flag)
                {
                    string recipientEmailAddress = base.ClientRequest.QueryString["RecipientEmailAddress"];
                    if (E4eBackoffListCache.Instance.ShouldBackOff(this.senderEmailAddress, recipientEmailAddress))
                    {
                        PerfCounters.HttpProxyCountersInstance.RejectedConnectionCount.Increment();
                        this.ThrowRedirectException(E4eProxyRequestHandler.GetErrorUrl(E4eProxyRequestHandler.E4eErrorType.ThrottlingRestriction));
                    }
                    else
                    {
                        PerfCounters.HttpProxyCountersInstance.AcceptedConnectionCount.Increment();
                    }
                }
                if (!this.IsBackEndCookieAndHeaderFlightEnabled())
                {
                    return(this.GetAnchorMailbox());
                }
                if (flag)
                {
                    string text3 = base.ClientRequest.Headers["X-E4ePostToBackEnd"];
                    if (!string.IsNullOrEmpty(text3))
                    {
                        return(new ServerInfoAnchorMailbox(text3, this));
                    }
                    return(this.GetAnchorMailbox());
                }
                else if (flag2)
                {
                    string text4;
                    string text5;
                    if (!this.GetRoutingInformationForWac(out text4, out text5))
                    {
                        base.Logger.AppendGenericError("E4EWacRequest", "Invalid routing information for request coming from WAC server, url:" + base.ClientRequest.Url);
                        return(this.GetAnchorMailbox());
                    }
                    AnchorMailbox result = new ServerInfoAnchorMailbox(text4, this);
                    base.Logger.AppendGenericInfo("E4eBEServerCookieHint", string.Format("Using BE server cookie hint. Cookie value [{0}]", text4));
                    return(result);
                }
                else
                {
                    if (!E4eProxyRequestHandler.IsRequestBoundToBEServer(base.ClientRequest))
                    {
                        return(this.GetAnchorMailbox());
                    }
                    string backendFqdnFromE4eCookie = E4eProxyRequestHandler.GetBackendFqdnFromE4eCookie(base.ClientRequest, base.Logger);
                    if (string.IsNullOrEmpty(backendFqdnFromE4eCookie))
                    {
                        return(this.GetAnchorMailbox());
                    }
                    AnchorMailbox result2 = new ServerInfoAnchorMailbox(backendFqdnFromE4eCookie, this);
                    base.Logger.AppendGenericInfo("E4eBEServerCookieHint", string.Format("Using BE server cookie hint. Cookie value [{0}]", backendFqdnFromE4eCookie));
                    return(result2);
                }
            }
        }
Ejemplo n.º 8
0
 // Token: 0x060004E7 RID: 1255 RVA: 0x0001B22D File Offset: 0x0001942D
 private static bool IsRequestBoundToBEServer(HttpRequest request)
 {
     return(!E4eProxyRequestHandler.IsErrorPageRequest(request) && !BEResourceRequestHandler.IsResourceRequest(request.Url.LocalPath));
 }
Ejemplo n.º 9
0
 // Token: 0x060004E4 RID: 1252 RVA: 0x0001B170 File Offset: 0x00019370
 private static bool IsAnonymousErrorPageRequest(HttpRequest request)
 {
     E4eProxyRequestHandler.E4eErrorType e4eErrorType;
     return(E4eProxyRequestHandler.IsErrorPageRequest(request) && Enum.TryParse <E4eProxyRequestHandler.E4eErrorType>(request.QueryString["code"], true, out e4eErrorType) && (e4eErrorType == E4eProxyRequestHandler.E4eErrorType.OrgNotExisting || e4eErrorType == E4eProxyRequestHandler.E4eErrorType.InvalidStoreRequest));
 }
Ejemplo n.º 10
0
 // Token: 0x060004E2 RID: 1250 RVA: 0x0001B0FC File Offset: 0x000192FC
 private static bool IsE4eInvalidStoreRequest(HttpRequest request)
 {
     return(request.HttpMethod.Equals(HttpMethod.Get.ToString(), StringComparison.OrdinalIgnoreCase) && E4eProxyRequestHandler.IsE4ePayloadRequest(request));
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        private IHttpHandler SelectHandlerForAuthenticatedRequest(HttpContext httpContext)
        {
            IHttpHandler result;

            try
            {
                IHttpHandler httpHandler;
                if (HttpProxyGlobals.ProtocolType == ProtocolType.Mapi)
                {
                    httpHandler = new MapiProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Ecp)
                {
                    if (SiteMailboxCreatingProxyRequestHandler.IsSiteMailboxCreatingProxyRequest(httpContext.Request))
                    {
                        httpHandler = new SiteMailboxCreatingProxyRequestHandler();
                    }
                    else if (EDiscoveryExportToolProxyRequestHandler.IsEDiscoveryExportToolProxyRequest(httpContext.Request))
                    {
                        httpHandler = new EDiscoveryExportToolProxyRequestHandler();
                    }
                    else if (BEResourceRequestHandler.CanHandle(httpContext.Request))
                    {
                        httpHandler = new BEResourceRequestHandler();
                    }
                    else
                    {
                        httpHandler = new EcpProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Autodiscover)
                {
                    httpHandler = new AutodiscoverProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Ews)
                {
                    if (EwsUserPhotoProxyRequestHandler.IsUserPhotoRequest(httpContext.Request))
                    {
                        httpHandler = new EwsUserPhotoProxyRequestHandler();
                    }
                    else if (EwsODataProxyRequestHandler.IsODataRequest(httpContext.Request))
                    {
                        httpHandler = new EwsODataProxyRequestHandler();
                    }
                    else if (MrsProxyRequestHandler.IsMrsRequest(httpContext.Request))
                    {
                        httpHandler = new MrsProxyRequestHandler();
                    }
                    else if (MessageTrackingRequestHandler.IsMessageTrackingRequest(httpContext.Request))
                    {
                        httpHandler = new MessageTrackingRequestHandler();
                    }
                    else
                    {
                        httpHandler = new EwsProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.RpcHttp)
                {
                    if (RpcHttpRequestHandler.CanHandleRequest(httpContext.Request))
                    {
                        httpHandler = new RpcHttpRequestHandler();
                    }
                    else
                    {
                        httpHandler = new RpcHttpProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Eas)
                {
                    httpHandler = new EasProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Oab)
                {
                    httpHandler = new OabProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.PowerShell || HttpProxyGlobals.ProtocolType == ProtocolType.PowerShellLiveId)
                {
                    httpHandler = new RemotePowerShellProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.ReportingWebService)
                {
                    httpHandler = new ReportingWebServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Psws)
                {
                    httpHandler = new PswsProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Xrop)
                {
                    httpHandler = new XRopProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.Owa)
                {
                    string absolutePath = httpContext.Request.Url.AbsolutePath;
                    if (OWAUserPhotoProxyRequestHandler.IsUserPhotoRequest(httpContext.Request))
                    {
                        httpHandler = new OWAUserPhotoProxyRequestHandler();
                    }
                    else if (absolutePath.EndsWith("service.svc", StringComparison.OrdinalIgnoreCase) || absolutePath.IndexOf("/service.svc/", StringComparison.OrdinalIgnoreCase) != -1)
                    {
                        httpHandler = new EwsJsonProxyRequestHandler();
                    }
                    else if (absolutePath.EndsWith("ev.owa2", StringComparison.OrdinalIgnoreCase))
                    {
                        httpHandler = new OwaOeh2ProxyRequestHandler();
                    }
                    else if (absolutePath.EndsWith("speech.reco", StringComparison.OrdinalIgnoreCase))
                    {
                        httpHandler = new SpeechRecoProxyRequestHandler();
                    }
                    else if (absolutePath.EndsWith("lang.owa", StringComparison.OrdinalIgnoreCase))
                    {
                        httpHandler = new OwaLanguagePostProxyRequestHandler();
                    }
                    else if (absolutePath.EndsWith("ev.owa", StringComparison.OrdinalIgnoreCase) && httpContext.Request.RawUrl.IndexOf("ns=EwsProxy", StringComparison.OrdinalIgnoreCase) > 0)
                    {
                        httpHandler = new EwsProxyRequestHandler(true);
                    }
                    else
                    {
                        httpHandler = new OwaProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.PushNotifications)
                {
                    httpHandler = new PushNotificationsProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.OutlookService)
                {
                    httpHandler = new OutlookServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.SnackyService)
                {
                    httpHandler = new SnackyServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == ProtocolType.E4e)
                {
                    httpHandler = new E4eProxyRequestHandler();
                }
                else
                {
                    if (HttpProxyGlobals.ProtocolType != ProtocolType.O365SuiteService)
                    {
                        throw new InvalidOperationException("Unknown protocol type " + HttpProxyGlobals.ProtocolType);
                    }
                    httpHandler = new O365SuiteServiceProxyRequestHandler();
                }
                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);
        }
Ejemplo n.º 13
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)));
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        // Token: 0x060005F4 RID: 1524 RVA: 0x000213C0 File Offset: 0x0001F5C0
        private IHttpHandler SelectHandlerForAuthenticatedRequest(HttpContext httpContext)
        {
            IHttpHandler result;

            try
            {
                IHttpHandler httpHandler;
                if (HttpProxyGlobals.ProtocolType == 14)
                {
                    httpHandler = new MapiProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 1)
                {
                    if (SiteMailboxCreatingProxyRequestHandler.IsSiteMailboxCreatingProxyRequest(httpContext.Request))
                    {
                        httpHandler = new SiteMailboxCreatingProxyRequestHandler();
                    }
                    else if (EDiscoveryExportToolProxyRequestHandler.IsEDiscoveryExportToolProxyRequest(httpContext.Request))
                    {
                        httpHandler = new EDiscoveryExportToolProxyRequestHandler();
                    }
                    else if (BEResourceRequestHandler.CanHandle(httpContext.Request))
                    {
                        httpHandler = new BEResourceRequestHandler();
                    }
                    else
                    {
                        httpHandler = new EcpProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == 9)
                {
                    httpHandler = new AutodiscoverProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 2)
                {
                    if (EwsUserPhotoProxyRequestHandler.IsUserPhotoRequest(httpContext.Request))
                    {
                        httpHandler = new EwsUserPhotoProxyRequestHandler();
                    }
                    else if (MrsProxyRequestHandler.IsMrsRequest(httpContext.Request))
                    {
                        httpHandler = new MrsProxyRequestHandler();
                    }
                    else if (MessageTrackingRequestHandler.IsMessageTrackingRequest(httpContext.Request))
                    {
                        httpHandler = new MessageTrackingRequestHandler();
                    }
                    else
                    {
                        httpHandler = new EwsProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == 27)
                {
                    httpHandler = new RestProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 8)
                {
                    if (RpcHttpRequestHandler.CanHandleRequest(httpContext.Request))
                    {
                        httpHandler = new RpcHttpRequestHandler();
                    }
                    else
                    {
                        httpHandler = new RpcHttpProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == null)
                {
                    httpHandler = new EasProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 3)
                {
                    httpHandler = new OabProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 6 || HttpProxyGlobals.ProtocolType == 7)
                {
                    httpHandler = new RemotePowerShellProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 10)
                {
                    httpHandler = new ReportingWebServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 11)
                {
                    httpHandler = new PswsProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 12)
                {
                    httpHandler = new XRopProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 4)
                {
                    string absolutePath = httpContext.Request.Url.AbsolutePath;
                    if (OWAUserPhotoProxyRequestHandler.IsUserPhotoRequest(httpContext.Request))
                    {
                        httpHandler = new OWAUserPhotoProxyRequestHandler();
                    }
                    else if (RequestPathParser.IsOwaEwsJsonRequest(absolutePath))
                    {
                        httpHandler = new EwsJsonProxyRequestHandler();
                    }
                    else if (RequestPathParser.IsOwaOeh2Request(absolutePath))
                    {
                        httpHandler = new OwaOeh2ProxyRequestHandler();
                    }
                    else if (RequestPathParser.IsOwaSpeechRecoRequest(absolutePath))
                    {
                        httpHandler = new SpeechRecoProxyRequestHandler();
                    }
                    else if (RequestPathParser.IsOwaLanguagePostRequest(absolutePath))
                    {
                        httpHandler = new OwaLanguagePostProxyRequestHandler();
                    }
                    else if (RequestPathParser.IsOwaE14ProxyRequest(absolutePath, httpContext.Request.RawUrl))
                    {
                        httpHandler = new EwsProxyRequestHandler(true);
                    }
                    else if (AuthenticatedWopiRequestPathHandler.IsAuthenticatedWopiRequest(httpContext.Request, AuthCommon.IsFrontEnd))
                    {
                        httpHandler = new AuthenticatedWopiProxyRequestHandler();
                    }
                    else
                    {
                        httpHandler = new OwaProxyRequestHandler();
                    }
                }
                else if (HttpProxyGlobals.ProtocolType == 13)
                {
                    httpHandler = new PushNotificationsProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 16)
                {
                    httpHandler = new OutlookServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 17)
                {
                    httpHandler = new SnackyServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 18)
                {
                    httpHandler = new MicroServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 15)
                {
                    httpHandler = new E4eProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 20)
                {
                    httpHandler = new O365SuiteServiceProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 21)
                {
                    httpHandler = new MailboxDeliveryProxyRequestHandler();
                }
                else if (HttpProxyGlobals.ProtocolType == 22)
                {
                    httpHandler = new ComplianceServiceProxyRequestHandler();
                }
                else
                {
                    if (HttpProxyGlobals.ProtocolType != 24)
                    {
                        throw new InvalidOperationException("Unknown protocol type " + HttpProxyGlobals.ProtocolType);
                    }
                    httpHandler = new LogExportProxyHandler();
                }
                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);
        }
Ejemplo n.º 16
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));
        }