Search in sources :

Example 11 with TicketDefinition

use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.

the class DynamoDbTicketRegistryFacilitator method deleteAll.

/**
     * Delete all.
     *
     * @return the int
     */
public int deleteAll() {
    final AtomicInteger count = new AtomicInteger();
    final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
    metadata.forEach(r -> {
        final ScanRequest scan = new ScanRequest(r.getProperties().getStorageName());
        LOGGER.debug("Submitting scan request [{}] to table [{}]", scan, r.getProperties().getStorageName());
        count.addAndGet(this.amazonDynamoDBClient.scan(scan).getCount());
    });
    createTicketTables(true);
    return count.get();
}
Also used : ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 12 with TicketDefinition

use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.

the class DynamoDbTicketRegistryFacilitator method put.

/**
     * Put ticket.
     *
     * @param ticket        the ticket
     * @param encodedTicket the encoded ticket
     */
public void put(final Ticket ticket, final Ticket encodedTicket) {
    final TicketDefinition metadata = this.ticketCatalog.find(ticket);
    final Map<String, AttributeValue> values = buildTableAttributeValuesMapFromTicket(ticket, encodedTicket);
    LOGGER.debug("Adding ticket id [{}] with attribute values [{}]", encodedTicket.getId(), values);
    final PutItemRequest putItemRequest = new PutItemRequest(metadata.getProperties().getStorageName(), values);
    LOGGER.debug("Submitting put request [{}] for ticket id [{}]", putItemRequest, encodedTicket.getId());
    final PutItemResult putItemResult = amazonDynamoDBClient.putItem(putItemRequest);
    LOGGER.debug("Ticket added with result [{}]", putItemResult);
    getAll();
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) PutItemRequest(com.amazonaws.services.dynamodbv2.model.PutItemRequest) PutItemResult(com.amazonaws.services.dynamodbv2.model.PutItemResult) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 13 with TicketDefinition

use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.

the class DynamoDbTicketRegistryFacilitator method getAll.

/**
     * Gets all.
     *
     * @return the all
     */
public Collection<Ticket> getAll() {
    final Collection<Ticket> tickets = new ArrayList<>();
    final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
    metadata.forEach(r -> {
        final ScanRequest scan = new ScanRequest(r.getProperties().getStorageName());
        LOGGER.debug("Scanning table with request [{}]", scan);
        final ScanResult result = this.amazonDynamoDBClient.scan(scan);
        LOGGER.debug("Scanned table with result [{}]", scan);
        tickets.addAll(result.getItems().stream().map(this::deserializeTicket).collect(Collectors.toList()));
    });
    return tickets;
}
Also used : Ticket(org.apereo.cas.ticket.Ticket) ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) ArrayList(java.util.ArrayList) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Example 14 with TicketDefinition

use of org.apereo.cas.ticket.TicketDefinition in project cas by apereo.

the class CasWsSecurityTokenTicketCatalogConfiguration method configureTicketCatalog.

@Override
public void configureTicketCatalog(final TicketCatalog plan) {
    LOGGER.debug("Registering core WS security token ticket definitions...");
    final TicketDefinition defn = buildTicketDefinition(plan, SecurityTokenTicket.PREFIX, DefaultSecurityTokenTicket.class);
    defn.getProperties().setStorageName("wsSecurityTokenTicketsCache");
    defn.getProperties().setStorageTimeout(casProperties.getTicket().getTgt().getMaxTimeToLiveInSeconds());
    registerTicketDefinition(plan, defn);
}
Also used : 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