Search in sources :

Example 1 with SerializableDocument

use of com.couchbase.client.java.document.SerializableDocument in project cas by apereo.

the class CouchbaseTicketRegistry method addTicket.

@Override
public void addTicket(final Ticket ticketToAdd) {
    LOGGER.debug("Adding ticket [{}]", ticketToAdd);
    try {
        final Ticket ticket = encodeTicket(ticketToAdd);
        final SerializableDocument document = SerializableDocument.create(ticket.getId(), getTimeToLive(ticketToAdd), ticket);
        LOGGER.debug("Created document for ticket [{}]. Upserting into bucket [{}]", ticketToAdd, this.couchbase.bucket().name());
        this.couchbase.bucket().upsert(document);
    } catch (final Exception e) {
        LOGGER.error("Failed adding [{}]: [{}]", ticketToAdd, e);
    }
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) ProxyTicket(org.apereo.cas.ticket.proxy.ProxyTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Ticket(org.apereo.cas.ticket.Ticket) SerializableDocument(com.couchbase.client.java.document.SerializableDocument)

Example 2 with SerializableDocument

use of com.couchbase.client.java.document.SerializableDocument in project cas by apereo.

the class CouchbaseTicketRegistry method updateTicket.

@Override
public Ticket updateTicket(final Ticket ticket) {
    LOGGER.debug("Updating ticket [{}]", ticket);
    try {
        final SerializableDocument document = SerializableDocument.create(ticket.getId(), getTimeToLive(ticket), ticket);
        LOGGER.debug("Upserting document [{}] into couchbase bucket [{}]", document.id(), this.couchbase.bucket().name());
        this.couchbase.bucket().upsert(document);
    } catch (final Exception e) {
        LOGGER.error("Failed updating [{}]: [{}]", ticket, e);
    }
    return ticket;
}
Also used : SerializableDocument(com.couchbase.client.java.document.SerializableDocument)

Example 3 with SerializableDocument

use of com.couchbase.client.java.document.SerializableDocument in project cas by apereo.

the class CouchbaseTicketRegistry method getTicket.

@Override
public Ticket getTicket(final String ticketId) {
    try {
        LOGGER.debug("Locating ticket id [{}]", ticketId);
        final String encTicketId = encodeTicketId(ticketId);
        if (encTicketId == null) {
            LOGGER.debug("Ticket id [{}] could not be found", ticketId);
            return null;
        }
        final SerializableDocument document = this.couchbase.bucket().get(encTicketId, SerializableDocument.class);
        if (document != null) {
            final Ticket t = (Ticket) document.content();
            LOGGER.debug("Got ticket [{}] from the registry.", t);
            return t;
        }
        LOGGER.debug("Ticket [{}] not found in the registry.", encTicketId);
        return null;
    } catch (final Exception e) {
        LOGGER.error("Failed fetching [{}]: [{}]", ticketId, e);
        return null;
    }
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) ProxyTicket(org.apereo.cas.ticket.proxy.ProxyTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Ticket(org.apereo.cas.ticket.Ticket) SerializableDocument(com.couchbase.client.java.document.SerializableDocument)

Aggregations

SerializableDocument (com.couchbase.client.java.document.SerializableDocument)3 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)2 Ticket (org.apereo.cas.ticket.Ticket)2 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)2 ProxyGrantingTicket (org.apereo.cas.ticket.proxy.ProxyGrantingTicket)2 ProxyTicket (org.apereo.cas.ticket.proxy.ProxyTicket)2