code: protected <T extends Ticket> T produceTicket(final TicketGrantingTicket ticketGrantingTicket,
                                                   final Service service,
                                                   final boolean credentialProvided,
                                                   final String ticketId,
                                                   final Class<T> clazz) {
          val expirationPolicyToUse = determineExpirationPolicyForService(service);
  
          val result = ticketGrantingTicket.grantServiceTicket(
              ticketId,
              service,
              expirationPolicyToUse,
              credentialProvided,
              trackMostRecentSession);
  
          if (!clazz.isAssignableFrom(result.getClass())) {
              throw new ClassCastException("Result [" + result
                  + " is of type " + result.getClass()
                  + " when we were expecting " + clazz);
          }
          return (T) result;
      }
docs: Produce ticket.
  
  @param <T>                  the type parameter
  @param ticketGrantingTicket the ticket granting ticket
  @param service              the service
  @param credentialProvided   the credential provided
  @param ticketId             the ticket id
  @param clazz                the clazz
  @return the ticket