private static Date getExpireAt ( final Ticket ticket ) { val expirationPolicy = ticket . getExpirationPolicy ( ) ; val ttl = ticket instanceof TicketState ? expirationPolicy . getTimeToLive ( ( TicketState ) ticket ) : expirationPolicy . getTimeToLive ( ) ; if ( ttl < 1 ) { return null ; } return new Date ( System . currentTimeMillis ( ) + TimeUnit . SECONDS . toMillis ( ttl ) ) ; }
Calculate the time at which the ticket is eligible for automated deletion by MongoDb . Makes the assumption that the CAS server date and the Mongo server date are in sync .