All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apereo.cas.ticket.registry.JmsTicketRegistry Maven / Gradle / Ivy

package org.apereo.cas.ticket.registry;

import org.apereo.cas.JmsTicketRegistryQueueIdentifier;
import org.apereo.cas.ticket.Ticket;
import org.apereo.cas.ticket.registry.queue.AddTicketMessageQueueCommand;
import org.apereo.cas.ticket.registry.queue.DeleteTicketMessageQueueCommand;
import org.apereo.cas.ticket.registry.queue.DeleteTicketsMessageQueueCommand;
import org.apereo.cas.ticket.registry.queue.UpdateTicketMessageQueueCommand;
import org.apereo.cas.util.crypto.CipherExecutor;

import lombok.extern.slf4j.Slf4j;
import lombok.val;

/**
 * This is {@link JmsTicketRegistry}.
 *
 * @author Misagh Moayyed
 * @since 5.2.0
 */
@Slf4j
public class JmsTicketRegistry extends DefaultTicketRegistry {


    private final JmsTicketRegistryPublisher ticketPublisher;
    private final JmsTicketRegistryQueueIdentifier id;

    public JmsTicketRegistry(final JmsTicketRegistryPublisher publisher, final JmsTicketRegistryQueueIdentifier id,
                             final CipherExecutor cipherExecutor) {
        super(cipherExecutor);
        this.ticketPublisher = publisher;
        this.id = id;
    }

    @Override
    public void addTicket(final Ticket ticket) {
        super.addTicket(ticket);
        ticketPublisher.publishMessageToQueue(new AddTicketMessageQueueCommand(id, ticket));
    }

    @Override
    public boolean deleteSingleTicket(final String ticketId) {
        val result = super.deleteSingleTicket(ticketId);
        ticketPublisher.publishMessageToQueue(new DeleteTicketMessageQueueCommand(id, ticketId));
        return result;
    }

    @Override
    public long deleteAll() {
        val result = super.deleteAll();
        ticketPublisher.publishMessageToQueue(new DeleteTicketsMessageQueueCommand(id));
        return result;
    }

    @Override
    public Ticket updateTicket(final Ticket ticket) {
        val result = super.updateTicket(ticket);
        ticketPublisher.publishMessageToQueue(new UpdateTicketMessageQueueCommand(id, ticket));
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy