@Override
    public <T extends Ticket> T create(final Service service, final Authentication authentication,
                                       final boolean credentialsProvided, final Class<T> clazz) throws Throwable {
        val expirationPolicyToUse = determineExpirationPolicyForService(service);
        val ticketId = produceTicketIdentifier(service, null, credentialsProvided);
        val result = new ServiceTicketImpl(ticketId, null, service, credentialsProvided, expirationPolicyToUse).setAuthentication(authentication);
        result.setTenantId(service.getTenant());
        if (!clazz.isAssignableFrom(result.getClass())) {
            throw new ClassCastException("Result [%s] is of type %s when we were expecting %s".formatted(result, result.getClass(), clazz));
        }
        result.markTicketStateless();
        return (T) result;
    }
The {@link DefaultServiceTicketFactory} is responsible for
creating {@link ServiceTicket} objects.

@author Misagh Moayyed
@since 4.2
core/cas-server-core-tickets-api/src/main/java/org/apereo/cas/ticket/factory/DefaultServiceTicketFactory.java