// Token: 0x0600020F RID: 527 RVA: 0x000081AC File Offset: 0x000063AC internal static DownloadResult SendRestRequest(string requestMethod, string requestUri, OwaIdentity identity, Stream requestStream, DataProviderCallLogEvent logEvent, string spCallName) { DownloadResult result; using (HttpClient httpClient = new HttpClient()) { HttpSessionConfig httpSessionConfig = new HttpSessionConfig { Method = requestMethod, Credentials = OauthUtils.GetOauthCredential(identity.GetOWAMiniRecipient()), UserAgent = OneDriveProUtilities.UserAgentString, RequestStream = requestStream, ContentType = "application/json;odata=verbose", PreAuthenticate = true }; httpSessionConfig.Headers = OneDriveProUtilities.GetOAuthRequestHeaders(); if (logEvent != null) { logEvent.TrackSPCallBegin(); } ICancelableAsyncResult cancelableAsyncResult = httpClient.BeginDownload(new Uri(requestUri), httpSessionConfig, null, null); cancelableAsyncResult.AsyncWaitHandle.WaitOne(); DownloadResult downloadResult = httpClient.EndDownload(cancelableAsyncResult); if (logEvent != null) { string correlationId = (downloadResult.ResponseHeaders == null) ? null : downloadResult.ResponseHeaders["SPRequestGuid"]; logEvent.TrackSPCallEnd(spCallName, correlationId); } result = downloadResult; } return(result); }
private ICollection <string> ExtractSmtpAddresses(OwaIdentity requestor) { if (requestor == null) { return(Array <string> .Empty); } OWAMiniRecipient owaminiRecipient = requestor.OwaMiniRecipient ?? requestor.GetOWAMiniRecipient(); if (owaminiRecipient == null) { this.tracer.TraceDebug((long)this.GetHashCode(), "OwaPhotoRequestorWriter: cannot extract SMTP addresses because recipient information has NOT been initialized or computed for requestor."); return(Array <string> .Empty); } HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); SmtpAddress primarySmtpAddress = requestor.PrimarySmtpAddress; hashSet.Add(requestor.PrimarySmtpAddress.ToString()); if (owaminiRecipient.EmailAddresses != null && owaminiRecipient.EmailAddresses.Count > 0) { hashSet.UnionWith(from a in owaminiRecipient.EmailAddresses where OwaPhotoRequestorWriter.IsNonBlankSmtpAddress(a) select a.ValueString); } return(hashSet); }
private static OrganizationId GetOrganization(OwaIdentity requestor) { if (requestor.UserOrganizationId != null) { return(requestor.UserOrganizationId); } OWAMiniRecipient owaminiRecipient = requestor.OwaMiniRecipient ?? requestor.GetOWAMiniRecipient(); if (owaminiRecipient != null) { return(owaminiRecipient.OrganizationId); } return(null); }
private static bool ShouldBlockConnection(HttpContext httpContext, OwaIdentity logonIdentity) { if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).OwaServer.OwaClientAccessRulesEnabled.Enabled) { return(false); } RequestDetailsLogger logger = OwaApplication.GetRequestDetailsLogger; Action <ClientAccessRulesEvaluationContext> blockLoggerDelegate = delegate(ClientAccessRulesEvaluationContext context) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, ClientAccessRulesConstants.ClientAccessRuleName, context.CurrentRule.Name); }; Action <double> latencyLoggerDelegate = delegate(double latency) { if (latency > 50.0) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, ClientAccessRulesConstants.ClientAccessRulesLatency, latency); } }; OWAMiniRecipient owaminiRecipient = logonIdentity.GetOWAMiniRecipient(); string usernameFromIdInformation = ClientAccessRulesUtils.GetUsernameFromIdInformation(owaminiRecipient.WindowsLiveID, owaminiRecipient.MasterAccountSid, owaminiRecipient.Sid, owaminiRecipient.ObjectId); return(ClientAccessRulesUtils.ShouldBlockConnection(logonIdentity.UserOrganizationId, usernameFromIdInformation, ClientAccessProtocol.OutlookWebApp, ClientAccessRulesUtils.GetRemoteEndPointFromContext(httpContext), httpContext.Request.IsAuthenticatedByAdfs() ? ClientAccessAuthenticationMethod.AdfsAuthentication : ClientAccessAuthenticationMethod.BasicAuthentication, owaminiRecipient, blockLoggerDelegate, latencyLoggerDelegate)); }
// Token: 0x0600020E RID: 526 RVA: 0x0000819D File Offset: 0x0000639D internal static ICredentials GetOneDriveProCredentials(OwaIdentity identity) { return(OauthUtils.GetOauthCredential(identity.GetOWAMiniRecipient())); }
// Token: 0x06000211 RID: 529 RVA: 0x000082BC File Offset: 0x000064BC internal static string GetWacUrl(OwaIdentity identity, string endPointUrl, string documentUrl, bool isEdit) { string arg = isEdit ? "2" : "4"; string text = string.Format("{0}/_api/Microsoft.SharePoint.Yammer.WACAPI.GetWacToken(fileUrl=@p, wopiAction={2})?@p='{1}'", endPointUrl, documentUrl, arg); string result; using (HttpClient httpClient = new HttpClient()) { OWAMiniRecipient owaminiRecipient = identity.GetOWAMiniRecipient(); ICredentials oauthCredential = OauthUtils.GetOauthCredential(owaminiRecipient); WebHeaderCollection oauthRequestHeaders = OneDriveProUtilities.GetOAuthRequestHeaders(); HttpSessionConfig sessionConfig = new HttpSessionConfig { Method = "GET", Credentials = oauthCredential, UserAgent = OneDriveProUtilities.UserAgentString, ContentType = "application/json;odata=verbose", PreAuthenticate = true, Headers = oauthRequestHeaders }; DownloadResult downloadResult; try { downloadResult = OneDriveProUtilities.TryTwice(httpClient, sessionConfig, text); } catch (WebException ex) { if (!OneDriveProUtilities.IsDurableUrlFormat(documentUrl)) { throw ex; } ExTraceGlobals.AttachmentHandlingTracer.TraceWarning <string>(0L, "OneDriveProUtilities.GetWacUrl Exception while trying to get wac token using durable url. : {0}", ex.StackTrace); documentUrl = documentUrl.Substring(0, documentUrl.LastIndexOf("?", StringComparison.InvariantCulture)); text = string.Format("{0}/_api/Microsoft.SharePoint.Yammer.WACAPI.GetWacToken(fileUrl=@p, wopiAction={2})?@p='{1}'", endPointUrl, documentUrl, arg); ExTraceGlobals.AttachmentHandlingTracer.TraceWarning <string>(0L, "OneDriveProUtilities.GetWacUrl Fallback to canonical url format: {0}", text); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("SP.GWT", null, "GetWacToken", string.Format("Error getting WAC Token fallback to canonical format:{0}", text))); downloadResult = OneDriveProUtilities.TryTwice(httpClient, sessionConfig, text); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(downloadResult.ResponseStream); string namespaceURI = "http://schemas.microsoft.com/ado/2007/08/dataservices"; string text2 = null; string text3 = null; string text4 = null; foreach (object obj in xmlDocument.GetElementsByTagName("*", namespaceURI)) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode is XmlElement) { if (text2 != null && text3 != null && text4 != null) { break; } if (string.CompareOrdinal(xmlNode.LocalName, "AppUrl") == 0) { text2 = xmlNode.InnerText; } else if (string.CompareOrdinal(xmlNode.LocalName, "AccessToken") == 0) { text3 = xmlNode.InnerText; } else if (string.CompareOrdinal(xmlNode.LocalName, "AccessTokenTtl") == 0) { text4 = xmlNode.InnerText; } } } if (text2 == null || text3 == null || text4 == null) { throw new OwaException("SharePoint's GetWacToken response is not usable."); } string text5 = isEdit ? "OwaEdit" : "OwaView"; result = string.Format("{0}&access_token={1}&access_token_ttl={2}&sc={3}", new object[] { text2, text3, text4, text5 }); } return(result); }