private void Complete2(AsyncTask task) { ProxyAuthenticator proxyAuthenticator = ProxyAuthenticator.Create(this.webProxyExternalAuthenticationRequest.RequestedToken, this.sharingKey, base.ClientContext.MessageId); this.dispatcher = new DispatcherWithAutoDiscoverResults(base.Application, base.QueryList, this.queryItems, proxyAuthenticator, RequestType.FederatedCrossForest, new DispatcherWithAutoDiscoverResults.CreateRequestWithQueryListDelegate(this.CreateRequest)); this.dispatcher.BeginInvoke(new TaskCompleteCallback(this.Complete3)); }
private void Complete1(AsyncTask task) { this.requestTimer.Stop(); if (!base.Aborted) { base.QueryList.LogLatency("EPWRADC1", this.requestTimer.ElapsedMilliseconds); } if (this.autoDiscoverExternalAuthenticationRequest.Exception != null) { base.SetExceptionInResultList(this.autoDiscoverExternalAuthenticationRequest.Exception); base.Complete(); return; } if (this.webProxyExternalAuthenticationRequest.Exception != null) { base.SetExceptionInResultList(this.webProxyExternalAuthenticationRequest.Exception); base.Complete(); return; } ProxyAuthenticator proxyAuthenticator = ProxyAuthenticator.Create(this.autoDiscoverExternalAuthenticationRequest.RequestedToken, this.sharingKey, base.ClientContext.MessageId); this.queryItems = new AutoDiscoverQueryItem[base.QueryList.Count]; string target = this.autoDiscoverUrl.ToString(); for (int i = 0; i < base.QueryList.Count; i++) { base.QueryList[i].Target = target; this.queryItems[i] = new AutoDiscoverQueryItem(base.QueryList[i].RecipientData, base.Application.Name, base.QueryList[i]); } this.autoDiscoverQuery = new AutoDiscoverQueryExternal(base.Application, base.ClientContext, base.RequestLogger, this.autoDiscoverUrl, proxyAuthenticator, this.queryItems, this.createAutoDiscoverRequest, base.QueryList); this.autoDiscoverQuery.BeginInvoke(new TaskCompleteCallback(this.Complete2)); }
private void Complete1(AsyncTask task) { ProxyAuthenticator proxyAuthenticator = ProxyAuthenticator.Create(OAuthCredentialsFactory.Create(base.ClientContext as InternalClientContext, base.RequestLogger), base.ClientContext.MessageId, false); this.dispatcher = new DispatcherWithAutoDiscoverResults(base.Application, base.QueryList, this.queryItems, proxyAuthenticator, RequestType.FederatedCrossForest, new DispatcherWithAutoDiscoverResults.CreateRequestWithQueryListDelegate(this.CreateRequest)); this.dispatcher.BeginInvoke(new TaskCompleteCallback(this.Complete2)); }
public static ProxyAuthenticator Create(OAuthCredentials credentials, string messageId, bool isAutodiscoverRequest) { ProxyAuthenticator.SecurityTracer.TraceDebug <object, OAuthCredentials>(0L, "{0}: creating ProxyAuthenticator for OAuthCredentials: {1}", TraceContext.Get(), credentials); SoapHttpClientAuthenticator soapHttpClientAuthenticator = isAutodiscoverRequest ? SoapHttpClientAuthenticator.CreateForSoap(credentials) : SoapHttpClientAuthenticator.Create(credentials); ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId); return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.OAuth)); }
public static ProxyAuthenticator Create(CommonAccessToken commonAccessToken, string messageId) { ProxyAuthenticator.SecurityTracer.TraceDebug <object, CommonAccessToken>(0L, "{0}: creating ProxyAuthenticator for CommonAccessToken: {1}", TraceContext.Get(), commonAccessToken); SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(commonAccessToken); ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId); return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.OAuth)); }
public override void BeginInvoke(TaskCompleteCallback callback) { base.BeginInvoke(callback); ProxyAuthenticator proxyAuthenticator = ProxyAuthenticator.Create(OAuthCredentialsFactory.Create(base.ClientContext as InternalClientContext, base.RequestLogger), base.ClientContext.MessageId, false); this.proxyWebRequest = new ProxyWebRequest(base.Application, base.ClientContext, RequestType.FederatedCrossForest, base.RequestLogger, base.QueryList, TargetServerVersion.Unknown, proxyAuthenticator, this.webServiceUri, this.webServiceUri.Source); this.proxyWebRequest.BeginInvoke(new TaskCompleteCallback(this.CompleteWebRequest)); }
public override void BeginInvoke(TaskCompleteCallback callback) { base.BeginInvoke(callback); ProxyAuthenticator proxyAuthenticator = ProxyAuthenticator.Create(OAuthCredentialsFactory.CreateAsApp(base.ClientContext as InternalClientContext, base.RequestLogger), base.ClientContext.MessageId, true); this.queryItems = AutoDiscoverQueryItem.CreateAutoDiscoverQueryItems(base.Application, base.QueryList, this.autoDiscoverUrl); this.autoDiscoverQuery = new AutoDiscoverQueryExternalByOAuth(base.Application, base.ClientContext, base.RequestLogger, this.autoDiscoverUrl, proxyAuthenticator, this.queryItems, this.createAutoDiscoverRequest, base.QueryList); this.autoDiscoverQuery.BeginInvoke(new TaskCompleteCallback(this.Complete1)); }
public static ProxyAuthenticator CreateForSoap(string messageId) { ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for network service", new object[] { TraceContext.Get() }); SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.CreateNetworkServiceForSoap(); ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId); return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.NetworkCredentials)); }
private void CompleteAuthenticator(AsyncTask task) { if (this.externalAuthenticationRequest.Exception != null) { base.SetExceptionInResultList(this.externalAuthenticationRequest.Exception); base.Complete(); return; } ProxyAuthenticator proxyAuthenticator = ProxyAuthenticator.Create(this.externalAuthenticationRequest.RequestedToken, this.sharingKey, base.ClientContext.MessageId); this.proxyWebRequest = new ProxyWebRequest(base.Application, base.ClientContext, RequestType.FederatedCrossForest, base.RequestLogger, base.QueryList, TargetServerVersion.Unknown, proxyAuthenticator, this.webServiceUri, this.webServiceUri.Source); this.proxyWebRequest.BeginInvoke(new TaskCompleteCallback(this.CompleteWebRequest)); }
public void Authenticate(CustomSoapHttpClientProtocol client) { if (this.ProxyAuthenticator == null) { if (this.CredentialCache != null) { this.ProxyAuthenticator = ProxyAuthenticator.Create(this.CredentialCache, null, null); } else { this.ProxyAuthenticator = ProxyAuthenticator.Create(this.Credentials, null, null); } } this.ProxyAuthenticator.Authenticate(client); }
internal ProxyAuthenticator GetProxyAuthenticatorForAutoDiscover(Uri uri, SerializedSecurityContext serializedSecurityContext, string messageId) { if (this.AccessMethod == AvailabilityAccessMethod.OrgWideFBBasic && this.Credentials != null) { return(ProxyAuthenticator.Create(new CredentialCache { { uri, "Basic", this.Credentials } }, serializedSecurityContext, messageId)); } return(ProxyAuthenticator.Create(this.Credentials, serializedSecurityContext, messageId)); }
public static ProxyAuthenticator Create(WSSecurityHeader wsSecurityHeader, SharingSecurityHeader sharingSecurityHeader, string messageId) { ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for WS-Security", new object[] { TraceContext.Get() }); SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(wsSecurityHeader); if (sharingSecurityHeader != null) { soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(sharingSecurityHeader); } ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId); return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.WSSecurity)); }
private AutoDiscoverResult GetResult(RecipientData recipientData, WebServiceUri webServiceUri) { if (!base.Application.IsVersionSupported(webServiceUri.ServerVersion)) { AutoDiscoverQuery.AutoDiscoverTracer.TraceError <object, int, Type>((long)this.GetHashCode(), "{0}: Remote server version {1} is considered a legacy server by {2} application.", TraceContext.Get(), webServiceUri.ServerVersion, base.Application.GetType()); return(new AutoDiscoverResult(base.Application.CreateExceptionForUnsupportedVersion(recipientData, webServiceUri.ServerVersion))); } AutoDiscoverQuery.AutoDiscoverTracer.TraceDebug <object, Uri, EmailAddress>((long)this.GetHashCode(), "{0}: Found availability service {1} that can fill request for mailbox {2}", TraceContext.Get(), webServiceUri.Uri, (recipientData != null) ? recipientData.EmailAddress : null); SerializedSecurityContext serializedSecurityContext = null; InternalClientContext internalClientContext = base.ClientContext as InternalClientContext; if (this.targetForestConfiguration.IsPerUserAuthorizationSupported && internalClientContext != null) { serializedSecurityContext = internalClientContext.SerializedSecurityContext; } ProxyAuthenticator proxyAuthenticatorForAutoDiscover = this.targetForestConfiguration.GetProxyAuthenticatorForAutoDiscover(webServiceUri.Uri, serializedSecurityContext, base.ClientContext.MessageId); return(new AutoDiscoverResult(webServiceUri, proxyAuthenticatorForAutoDiscover)); }
public static ProxyAuthenticator Create(RequestedToken token, SmtpAddress sharingKey, string messageId) { ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for WS-Security", new object[] { TraceContext.Get() }); XmlElement xmlElement = null; if (sharingKey != SmtpAddress.Empty) { xmlElement = SharingKeyHandler.Encrypt(sharingKey, token.ProofToken); } SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(token); if (xmlElement != null) { soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(new SharingSecurityHeader(xmlElement)); } ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId); return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.WSSecurity)); }
public static ProxyAuthenticator Create(CredentialCache cache, SerializedSecurityContext serializedContext, string messageId) { SoapHttpClientAuthenticator soapHttpClientAuthenticator; if (cache == null) { ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for network service", new object[] { TraceContext.Get() }); soapHttpClientAuthenticator = SoapHttpClientAuthenticator.CreateNetworkService(); } else { ProxyAuthenticator.SecurityTracer.TraceDebug <object, CredentialCache>(0L, "{0}: creating ProxyAuthenticator for credential cache: {1}", TraceContext.Get(), cache); soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(cache); } if (serializedContext != null) { soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(serializedContext); } ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId); return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.NetworkCredentials)); }
private AsyncRequest CreateRequest(QueryList queryList, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri, UriSource source) { return(new ProxyWebRequest(base.Application, base.ClientContext, RequestType.FederatedCrossForest, base.RequestLogger, queryList, TargetServerVersion.Unknown, proxyAuthenticator, webServiceUri, source)); }
public AutoDiscoverAuthenticator(ProxyAuthenticator proxyAuthenticator) { this.ProxyAuthenticator = proxyAuthenticator; }
public static AutoDiscoverRequestOperation CreateForCrossForest(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri targetUri, AutoDiscoverAuthenticator authenticator, EmailAddress[] emailAddresses, UriSource uriSource, AutodiscoverType autodiscoverType) { return(new AutoDiscoverRequestByDomain(application, clientContext, requestLogger, new AutoDiscoverAuthenticator(ProxyAuthenticator.CreateForSoap(clientContext.MessageId)), targetUri, emailAddresses, autodiscoverType)); }
internal ProxyWebRequest(Application application, ClientContext clientContext, RequestType requestType, RequestLogger requestLogger, QueryList queryList, TargetServerVersion targetVersion, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri, UriSource source) : base(application, clientContext, requestLogger, "ProxyWebRequest") { this.proxyAuthenticator = proxyAuthenticator; this.url = webServiceUri.Uri.OriginalString; this.protocol = webServiceUri.Protocol; this.source = source; this.queryList = queryList; this.requestType = requestType; this.service = application.CreateService(webServiceUri, targetVersion, requestType); if (proxyAuthenticator.AuthenticatorType == AuthenticatorType.WSSecurity || proxyAuthenticator.AuthenticatorType == AuthenticatorType.OAuth) { if (webServiceUri.ServerVersion >= Globals.E15Version && clientContext.RequestSchemaVersion >= ExchangeVersionType.Exchange2012) { this.service.RequestServerVersionValue = new RequestServerVersion { Version = ExchangeVersionType.Exchange2012 }; } else { this.service.RequestServerVersionValue = new RequestServerVersion { Version = ExchangeVersionType.Exchange2009 }; } } else if (targetVersion >= TargetServerVersion.E15 && clientContext.RequestSchemaVersion == ExchangeVersionType.Exchange2012) { this.service.RequestServerVersionValue = new RequestServerVersion { Version = ExchangeVersionType.Exchange2012 }; } this.service.CookieContainer = new CookieContainer(); this.service.requestTypeValue = new RequestTypeHeader(); if (requestType == RequestType.CrossSite || requestType == RequestType.IntraSite) { if (Configuration.BypassProxyForCrossSiteRequests) { this.service.Proxy = new WebProxy(); } this.service.requestTypeValue.RequestType = ProxyRequestType.CrossSite; if (requestType == RequestType.CrossSite) { this.failedCounter = PerformanceCounters.CrossSiteCalendarFailuresPerSecond; this.averageProcessingTimeCounter = PerformanceCounters.AverageCrossSiteFreeBusyRequestProcessingTime; this.averageProcessingTimeCounterBase = PerformanceCounters.AverageCrossSiteFreeBusyRequestProcessingTimeBase; this.requestStatisticsType = RequestStatisticsType.CrossSiteProxy; } else { this.failedCounter = PerformanceCounters.IntraSiteProxyFreeBusyFailuresPerSecond; this.averageProcessingTimeCounter = PerformanceCounters.AverageIntraSiteProxyFreeBusyRequestProcessingTime; this.averageProcessingTimeCounterBase = PerformanceCounters.AverageIntraSiteProxyFreeBusyRequestProcessingTimeBase; this.requestStatisticsType = RequestStatisticsType.IntraSiteProxy; } } else { bool flag = false; if (Configuration.BypassProxyForCrossForestRequests) { this.service.Proxy = new WebProxy(); flag = true; } this.service.requestTypeValue.RequestType = ProxyRequestType.CrossForest; if (requestType == RequestType.FederatedCrossForest) { if (proxyAuthenticator.AuthenticatorType == AuthenticatorType.OAuth) { this.failedCounter = PerformanceCounters.FederatedByOAuthFreeBusyFailuresPerSecond; this.averageProcessingTimeCounter = PerformanceCounters.AverageFederatedByOAuthFreeBusyRequestProcessingTime; this.averageProcessingTimeCounterBase = PerformanceCounters.AverageFederatedByOAuthFreeBusyRequestProcessingTimeBase; this.requestStatisticsType = RequestStatisticsType.OAuthProxy; this.service.requestTypeValue = null; } else { this.failedCounter = PerformanceCounters.FederatedFreeBusyFailuresPerSecond; this.averageProcessingTimeCounter = PerformanceCounters.AverageFederatedFreeBusyRequestProcessingTime; this.averageProcessingTimeCounterBase = PerformanceCounters.AverageFederatedFreeBusyRequestProcessingTimeBase; this.requestStatisticsType = RequestStatisticsType.FederatedProxy; } if (!flag) { Server localServer = LocalServerCache.LocalServer; if (localServer != null && localServer.InternetWebProxy != null) { ProxyWebRequest.ProxyWebRequestTracer.TraceDebug <object, Uri>((long)this.GetHashCode(), "{0}: Using custom InternetWebProxy {1}", TraceContext.Get(), localServer.InternetWebProxy); this.service.Proxy = new WebProxy(localServer.InternetWebProxy); } } } else { this.failedCounter = PerformanceCounters.CrossForestCalendarFailuresPerSecond; this.averageProcessingTimeCounter = PerformanceCounters.AverageCrossForestFreeBusyRequestProcessingTime; this.averageProcessingTimeCounterBase = PerformanceCounters.AverageCrossForestFreeBusyRequestProcessingTimeBase; this.requestStatisticsType = RequestStatisticsType.CrossForestProxy; } } if (!Configuration.DisableGzipForProxyRequests) { this.service.EnableDecompression = true; } string address = this.queryList[0].Email.Address; ProxyWebRequest.ProxyWebRequestTracer.TraceDebug <object, string, WebServiceUri>((long)this.GetHashCode(), "{0}: Adding Anchor Mailbox Header {1} to the request to {2}.", TraceContext.Get(), address, webServiceUri); this.service.HttpHeaders.Add("X-AnchorMailbox", address); if (!string.IsNullOrEmpty(base.ClientContext.RequestId)) { this.service.HttpHeaders.Add("client-request-id", base.ClientContext.RequestId); } }
public AutoDiscoverQueryExternal(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri autoDiscoverUrl, ProxyAuthenticator proxyAuthenticator, AutoDiscoverQueryItem[] queryItems, CreateAutoDiscoverRequestDelegate createAutoDiscoverRequest, QueryList queryList) : this(application, clientContext, requestLogger, autoDiscoverUrl, new AutoDiscoverAuthenticator(proxyAuthenticator), queryItems, 0, createAutoDiscoverRequest, queryList) { }
public AutoDiscoverResult(WebServiceUri webServiceUri, ProxyAuthenticator proxyAuthenticator) { this.ProxyAuthenticator = proxyAuthenticator; this.WebServiceUri = webServiceUri; }
private AsyncRequestWithQueryList CreateRequest(QueryList queryList, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri, UriSource source) { return(new GetFolderAndProxyRequest(base.Application, (InternalClientContext)base.ClientContext, RequestType.CrossForest, base.RequestLogger, queryList, TargetServerVersion.Unknown, proxyAuthenticator, webServiceUri)); }
public DispatcherWithAutoDiscoverResults(Application application, QueryList queryList, IList <AutoDiscoverQueryItem> autoDiscoverQueryItems, ProxyAuthenticator proxyAuthenticator, RequestType requestType, DispatcherWithAutoDiscoverResults.CreateRequestWithQueryListDelegate createRequestDelegate) { DispatcherWithAutoDiscoverResults < > 4__this = this; this.createRequestDelegate = createRequestDelegate; for (int i = 0; i < queryList.Count; i++) { BaseQuery baseQuery = queryList[i]; AutoDiscoverResult autoDiscoverResult = autoDiscoverQueryItems[i].Result; if (autoDiscoverResult.Exception != null) { DispatcherWithAutoDiscoverResults.RequestRoutingTracer.TraceError <object, EmailAddress>((long)this.GetHashCode(), "{0}: autodiscover for {1} failed and it will not be dispatched for query", TraceContext.Get(), baseQuery.Email); baseQuery.SetResultOnFirstCall(application.CreateQueryResult(autoDiscoverResult.Exception)); } else { string key = autoDiscoverResult.WebServiceUri.Uri.ToString(); if (autoDiscoverResult.WebServiceUri.EmailAddress != null) { baseQuery.RecipientData.EmailAddress = autoDiscoverResult.WebServiceUri.EmailAddress; } base.Add(key, baseQuery, requestType, (QueryList perRequestQueryList) => < > 4__this.createRequestDelegate(perRequestQueryList, proxyAuthenticator ?? autoDiscoverResult.ProxyAuthenticator, autoDiscoverResult.WebServiceUri, UriSource.EmailDomain)); } } }
public GetFolderAndProxyRequest(Application application, InternalClientContext clientContext, RequestType requestType, RequestLogger requestLogger, QueryList queryList, TargetServerVersion targetVersion, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri) : base(application, clientContext, requestType, requestLogger, queryList) { this.targetVersion = targetVersion; this.proxyAuthenticator = proxyAuthenticator; this.webServiceUri = webServiceUri; }
public override ProxyAuthenticator CreateInternalProxyAuthenticator() { return(ProxyAuthenticator.Create(base.WSSecurityHeader, null, base.MessageId)); }