Search in sources :

Example 1 with LogoutManager

use of org.apereo.cas.logout.LogoutManager in project cas by apereo.

the class CasCoreTicketsConfiguration method ticketRegistry.

@ConditionalOnMissingBean(name = "ticketRegistry")
@Bean
public TicketRegistry ticketRegistry() {
    LOGGER.warn("Runtime memory is used as the persistence storage for retrieving and managing tickets. " + "Tickets that are issued during runtime will be LOST when the web server is restarted. This MAY impact SSO functionality.");
    final TicketRegistryProperties.InMemory mem = casProperties.getTicket().getRegistry().getInMemory();
    final CipherExecutor cipher = CoreTicketUtils.newTicketRegistryCipherExecutor(mem.getCrypto(), "inMemory");
    if (mem.isCache()) {
        final LogoutManager logoutManager = applicationContext.getBean("logoutManager", LogoutManager.class);
        return new CachingTicketRegistry(cipher, logoutManager);
    }
    return new DefaultTicketRegistry(mem.getInitialCapacity(), mem.getLoadFactor(), mem.getConcurrency(), cipher);
}
Also used : CipherExecutor(org.apereo.cas.CipherExecutor) ProtocolTicketCipherExecutor(org.apereo.cas.util.cipher.ProtocolTicketCipherExecutor) DefaultTicketRegistry(org.apereo.cas.ticket.registry.DefaultTicketRegistry) LogoutManager(org.apereo.cas.logout.LogoutManager) CachingTicketRegistry(org.apereo.cas.ticket.registry.CachingTicketRegistry) TicketRegistryProperties(org.apereo.cas.configuration.model.core.ticket.registry.TicketRegistryProperties) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with LogoutManager

use of org.apereo.cas.logout.LogoutManager in project cas by apereo.

the class CentralAuthenticationServiceImplTests method verifyDestroyRemoteRegistry.

/**
 * This test checks that the TGT destruction happens properly for a remote registry.
 * It previously failed when the deletion happens before the ticket was marked expired because an update was necessary for that.
 */
@Test
public void verifyDestroyRemoteRegistry() throws AbstractTicketException, AuthenticationException {
    final MockOnlyOneTicketRegistry registry = new MockOnlyOneTicketRegistry();
    final TicketGrantingTicketImpl tgt = new TicketGrantingTicketImpl("TGT-1", mock(Authentication.class), mock(ExpirationPolicy.class));
    final LogoutManager logoutManager = mock(LogoutManager.class);
    when(logoutManager.performLogout(any(TicketGrantingTicket.class))).thenAnswer(invocation -> {
        tgt.markTicketExpired();
        registry.updateTicket(tgt);
        return null;
    });
    registry.addTicket(tgt);
    final DefaultCentralAuthenticationService cas = new DefaultCentralAuthenticationService(mock(ApplicationEventPublisher.class), registry, null, logoutManager, null, null, null, null, null, mock(AuditableExecution.class));
    cas.destroyTicketGrantingTicket(tgt.getId());
}
Also used : Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) LogoutManager(org.apereo.cas.logout.LogoutManager) MockOnlyOneTicketRegistry(org.apereo.cas.util.MockOnlyOneTicketRegistry) ExpirationPolicy(org.apereo.cas.ticket.ExpirationPolicy) AuditableExecution(org.apereo.cas.audit.AuditableExecution) Test(org.junit.Test)

Aggregations

LogoutManager (org.apereo.cas.logout.LogoutManager)2 CipherExecutor (org.apereo.cas.CipherExecutor)1 AuditableExecution (org.apereo.cas.audit.AuditableExecution)1 Authentication (org.apereo.cas.authentication.Authentication)1 TicketRegistryProperties (org.apereo.cas.configuration.model.core.ticket.registry.TicketRegistryProperties)1 ExpirationPolicy (org.apereo.cas.ticket.ExpirationPolicy)1 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)1 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)1 CachingTicketRegistry (org.apereo.cas.ticket.registry.CachingTicketRegistry)1 DefaultTicketRegistry (org.apereo.cas.ticket.registry.DefaultTicketRegistry)1 MockOnlyOneTicketRegistry (org.apereo.cas.util.MockOnlyOneTicketRegistry)1 ProtocolTicketCipherExecutor (org.apereo.cas.util.cipher.ProtocolTicketCipherExecutor)1 Test (org.junit.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1 Bean (org.springframework.context.annotation.Bean)1