use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.
the class HazelcastTicketRegistry method addTicket.
@Override
public void addTicket(final Ticket ticket) {
LOGGER.debug("Adding ticket [{}] with ttl [{}s]", ticket.getId(), ticket.getExpirationPolicy().getTimeToLive());
final Ticket encTicket = encodeTicket(ticket);
final TicketDefinition metadata = this.ticketCatalog.find(ticket);
final IMap<String, Ticket> ticketMap = getTicketMapInstanceByMetadata(metadata);
ticketMap.set(encTicket.getId(), encTicket, ticket.getExpirationPolicy().getTimeToLive(), TimeUnit.SECONDS);
}
use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.
the class HazelcastTicketRegistry method deleteAll.
@Override
public long deleteAll() {
final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
final AtomicLong count = new AtomicLong();
metadata.forEach(r -> {
final IMap<String, Ticket> instance = getTicketMapInstanceByMetadata(r);
if (instance != null) {
count.addAndGet(instance.size());
instance.evictAll();
instance.clear();
}
});
return count.get();
}
use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.
the class JpaTicketRegistry method deleteAll.
@Override
public long deleteAll() {
final Collection<TicketDefinition> tkts = this.ticketCatalog.findAll();
final AtomicLong count = new AtomicLong();
tkts.forEach(t -> {
final String entityName = getTicketEntityName(t);
final Query query = entityManager.createQuery("delete from " + entityName);
LOGGER.debug("Deleting ticket entity [{}]", entityName);
count.addAndGet(query.executeUpdate());
});
return count.get();
}
use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.
the class JpaTicketRegistry method getTickets.
@Override
public Collection<Ticket> getTickets() {
final Collection<TicketDefinition> tkts = this.ticketCatalog.findAll();
final List<Ticket> tickets = new ArrayList<>();
tkts.forEach(t -> {
final Query query = this.entityManager.createQuery("select t from " + getTicketEntityName(t) + " t", t.getImplementationClass());
tickets.addAll(query.getResultList());
});
return tickets;
}
use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.
the class JpaTicketRegistry method deleteSingleTicket.
@Override
public boolean deleteSingleTicket(final String ticketId) {
final int totalCount;
final TicketDefinition md = this.ticketCatalog.find(ticketId);
if (md.getProperties().isCascade()) {
totalCount = deleteTicketGrantingTickets(ticketId);
} else {
final Query query = entityManager.createQuery("delete from " + getTicketEntityName(md) + " o where o.id = :id");
query.setParameter("id", ticketId);
totalCount = query.executeUpdate();
}
return totalCount != 0;
}
Aggregations