Ejemplo n.º 1
0
        // Token: 0x06000587 RID: 1415 RVA: 0x0001EF50 File Offset: 0x0001D150
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            IIdentity identity = base.HttpContext.User.Identity;
            string    text;

            if (!RequestPathParser.IsRestGroupUserActionRequest(base.ClientRequest.Url.AbsolutePath) && RequestPathParser.TryGetTargetMailbox(base.ClientRequest.Url.PathAndQuery, ref text) && SmtpAddress.IsValidSmtpAddress(text))
            {
                Guid guid;
                Guid guid2;
                if (RequestPathParser.TryParseExternalDirectoryId(text, ref guid, ref guid2))
                {
                    base.Logger.SafeSet(3, "TargetMailbox-ExternalDirectoryObjectId");
                    return(new ExternalDirectoryObjectIdAnchorMailbox(guid.ToString(), guid2, this));
                }
                if (!RequestPathParser.TryParseSpoProxy(text, ref guid2))
                {
                    base.Logger.Set(3, "TargetMailbox-SMTP");
                    return(new SmtpAnchorMailbox(text, this));
                }
                ADRawEntry adrawEntry = DirectoryHelper.ResolveMailboxByProxyAddress(base.LatencyTracker, base.Logger, guid2, text, "SPO");
                if (adrawEntry != null)
                {
                    base.Logger.SafeSet(3, "TargetMailbox-SpoProxy");
                    return(new ProxyAddressAnchorMailbox(adrawEntry, this));
                }
            }
            return(base.ResolveAnchorMailbox());
        }
Ejemplo n.º 2
0
 // Token: 0x060004A1 RID: 1185 RVA: 0x000198AC File Offset: 0x00017AAC
 protected override void DoProtocolSpecificBeginProcess()
 {
     if (!base.ClientRequest.IsAuthenticated)
     {
         try
         {
             if (this.IsSimpleSoapRequest())
             {
                 base.ParseClientRequest <bool>(new Func <Stream, bool>(this.ParseRequest), 81820);
             }
         }
         catch (FormatException innerException)
         {
             throw new HttpException(400, "FormatException parsing Autodiscover request", innerException);
         }
         catch (XmlException innerException2)
         {
             throw new HttpException(400, "XmlException parsing Autodiscover request", innerException2);
         }
         if (!base.IsWsSecurityRequest && !base.IsDomainBasedRequest && !RequestPathParser.IsOAuthMetadataRequest(base.ClientRequest.Url.AbsolutePath) && !RequestPathParser.IsAutodiscoverV2Request(base.ClientRequest.Url.AbsolutePath))
         {
             throw new HttpProxyException(HttpStatusCode.Unauthorized, 4001, "Unauthenticated AutoDiscover request.");
         }
     }
 }
        // Token: 0x0600051F RID: 1311 RVA: 0x0001C974 File Offset: 0x0001AB74
        protected override UriBuilder GetClientUrlForProxy()
        {
            string absoluteUri = base.ClientRequest.Url.AbsoluteUri;
            string uri         = absoluteUri;

            if (this.isExplicitLogonRequest && !RequestPathParser.IsAutodiscoverV2Request(base.ClientRequest.Url.AbsoluteUri))
            {
                uri = UrlHelper.RemoveExplicitLogonFromUrlAbsoluteUri(absoluteUri, this.explicitLogonAddress);
            }
            return(new UriBuilder(uri));
        }
        // Token: 0x0600049B RID: 1179 RVA: 0x0001970C File Offset: 0x0001790C
        private bool TryMatchByCid(string publishingUrl, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            CID cid;

            if (RequestPathParser.TryGetCid(publishingUrl, ref cid))
            {
                anchorMailbox = new CidAnchorMailbox(cid.ToString(), this);
            }
            return(anchorMailbox != null);
        }
 // Token: 0x0600051C RID: 1308 RVA: 0x0001C7CC File Offset: 0x0001A9CC
 protected override AnchorMailbox ResolveAnchorMailbox()
 {
     if (this.skipTargetBackEndCalculation)
     {
         base.Logger.Set(3, "OrgRelationship-Anonymous");
         return(new AnonymousAnchorMailbox(this));
     }
     if (base.UseRoutingHintForAnchorMailbox)
     {
         string text;
         if (RequestPathParser.IsAutodiscoverV2PreviewRequest(base.ClientRequest.Url.AbsolutePath))
         {
             text = base.ClientRequest.Params["Email"];
         }
         else if (RequestPathParser.IsAutodiscoverV2Version1Request(base.ClientRequest.Url.AbsolutePath))
         {
             int num = base.ClientRequest.Url.AbsolutePath.LastIndexOf('/');
             text = base.ClientRequest.Url.AbsolutePath.Substring(num + 1);
         }
         else
         {
             text = this.TryGetExplicitLogonNode(0);
         }
         string text2;
         if (ExplicitLogonParser.TryGetNormalizedExplicitLogonAddress(text, ref text2) && SmtpAddress.IsValidSmtpAddress(text2))
         {
             this.isExplicitLogonRequest = true;
             this.explicitLogonAddress   = text;
             if (HttpProxySettings.NoMailboxFallbackRoutingEnabled.Value)
             {
                 base.IsAnchorMailboxFromRoutingHint = true;
             }
             bool failOnDomainNotFound = !RequestPathParser.IsAutodiscoverV2Request(base.ClientRequest.Url.AbsolutePath);
             if (this.preferAnchorMailboxHeader)
             {
                 string text3 = base.ClientRequest.Headers[Constants.AnchorMailboxHeaderName];
                 if (!string.IsNullOrEmpty(text3) && !StringComparer.OrdinalIgnoreCase.Equals(text3, text2) && SmtpAddress.IsValidSmtpAddress(text3))
                 {
                     return(AnchorMailboxFactory.ParseAnchorMailboxFromSmtp(this, text3, "AnchorMailboxHeader", failOnDomainNotFound));
                 }
             }
             return(AnchorMailboxFactory.ParseAnchorMailboxFromSmtp(this, text2, "ExplicitLogon", failOnDomainNotFound));
         }
     }
     return(base.ResolveAnchorMailbox());
 }
 // Token: 0x060004CF RID: 1231 RVA: 0x0001AA7B File Offset: 0x00018C7B
 internal static bool IsResourceRequest(string localPath)
 {
     return(RequestPathParser.IsResourceRequest(localPath));
 }
 // Token: 0x06000546 RID: 1350 RVA: 0x0001D211 File Offset: 0x0001B411
 internal static bool IsUserPhotoRequest(HttpRequest request)
 {
     return(RequestPathParser.IsOwaGetUserPhotoRequest(request.Path));
 }
