@Override
    public Stream<? extends Ticket> getSessionsWithAttributes(final Map<String, List<Object>> queryAttributes) {
        val ticketDefinitions = ticketCatalog.findTicketDefinition(TicketGrantingTicket.class);
        return ticketDefinitions
            .stream()
            .map(this::getTicketCollectionInstanceByMetadata)
            .flatMap(map -> {
                val criteria = queryAttributes.entrySet()
                    .stream()
                    .map(entry -> {
                        val criteriaValues = entry.getValue()
                            .stream()
                            .map(queryValue -> {
                                val key = MongoDbTicketDocument.FIELD_NAME_ATTRIBUTES + '.' + digestIdentifier(entry.getKey());
                                return Criteria.where(key).is(digestIdentifier(queryValue.toString()));
                            })
                            .toList();
                        return new Criteria().orOperator(criteriaValues);
                    })
                    .collect(Collectors.toList());
                val finalCriteria = new Criteria().andOperator(criteria);
                LOGGER.debug("Authenticated sessions query criteria is [{}]", finalCriteria.getCriteriaObject());
                val query = new Query(finalCriteria);
                return mongoTemplate.stream(query, MongoDbTicketDocument.class, map);
            })
            .map(ticket -> decodeTicket(deserializeTicket(ticket.getJson(), ticket.getType())))
            .filter(ticket -> !ticket.isExpired());
    }
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.
support/cas-server-support-mongo-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/MongoDbTicketRegistry.java