public override void AddOrUpdate(SessionSecurityTokenCacheKey key, SessionSecurityToken value, DateTime expiryTime) { string tokenId = null; ApiHelperAsync helper = new ApiHelperAsync(_httpClient); var claimsIdentity = Thread.CurrentPrincipal.Identity as ClaimsIdentity; if (claimsIdentity != null && claimsIdentity.BootstrapContext != null) { var bootstrap = claimsIdentity.BootstrapContext as BootstrapContext; if (bootstrap != null && bootstrap.SecurityToken != null) { tokenId = bootstrap.SecurityToken.Id; } } if (tokenId == null || value == null) { return; } var res = helper.AddOrUpdate(new SessionCacheEntry() { EndpointId = key.EndpointId, ContextId = GetContextIdString(key), KeyGeneration = GetKeyGenerationString(key), ExpiryTime = expiryTime, SessionSecurityTokenValue = value, UserName = Thread.CurrentPrincipal.Identity.Name, SessionSecurityTokenID = tokenId }); if (res) { _internalCache.AddOrUpdate(key, value, expiryTime); } }
public override void AddOrUpdate(System.IdentityModel.Tokens.SessionSecurityTokenCacheKey key, System.IdentityModel.Tokens.SessionSecurityToken value, DateTime expiryTime) { string tokenId = null; var claimsIdentity = Thread.CurrentPrincipal.Identity as ClaimsIdentity; if (claimsIdentity != null && claimsIdentity.BootstrapContext != null) { var bootstrap = claimsIdentity.BootstrapContext as BootstrapContext; if (bootstrap != null && bootstrap.SecurityToken != null) { tokenId = bootstrap.SecurityToken.Id; } } var data = cache.AddOrUpdate(new bUtility.TokenCache.Types.SessionSecurity.SessionCacheEntry { EndpointId = key.EndpointId, ContextId = key?.ContextId?.ToString(), KeyGeneration = GetKeyGenerationString(key), ExpiryTime = expiryTime, SessionSecurityTokenValue = value, UserName = Thread.CurrentPrincipal.Identity.Name, SessionSecurityTokenID = tokenId }); if (data) { _internalCache.AddOrUpdate(key, value, expiryTime); } }