use of org.apereo.cas.support.events.ticket.CasTicketGrantingTicketCreatedEvent in project cas by apereo.
the class AbstractCasEventRepositoryTests method verifySave.
@Test
public void verifySave() {
final TicketGrantingTicket ticket = new MockTicketGrantingTicket("casuser");
final CasTicketGrantingTicketCreatedEvent event = new CasTicketGrantingTicketCreatedEvent(this, ticket);
final CasEvent dto = new CasEvent();
dto.setType(event.getClass().getCanonicalName());
dto.putTimestamp(event.getTimestamp());
dto.putCreationTime(event.getTicketGrantingTicket().getCreationTime());
dto.putId(event.getTicketGrantingTicket().getId());
dto.setPrincipalId(event.getTicketGrantingTicket().getAuthentication().getPrincipal().getId());
getRepositoryInstance().save(dto);
final Collection<CasEvent> col = getRepositoryInstance().load();
assertEquals(col.size(), 1);
assertFalse(col.stream().findFirst().get().getProperties().isEmpty());
}
use of org.apereo.cas.support.events.ticket.CasTicketGrantingTicketCreatedEvent in project cas by apereo.
the class DefaultCentralAuthenticationService method createTicketGrantingTicket.
@Audit(action = "TICKET_GRANTING_TICKET", actionResolverName = "CREATE_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName = "CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER")
@Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER")
@Counted(name = "CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic = true)
@Override
public TicketGrantingTicket createTicketGrantingTicket(final AuthenticationResult authenticationResult) throws AuthenticationException, AbstractTicketException {
final Authentication authentication = authenticationResult.getAuthentication();
final Service service = authenticationResult.getService();
AuthenticationCredentialsLocalBinder.bindCurrent(authentication);
if (service != null) {
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
RegisteredServiceAccessStrategyUtils.ensurePrincipalAccessIsAllowedForService(service, registeredService, authentication);
}
final TicketGrantingTicketFactory factory = this.ticketFactory.get(TicketGrantingTicket.class);
final TicketGrantingTicket ticketGrantingTicket = factory.create(authentication);
this.ticketRegistry.addTicket(ticketGrantingTicket);
doPublishEvent(new CasTicketGrantingTicketCreatedEvent(this, ticketGrantingTicket));
return ticketGrantingTicket;
}
Aggregations