Ejemplo n.º 8
0
 // Token: 0x060004A0 RID: 1184 RVA: 0x00019820 File Offset: 0x00017A20
 protected override void OnInitializingHandler()
 {
     base.OnInitializingHandler();
     if (!base.ClientRequest.IsAuthenticated)
     {
         base.IsWsSecurityRequest = base.ClientRequest.IsAnyWsSecurityRequest();
         if (base.IsWsSecurityRequest && !AutodiscoverEwsWebConfiguration.WsSecurityEndpointEnabled)
         {
             throw new HttpException(404, "WS-Security endpoint is not supported");
         }
     }
     if (base.ClientRequest.Url.ToString().EndsWith("autodiscover.xml", StringComparison.OrdinalIgnoreCase) || RequestPathParser.IsAutodiscoverV2Request(base.ClientRequest.Url.AbsolutePath))
     {
         base.PreferAnchorMailboxHeader = true;
     }
 }
Ejemplo n.º 9
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.º 10
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.º 11
0
 // Token: 0x06000453 RID: 1107 RVA: 0x000185AD File Offset: 0x000167AD
 public static bool IsIntegratedAuthUrl(Uri url)
 {
     return(RequestPathParser.IsIntegratedAuthUrl(url.AbsolutePath));
 }
Ejemplo n.º 12
0
 // Token: 0x06000405 RID: 1029 RVA: 0x0001776B File Offset: 0x0001596B
 public static bool IsX509CertAuthRequest(this HttpRequest request)
 {
     return(RequestPathParser.IsX509CertAuthRequest(request.Url.LocalPath));
 }
Ejemplo n.º 13
0
 // Token: 0x06000403 RID: 1027 RVA: 0x00017747 File Offset: 0x00015947
 public static bool IsWsSecurityRequest(this HttpRequest request)
 {
     return(RequestPathParser.IsWsSecurityRequest(request.Url.LocalPath));
 }