/// <summary>
        /// Verify that the supplied DeviceAuthenticationTicket exists in the ticket store
        /// </summary>
        /// <param name="ticket">The DeviceAuthenticationTicket 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(DeviceAuthenticationTicket ticket)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException("ticket", "DeviceAuthenticationTicket parameter cannot be null.");
            }

            string incomingTicket = ticket.Key;
            DeviceAuthenticationTicket cacheAuthTicket = GetTicket(incomingTicket);
            if (cacheAuthTicket != null)
            {
                string cacheTicket = cacheAuthTicket.Key;
                if (cacheTicket == incomingTicket)
                {
                    // TODO: See how to handle this.  For now, just return true
                    // if (string.Compare(cacheAuthTicket.HostAddress, ticket.HostAddress, 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 DeviceAuthenticationTicket to insert</param>
        /// <param name="newExpiration">The new expiration date and time</param>
        /// <exception cref="ArgumentNullException">DeviceAuthenticationTicket is null</exception>
        public override void UpdateTicketExpiration(DeviceAuthenticationTicket ticket, DateTime newExpiration)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException("ticket", "DeviceAuthenticationTicket parameter cannot be null.");
            }

            RevokeTicket(ticket.Key);
            InsertTicket(ticket, newExpiration);
        }
        /// <summary>
        /// Inserts a DeviceAuthenticationTicket to the ticket store with a corresponding 
        /// ticket expiration date.
        /// </summary>
        /// <param name="ticket">The DeviceAuthenticationTicket to insert</param>
        /// <param name="expiration">The date and time at which the ticket expires</param>
        /// <exception cref="ArgumentNullException">DeviceAuthenticationTicket is null</exception>
        public override void InsertTicket(DeviceAuthenticationTicket ticket, DateTime expiration)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException("ticket", "DeviceAuthenticationTicket 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);
        }
 public abstract bool VerifyTicket(DeviceAuthenticationTicket ticket);
 public abstract void UpdateTicketExpiration(DeviceAuthenticationTicket ticket, DateTime newExpiration);
 public abstract void InsertTicket(DeviceAuthenticationTicket ticket, DateTime expiration);