public void Get_SessionSecurityTokenNotInCache_ReturnsNull(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store) { var token = CreateToken(DateTime.UtcNow, TimeSpan.MaxValue); var key = CreateKeyFromToken(token); var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store); var roundtrippedToken = cache.Get(key); roundtrippedToken.Should().BeNull(); }
public void AddOrUpdate_EternalSessionSecurityToken_GetReturnsToken(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store) { var token = CreateToken(DateTime.UtcNow, TimeSpan.MaxValue); var key = CreateKeyFromToken(token); var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store); cache.AddOrUpdate(key, token, token.KeyExpirationTime); var roundtrippedToken = cache.Get(key); roundtrippedToken.ShouldBeEquivalentTo(token); }
public PassiveRepositorySessionSecurityTokenCache(ITokenCacheRepository tokenCacheRepository, SessionSecurityTokenCache inner) { if (tokenCacheRepository == null) { throw new ArgumentNullException("tokenCacheRepository"); } if (inner == null) { throw new ArgumentNullException("inner"); } this.tokenCacheRepository = tokenCacheRepository; this.inner = inner; }
public void Get_SessionSecurityTokenDeletedFromCache_ReturnsNull(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store) { var token = CreateToken(DateTime.UtcNow, TimeSpan.MaxValue); var key = CreateKeyFromToken(token); var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store); cache.AddOrUpdate(key, token, token.KeyExpirationTime); cache.Remove(key); var roundtrippedToken = cache.Get(key); roundtrippedToken.Should().BeNull(); }
public WrappedTokenCache(SessionSecurityTokenCache tokenCache, SctClaimsHandler sctClaimsHandler) { if (tokenCache == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenCache"); } if (sctClaimsHandler == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("sctClaimsHandler"); } _tokenCache = tokenCache; _claimsHandler = sctClaimsHandler; }
public void AddOrUpdate_SessionSecurityTokenExpiredInCache_GetReturnsToken(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store) { // It is, unfortunately, impossible to create a SessionSecurityToken that is expired... var token = CreateToken(DateTime.UtcNow, TimeSpan.FromMilliseconds(500)); var key = CreateKeyFromToken(token); var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store); cache.AddOrUpdate(key, token, token.KeyExpirationTime); Thread.Sleep(TimeSpan.FromSeconds(1)); var roundtrippedToken = cache.Get(key); roundtrippedToken.ShouldBeEquivalentTo(token); }
/// <summary> /// Initializes an instance of <see cref="FederatedSecurityTokenManager"/>. /// </summary> /// <param name="parentCredentials">ServiceCredentials that created this instance of TokenManager.</param> /// <exception cref="ArgumentNullException">The argument 'parentCredentials' is null.</exception> public FederatedSecurityTokenManager(ServiceCredentials parentCredentials) : base(parentCredentials) { if (parentCredentials == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parentCredentials"); } if (parentCredentials.IdentityConfiguration == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parentCredentials.IdentityConfiguration"); } _exceptionMapper = parentCredentials.ExceptionMapper; _securityTokenHandlerCollection = parentCredentials.IdentityConfiguration.SecurityTokenHandlers; _tokenCache = _securityTokenHandlerCollection.Configuration.Caches.SessionSecurityTokenCache; _cookieTransforms = SessionSecurityTokenHandler.DefaultCookieTransforms; }
public DatabaseSecurityTokenCache() { m_MemoryCache = new IdentityModelCaches().SessionSecurityTokenCache; m_SessionSecurityTokenStore = new SqlServerSessionSecurityTokenStore(); }
public TestableDatabaseSecurityTokenCache(SessionSecurityTokenCache sessionSecurityTokenCache, SessionSecurityTokenStore sessionSecurityTokenStore) { m_MemoryCache = sessionSecurityTokenCache; m_SessionSecurityTokenStore = sessionSecurityTokenStore; }
public SessionSecurityTokenCacheService() { internalCache = new IdentityModelCaches().SessionSecurityTokenCache; }