Search in sources :

Example 1 with ProxyGrantingTicket

use of org.apereo.cas.ticket.proxy.ProxyGrantingTicket in project cas by apereo.

the class LogoutManagerImpl method performLogoutForTicket.

private void performLogoutForTicket(final TicketGrantingTicket ticket, final List<LogoutRequest> logoutRequests) {
    ticket.getServices().entrySet().stream().filter(entry -> entry.getValue() instanceof WebApplicationService).forEach(entry -> {
        final Service service = entry.getValue();
        LOGGER.debug("Handling single logout callback for [{}]", service);
        final LogoutRequest logoutRequest = this.singleLogoutServiceMessageHandler.handle((WebApplicationService) service, entry.getKey());
        if (logoutRequest != null) {
            LOGGER.debug("Captured logout request [{}]", logoutRequest);
            logoutRequests.add(logoutRequest);
        }
    });
    final Collection<ProxyGrantingTicket> proxyGrantingTickets = ticket.getProxyGrantingTickets();
    if (proxyGrantingTickets.isEmpty()) {
        LOGGER.debug("There are no proxy-granting tickets associated with [{}] to process for single logout", ticket.getId());
    } else {
        proxyGrantingTickets.forEach(proxyGrantingTicket -> performLogoutForTicket(proxyGrantingTicket, logoutRequests));
    }
}
Also used : WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) List(java.util.List) Logger(org.slf4j.Logger) Service(org.apereo.cas.authentication.principal.Service) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) CompressionUtils(org.apereo.cas.util.CompressionUtils) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) Collections(java.util.Collections) ArrayList(java.util.ArrayList) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) Service(org.apereo.cas.authentication.principal.Service) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket)

Example 2 with ProxyGrantingTicket

use of org.apereo.cas.ticket.proxy.ProxyGrantingTicket in project cas by apereo.

the class JpaTicketRegistryTests method grantProxyGrantingTicketInTransaction.

private ProxyGrantingTicket grantProxyGrantingTicketInTransaction(final ServiceTicket parent) {
    return new TransactionTemplate(txManager).execute(status -> {
        final ProxyGrantingTicket pgt = newPGT(parent);
        ticketRegistry.addTicket(pgt);
        return pgt;
    });
}
Also used : TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket)

Example 3 with ProxyGrantingTicket

use of org.apereo.cas.ticket.proxy.ProxyGrantingTicket in project cas by apereo.

the class HazelcastTicketRegistryReplicationTests method verifyDeleteTicketWithPGT.

@Test
public void verifyDeleteTicketWithPGT() {
    final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
    this.hzTicketRegistry1.addTicket(new TicketGrantingTicketImpl(TGT_ID, a, new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.hzTicketRegistry1.getTicket(TGT_ID, TicketGrantingTicket.class);
    final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
    final ServiceTicket st1 = tgt.grantServiceTicket(ST_ID_1, service, new NeverExpiresExpirationPolicy(), false, true);
    this.hzTicketRegistry1.addTicket(st1);
    assertNotNull(this.hzTicketRegistry1.getTicket(TGT_ID, TicketGrantingTicket.class));
    assertNotNull(this.hzTicketRegistry1.getTicket(ST_ID_1, ServiceTicket.class));
    final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket(PGT_ID_1, a, new NeverExpiresExpirationPolicy());
    assertEquals(a, pgt.getAuthentication());
    this.hzTicketRegistry1.addTicket(pgt);
    this.hzTicketRegistry1.updateTicket(tgt);
    assertSame(3, this.hzTicketRegistry1.deleteTicket(tgt.getId()));
    assertNull(this.hzTicketRegistry1.getTicket(TGT_ID, TicketGrantingTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket(ST_ID_1, ServiceTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket(PGT_ID_1, ProxyGrantingTicket.class));
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) Service(org.apereo.cas.authentication.principal.Service) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with ProxyGrantingTicket

use of org.apereo.cas.ticket.proxy.ProxyGrantingTicket in project cas by apereo.

the class AbstractTicketRegistry method deleteProxyGrantingTicketFromParent.

private void deleteProxyGrantingTicketFromParent(final ProxyGrantingTicket ticket) {
    final ProxyGrantingTicket thePgt = ticket;
    thePgt.getTicketGrantingTicket().getProxyGrantingTickets().remove(thePgt.getId());
    updateTicket(thePgt.getTicketGrantingTicket());
}
Also used : ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket)

Example 5 with ProxyGrantingTicket

use of org.apereo.cas.ticket.proxy.ProxyGrantingTicket in project cas by apereo.

the class AbstractTicketRegistry method deleteTicket.

@Override
public int deleteTicket(final Ticket ticket) throws Exception {
    val count = new AtomicInteger(0);
    if (ticket instanceof TicketGrantingTicket) {
        LOGGER.debug("Removing children of ticket [{}] from the registry.", ticket.getId());
        val tgt = (TicketGrantingTicket) ticket;
        count.addAndGet(deleteChildren(tgt));
        if (ticket instanceof ProxyGrantingTicket) {
            deleteProxyGrantingTicketFromParent((ProxyGrantingTicket) ticket);
        } else {
            deleteLinkedProxyGrantingTickets(count, tgt);
        }
    }
    LOGGER.debug("Removing ticket [{}] from the registry.", ticket);
    if (deleteSingleTicket(ticket.getId())) {
        count.incrementAndGet();
    }
    return count.intValue();
}
Also used : lombok.val(lombok.val) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket)

Aggregations

ProxyGrantingTicket (org.apereo.cas.ticket.proxy.ProxyGrantingTicket)13 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)9 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)7 Test (org.junit.Test)6 Service (org.apereo.cas.authentication.principal.Service)5 Authentication (org.apereo.cas.authentication.Authentication)4 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)4 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)4 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)4 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)4 lombok.val (lombok.val)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 InvalidTicketException (org.apereo.cas.ticket.InvalidTicketException)2 ProxyTicket (org.apereo.cas.ticket.proxy.ProxyTicket)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)1