org.apereo.cas.ticket.registry.DynamoDbTicketRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cas-server-support-dynamodb-ticket-registry Show documentation
Show all versions of cas-server-support-dynamodb-ticket-registry Show documentation
cas-server-support-dynamodb-ticket-registry
package org.apereo.cas.ticket.registry;
import org.apereo.cas.ticket.Ticket;
import org.apereo.cas.util.LoggingUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.lang3.StringUtils;
import java.util.Collection;
import java.util.function.Predicate;
/**
* This is {@link DynamoDbTicketRegistry}.
*
* @author Misagh Moayyed
* @since 5.1.0
*/
@Slf4j
@RequiredArgsConstructor
public class DynamoDbTicketRegistry extends AbstractTicketRegistry {
private final DynamoDbTicketRegistryFacilitator dbTableService;
@Override
public void addTicketInternal(final Ticket ticket) {
try {
LOGGER.debug("Adding ticket [{}] with ttl [{}s]", ticket.getId(),
ticket.getExpirationPolicy().getTimeToLive());
val encTicket = encodeTicket(ticket);
this.dbTableService.put(ticket, encTicket);
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
}
}
@Override
public Ticket getTicket(final String ticketId, final Predicate predicate) {
val encTicketId = encodeTicketId(ticketId);
if (StringUtils.isBlank(encTicketId)) {
return null;
}
LOGGER.debug("Retrieving ticket [{}]", ticketId);
val ticket = this.dbTableService.get(ticketId, encTicketId);
val decodedTicket = decodeTicket(ticket);
if (predicate.test(decodedTicket)) {
return decodedTicket;
}
return null;
}
@Override
public long deleteAll() {
return this.dbTableService.deleteAll();
}
@Override
public Collection extends Ticket> getTickets() {
return decodeTickets(this.dbTableService.getAll());
}
@Override
public Ticket updateTicket(final Ticket ticket) throws Exception {
addTicket(ticket);
return ticket;
}
@Override
public boolean deleteSingleTicket(final String ticketIdToDelete) {
val ticketId = encodeTicketId(ticketIdToDelete);
return this.dbTableService.delete(ticketIdToDelete, ticketId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy