Search in sources :

Example 1 with CasTicketGrantingTicketCreatedEvent

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());
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) CasTicketGrantingTicketCreatedEvent(org.apereo.cas.support.events.ticket.CasTicketGrantingTicketCreatedEvent) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) CasEvent(org.apereo.cas.support.events.dao.CasEvent) Test(org.junit.Test)

Example 2 with CasTicketGrantingTicketCreatedEvent

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;
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) CasTicketGrantingTicketCreatedEvent(org.apereo.cas.support.events.ticket.CasTicketGrantingTicketCreatedEvent) Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) RegisteredService(org.apereo.cas.services.RegisteredService) Service(org.apereo.cas.authentication.principal.Service) TicketGrantingTicketFactory(org.apereo.cas.ticket.TicketGrantingTicketFactory) Audit(org.apereo.inspektr.audit.annotation.Audit) Counted(com.codahale.metrics.annotation.Counted) Metered(com.codahale.metrics.annotation.Metered) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

CasTicketGrantingTicketCreatedEvent (org.apereo.cas.support.events.ticket.CasTicketGrantingTicketCreatedEvent)2 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)2 Counted (com.codahale.metrics.annotation.Counted)1 Metered (com.codahale.metrics.annotation.Metered)1 Timed (com.codahale.metrics.annotation.Timed)1 Authentication (org.apereo.cas.authentication.Authentication)1 Service (org.apereo.cas.authentication.principal.Service)1 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)1 RegisteredService (org.apereo.cas.services.RegisteredService)1 CasEvent (org.apereo.cas.support.events.dao.CasEvent)1 TicketGrantingTicketFactory (org.apereo.cas.ticket.TicketGrantingTicketFactory)1 Audit (org.apereo.inspektr.audit.annotation.Audit)1 Test (org.junit.Test)1