protected override SharePointContext CreateSharePointContext(Uri spHostUrl, Uri spAppWebUrl, string spLanguage, string spClientTag, string spProductNumber, HttpRequest httpRequest) { string contextTokenString = TokenHandler.GetContextTokenFromRequest(httpRequest); if (string.IsNullOrEmpty(contextTokenString)) { return(null); } SharePointContextToken contextToken = null; try { contextToken = TokenHandler.ReadAndValidateContextToken(contextTokenString, httpRequest.Host.Value); } //catch (WebException) //{ // return null; //} catch (AudienceUriValidationFailedException) { return(null); } return(new SharePointAcsContext(spHostUrl, spAppWebUrl, spLanguage, spClientTag, spProductNumber, contextTokenString, contextToken, Configuration)); }
protected override SharePointContext LoadSharePointContext(HttpContext httpContext) { byte[] value; httpContext.Session.TryGetValue(SPContextKey, out value); if (value == null) { return(null); } char[] chars = new char[value.Length / sizeof(char)]; System.Buffer.BlockCopy(value, 0, chars, 0, value.Length); string acsSessionContext = new string(chars); var dto = JsonConvert.DeserializeObject <SharePointSessionData>(acsSessionContext); var contextTokenObj = TokenHandler.ReadAndValidateContextToken(dto.ContextToken, httpContext.Request.Host.Value); return(new SharePointAcsContext(dto.SpHostUrl, dto.SpAppWebUrl, dto.SpLanguage, dto.SpClientTag, dto.SpProductNumber, dto.ContextToken, contextTokenObj, Configuration)); }