public abstract bool VerifyTicket(UserAuthenticationTicket ticket);
public abstract void UpdateTicketExpiration(UserAuthenticationTicket ticket, DateTime newExpiration);
public abstract void InsertTicket(UserAuthenticationTicket ticket, DateTime expiration);
/// <summary> /// Verify that the supplied UserAuthenticationTicket exists in the ticket store /// </summary> /// <param name="ticket">The UserAuthenticationTicket to verify</param> /// <returns> /// True if the ticket exists in the ticket store and the properties of that /// ticket match the properties of the ticket in the ticket store. /// </returns> public override bool VerifyTicket(UserAuthenticationTicket ticket) { if (ticket == null) { throw new ArgumentNullException("ticket", "UserAuthenticationTicket parameter cannot be null."); } string incomingTicket = ticket.Key; UserAuthenticationTicket cacheAuthTicket = GetTicket(incomingTicket); if (cacheAuthTicket != null) { string cacheTicket = cacheAuthTicket.Key; if (cacheTicket == incomingTicket) { if (string.Compare(cacheAuthTicket.Username, ticket.Username, StringComparison.OrdinalIgnoreCase) != 0) { return false; } return true; } } else { return false; } return false; }
/// <summary> /// Updates the expiration date and time for an existing ticket. If the ticket does /// not exist in the ticket store, just return (do not throw an exception). /// </summary> /// <param name="ticket">The UserAuthenticationTicket to insert</param> /// <param name="newExpiration">The new expiration date and time</param> /// <exception cref="ArgumentNullException">UserAuthenticationTicket is null</exception> public override void UpdateTicketExpiration(UserAuthenticationTicket ticket, DateTime newExpiration) { if (ticket == null) { throw new ArgumentNullException("ticket", "UserAuthenticationTicket parameter cannot be null."); } RevokeTicket(ticket.Key); InsertTicket(ticket, newExpiration); }
/// <summary> /// Inserts a UserAuthenticationTicket to the ticket store with a corresponding /// ticket expiration date. /// </summary> /// <param name="ticket">The UserAuthenticationTicket to insert</param> /// <param name="expiration">The date and time at which the ticket expires</param> /// <exception cref="ArgumentNullException">UserAuthenticationTicket is null</exception> public override void InsertTicket(UserAuthenticationTicket ticket, DateTime expiration) { if (ticket == null) { throw new ArgumentNullException("ticket", "UserAuthenticationTicket parameter cannot be null."); } // Don't enforce sliding expiration on the cache entry. Sliding expiration // is handled by the HttpModule HttpContext.Current.Cache.Insert(GetCacheKey(ticket.Key), ticket, null, expiration, Cache.NoSlidingExpiration); }