public BaseTicketEntity fromTicket(final Ticket encodedTicket, final Ticket realTicket) {
        val jsonBody = getTicketSerializationManager().serializeTicket(encodedTicket);
        val authentication = encodedTicket instanceof final AuthenticationAwareTicket authAware
            ? authAware.getAuthentication()
            : null;

        val parentTicket = encodedTicket instanceof final TicketGrantingTicketAwareTicket tgtAware
            ? tgtAware.getTicketGrantingTicket()
            : null;

        val expirationTime = realTicket.getExpirationPolicy().toMaximumExpirationTime(realTicket);
        val entity = FunctionUtils.doUnchecked(() -> getEntityClass().getDeclaredConstructor().newInstance());
        return entity
            .setId(encodedTicket.getId())
            .setParentId(Optional.ofNullable(parentTicket).map(Ticket::getId).orElse(null))
            .setBody(jsonBody)
            .setType(encodedTicket.getClass().getName())
            .setService(realTicket instanceof final ServiceAwareTicket sat && Objects.nonNull(sat.getService()) ? sat.getService().getId() : null)
            .setPrincipalId(Optional.ofNullable(authentication)
                .map(Authentication::getPrincipal)
                .map(Principal::getId)
                .orElse(null))
            .setExpirationTime(expirationTime)
            .setLastUsedTime(ObjectUtils.defaultIfNull(encodedTicket.getLastTimeUsed(), ZonedDateTime.now(Clock.systemUTC())))
            .setCreationTime(ObjectUtils.defaultIfNull(encodedTicket.getCreationTime(), ZonedDateTime.now(Clock.systemUTC())));
    }
From tickets objects to entity.

@param encodedTicket the ticket
@param realTicket    the real ticket
@return the jpa ticket entity
support/cas-server-support-jpa-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/JpaTicketEntityFactory.java