コード例 #1
0
ファイル: SharePointContext.cs プロジェクト: BNATENSTEDT/PnP
 protected override void SaveSharePointContext(SharePointContext spContext, HttpContextBase httpContext)
 {
     httpContext.Session[SPContextKey] = spContext as SharePointHighTrustContext;
 }
コード例 #2
0
ファイル: SharePointContext.cs プロジェクト: BNATENSTEDT/PnP
        protected override bool ValidateSharePointContext(SharePointContext spContext, HttpContextBase httpContext)
        {
            SharePointHighTrustContext spHighTrustContext = spContext as SharePointHighTrustContext;

            if (spHighTrustContext != null)
            {
                Uri spHostUrl = SharePointContext.GetSPHostUrl(httpContext.Request);
                WindowsIdentity logonUserIdentity = httpContext.Request.LogonUserIdentity;

                return spHostUrl == spHighTrustContext.SPHostUrl &&
                       logonUserIdentity != null &&
                       logonUserIdentity.IsAuthenticated &&
                       !logonUserIdentity.IsGuest &&
                       logonUserIdentity.User == spHighTrustContext.LogonUserIdentity.User;
            }

            return false;
        }
コード例 #3
0
ファイル: SharePointContext.cs プロジェクト: BNATENSTEDT/PnP
        protected override void SaveSharePointContext(SharePointContext spContext, HttpContextBase httpContext)
        {
            SharePointAcsContext spAcsContext = spContext as SharePointAcsContext;

            if (spAcsContext != null)
            {
                HttpCookie spCacheKeyCookie = new HttpCookie(SPCacheKeyKey)
                {
                    Value = spAcsContext.CacheKey,
                    Secure = true,
                    HttpOnly = true
                };

                httpContext.Response.AppendCookie(spCacheKeyCookie);
            }

            httpContext.Session[SPContextKey] = spAcsContext;
        }
コード例 #4
0
ファイル: SharePointContext.cs プロジェクト: BNATENSTEDT/PnP
        protected override bool ValidateSharePointContext(SharePointContext spContext, HttpContextBase httpContext)
        {
            SharePointAcsContext spAcsContext = spContext as SharePointAcsContext;

            if (spAcsContext != null)
            {
                Uri spHostUrl = SharePointContext.GetSPHostUrl(httpContext.Request);
                string contextToken = TokenHelper.GetContextTokenFromRequest(httpContext.Request);
                HttpCookie spCacheKeyCookie = httpContext.Request.Cookies[SPCacheKeyKey];
                string spCacheKey = spCacheKeyCookie != null ? spCacheKeyCookie.Value : null;

                return spHostUrl == spAcsContext.SPHostUrl &&
                       !string.IsNullOrEmpty(spAcsContext.CacheKey) &&
                       spCacheKey == spAcsContext.CacheKey &&
                       !string.IsNullOrEmpty(spAcsContext.ContextToken) &&
                       (string.IsNullOrEmpty(contextToken) || contextToken == spAcsContext.ContextToken);
            }

            return false;
        }
コード例 #5
0
ファイル: SharePointContext.cs プロジェクト: BNATENSTEDT/PnP
 /// <summary>
 /// Saves the specified SharePointContext instance associated with the specified HTTP context.
 /// <c>null</c> is accepted for clearing the SharePointContext instance associated with the HTTP context.
 /// </summary>
 /// <param name="spContext">The SharePointContext instance to be saved, or <c>null</c>.</param>
 /// <param name="httpContext">The HTTP context.</param>
 protected abstract void SaveSharePointContext(SharePointContext spContext, HttpContextBase httpContext);
コード例 #6
0
ファイル: SharePointContext.cs プロジェクト: BNATENSTEDT/PnP
 /// <summary>
 /// Validates if the given SharePointContext can be used with the specified HTTP context.
 /// </summary>
 /// <param name="spContext">The SharePointContext.</param>
 /// <param name="httpContext">The HTTP context.</param>
 /// <returns>True if the given SharePointContext can be used with the specified HTTP context.</returns>
 protected abstract bool ValidateSharePointContext(SharePointContext spContext, HttpContextBase httpContext);