class AbstractCasRestClient extends DirectClient {

    @Getter
    @Setter
    protected CasConfiguration configuration;

    /**
     * <p>destroyTicketGrantingTicket.</p>
     *
     * @param profile a {@link CasRestProfile} object
     * @param context a {@link WebContext} object
     */
    public void destroyTicketGrantingTicket(final CasRestProfile profile, final WebContext context) {
        HttpURLConnection connection = null;
        try {
            val endpointURL = new URL(configuration.computeFinalRestUrl(context));
            val deleteURL = new URL(endpointURL, endpointURL.getPath() + "/" + profile.getTicketGrantingTicketId());
            connection = HttpUtils.openDeleteConnection(deleteURL);
            val responseCode = connection.getResponseCode();
            if (responseCode != HttpConstants.OK) {
                throw new TechnicalException("TGT delete request for `" + profile + "` failed: " +
                        HttpUtils.buildHttpErrorMessage(connection));
            }
        } catch (final IOException e) {
            throw new TechnicalException(e);
        } finally {
            HttpUtils.closeConnection(connection);
        }
    }

    /**
     * <p>requestServiceTicket.</p>
     *
     * @param serviceURL a {@link String} object
     * @param profile a {@link CasRestProfile} object
     * @param context a {@link WebContext} object
     * @return a {@link TokenCredentials} object
     */
    public TokenCredentials requestServiceTicket(final String serviceURL, final CasRestProfile profile, final WebContext context) {<FILL_FUNCTION_BODY>}

    /**
     * <p>validateServiceTicket.</p>
     *
     * @param serviceURL a {@link String} object
     * @param ticket a {@link TokenCredentials} object
     * @param context a {@link WebContext} object
     * @return a {@link CasProfile} object
     */
    public CasProfile validateServiceTicket(final String serviceURL, final TokenCredentials ticket, final WebContext context) {
        try {
            val assertion = configuration.retrieveTicketValidator(context).validate(ticket.getToken(), serviceURL);
            val principal = assertion.getPrincipal();
            val casProfile = new CasProfile();
            casProfile.setId(ProfileHelper.sanitizeIdentifier(principal.getName()));
            casProfile.addAttributes(principal.getAttributes());
            return casProfile;
        } catch (final TicketValidationException e) {
            throw new TechnicalException(e);
        }
    }
}

        HttpURLConnection connection = null;
        try {
            val endpointURL = new URL(configuration.computeFinalRestUrl(context));
            val ticketURL = new URL(endpointURL, endpointURL.getPath() + "/" + profile.getTicketGrantingTicketId());

            connection = HttpUtils.openPostConnection(ticketURL);
            val payload = HttpUtils.encodeQueryParam("service", serviceURL);

            val out = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8));
            out.write(payload);
            out.close();

            val responseCode = connection.getResponseCode();
            if (responseCode == HttpConstants.OK) {
                try (var in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
                    return new TokenCredentials(in.readLine());
                }
            }
            throw new TechnicalException("Service ticket request for `" + profile + "` failed: " +
                    HttpUtils.buildHttpErrorMessage(connection));
        } catch (final IOException e) {
            throw new TechnicalException(e);
        } finally {
            HttpUtils.closeConnection(connection);
        }
    
<methods>public non-sealed void <init>() ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getLogoutAction(CallContext, org.pac4j.core.profile.UserProfile, java.lang.String) ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getRedirectionAction(CallContext) ,public final org.pac4j.core.exception.http.HttpAction processLogout(CallContext, org.pac4j.core.credentials.Credentials) <variables>