Search in sources :

Example 6 with TicketDefinition

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);
}
Also used : Ticket(org.apereo.cas.ticket.Ticket) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 7 with TicketDefinition

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();
}
Also used : Ticket(org.apereo.cas.ticket.Ticket) AtomicLong(java.util.concurrent.atomic.AtomicLong) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 8 with TicketDefinition

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();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Query(javax.persistence.Query) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 9 with TicketDefinition

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;
}
Also used : ServiceTicket(org.apereo.cas.ticket.ServiceTicket) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) Ticket(org.apereo.cas.ticket.Ticket) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 10 with TicketDefinition

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;
}
Also used : Query(javax.persistence.Query) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Aggregations

TicketDefinition (org.apereo.cas.ticket.TicketDefinition)14 Ticket (org.apereo.cas.ticket.Ticket)6 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)4 Query (javax.persistence.Query)4 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DeleteItemRequest (com.amazonaws.services.dynamodbv2.model.DeleteItemRequest)2 DeleteItemResult (com.amazonaws.services.dynamodbv2.model.DeleteItemResult)2 GetItemRequest (com.amazonaws.services.dynamodbv2.model.GetItemRequest)2 PutItemRequest (com.amazonaws.services.dynamodbv2.model.PutItemRequest)2 PutItemResult (com.amazonaws.services.dynamodbv2.model.PutItemResult)2 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)1 AttributeDefinition (com.amazonaws.services.dynamodbv2.model.AttributeDefinition)1 CreateTableRequest (com.amazonaws.services.dynamodbv2.model.CreateTableRequest)1 DeleteTableRequest (com.amazonaws.services.dynamodbv2.model.DeleteTableRequest)1 DescribeTableRequest (com.amazonaws.services.dynamodbv2.model.DescribeTableRequest)1