use of org.apereo.cas.ticket.Ticket in project cas by apereo.
the class TicketEncryptionDecryptionTests method checkSerializationOfStBase64Encode.
@Test
public void checkSerializationOfStBase64Encode() {
final MockServiceTicket st = new MockServiceTicket("serviceid", RegisteredServiceTestUtils.getService(), tgt);
final byte[] bytes = SerializationUtils.serializeAndEncodeObject(cipher, st);
final String string = EncodingUtils.encodeBase64(bytes);
assertNotNull(string);
final byte[] result = EncodingUtils.decodeBase64(string);
final Ticket obj = SerializationUtils.decodeAndDeserializeObject(result, cipher, Ticket.class);
assertNotNull(obj);
}
use of org.apereo.cas.ticket.Ticket in project cas by apereo.
the class TicketEncryptionDecryptionTests method checkSerializationOfSt.
@Test
public void checkSerializationOfSt() {
final MockServiceTicket st = new MockServiceTicket("serviceid", RegisteredServiceTestUtils.getService(), tgt);
final byte[] bytes = SerializationUtils.serializeAndEncodeObject(cipher, st);
final Ticket obj = SerializationUtils.decodeAndDeserializeObject(bytes, cipher, Ticket.class);
assertNotNull(obj);
}
use of org.apereo.cas.ticket.Ticket in project cas by apereo.
the class AbstractCentralAuthenticationService method getTicket.
@Transactional(transactionManager = "ticketTransactionManager", noRollbackFor = InvalidTicketException.class)
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name = "GET_TICKET_COUNTER", monotonic = true)
@Override
public <T extends Ticket> T getTicket(final String ticketId) throws InvalidTicketException {
Assert.notNull(ticketId, "ticketId cannot be null");
final Ticket ticket = this.ticketRegistry.getTicket(ticketId);
verifyTicketState(ticket, ticketId, null);
return (T) ticket;
}
use of org.apereo.cas.ticket.Ticket in project cas by apereo.
the class TicketGrantingTicketCheckAction method doExecute.
/**
* Determines whether the TGT in the flow request context is valid.
*
* @param requestContext Flow request context.
*
* @throws Exception in case ticket cannot be retrieved from the service layer
* @return {@link #NOT_EXISTS}, {@link #INVALID}, or {@link #VALID}.
*/
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
final String tgtId = WebUtils.getTicketGrantingTicketId(requestContext);
if (!StringUtils.hasText(tgtId)) {
return new Event(this, NOT_EXISTS);
}
String eventId = INVALID;
try {
final Ticket ticket = this.centralAuthenticationService.getTicket(tgtId, Ticket.class);
if (ticket != null && !ticket.isExpired()) {
eventId = VALID;
}
} catch (final AbstractTicketException e) {
LOGGER.trace("Could not retrieve ticket id [{}] from registry.", e.getMessage());
}
return new Event(this, eventId);
}
use of org.apereo.cas.ticket.Ticket 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);
}
}
Aggregations