diff --git a/README.md b/README.md index c09ee65..a6afd63 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ static SharePointContextProvider() } else { - if(HttpContext.Current.User.Identity.AuthenticationType == "Federation") { + if (HttpContext.Current.User.Identity.GetType() == typeof(ClaimsIdentity)) { SharePointContextProvider.current = new SharePointHighTrustSamlContextProvider(); } else { SharePointContextProvider.current = new SharePointHighTrustContextProvider(); diff --git a/SharePointContextSaml.cs b/SharePointContextSaml.cs index 0dd36bc..f522f16 100644 --- a/SharePointContextSaml.cs +++ b/SharePointContextSaml.cs @@ -326,7 +326,7 @@ private static TokenHelper.ClaimsUserIdClaim RetrieveIdentityForSamlClaimsUser(C return id; } - + /// /// NOT IMPLEMENTED /// @@ -518,11 +518,11 @@ private static void RenewAccessTokenIfNeeded(ref Tuple accessT /// public class SharePointHighTrustSamlContextProvider : SharePointHighTrustContextProvider { - + private const string SPContextKey = "SPContext"; protected override SharePointContext CreateSharePointContext(Uri spHostUrl, Uri spAppWebUrl, string spLanguage, string spClientTag, string spProductNumber, HttpRequestBase httpRequest) { ClaimsIdentity logonUserIdentity = HttpContext.Current.User.Identity as ClaimsIdentity; - if (logonUserIdentity == null || !logonUserIdentity.IsAuthenticated ) + if (logonUserIdentity == null || !logonUserIdentity.IsAuthenticated) { return null; } @@ -546,6 +546,16 @@ protected override bool ValidateSharePointContext(SharePointContext spContext, H return false; } + + protected override SharePointContext LoadSharePointContext(HttpContextBase httpContext) + { + return httpContext.Session[SPContextKey] as SharePointHighTrustSamlContext; + } + + protected override void SaveSharePointContext(SharePointContext spContext, HttpContextBase httpContext) + { + httpContext.Session[SPContextKey] = spContext as SharePointHighTrustSamlContext; + } } #endregion HighTrust