class HttpBasicPassTicketScheme implements AbstractAuthenticationScheme {

    @Override
    public AuthenticationCommand createCommand(Authentication authentication, Supplier<QueryResponse> tokenSupplier) {
        final long before = System.currentTimeMillis();
        final QueryResponse token = tokenSupplier.get();

        if (token == null) {
            return AuthenticationCommand.EMPTY;
        }

        final String applId = authentication.getApplid();
        final String userId = token.getUserId();
        String passTicket;
        try {
            passTicket = passTicketService.generate(userId, applId);
        } catch (IRRPassTicketGenerationException e) {
            throw new PassTicketException(
                String.format("Could not generate PassTicket for user ID %s and APPLID %s", userId, applId), e
            );
        }
        final String encoded = Base64.getEncoder()
            .encodeToString((userId + ":" + passTicket).getBytes(StandardCharsets.UTF_8));
        final String value = "Basic " + encoded;

        final long expiredAt = Math.min(before + authConfigurationProperties.getPassTicket().getTimeout() * 1000,
            token.getExpiration().getTime());

        return new PassTicketCommand(value, cookieName, expiredAt);
    }

    public  HttpBasicPassTicketScheme(
        PassTicketService passTicketService,
        AuthConfigurationProperties authConfigurationProperties
    );

}