@Override public Ticket getTicket(final String ticketId) { return this.ticketRegistry.getTicket(ticketId); }
@Override public boolean deleteSingleTicket(final String ticketId) { if (this.ticketRegistry.deleteTicket(ticketId) > 0) { return true; } return false; }
@Override public Collection<Ticket> getTickets() { return this.ticketRegistry.getTickets(); }
throws InvalidTicketException { Assert.notNull(ticketId, "ticketId cannot be null"); final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz); synchronized (ticket) { if (ticket.isExpired()) { this.ticketRegistry.deleteTicket(ticketId); logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId); throw new InvalidTicketException(ticketId);
@Audit( action = "PROXY_GRANTING_TICKET", actionResolverName = "CREATE_PROXY_GRANTING_TICKET_RESOLVER", resourceResolverName = "CREATE_PROXY_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "CREATE_PROXY_GRANTING_TICKET_TIMER") @Metered(name = "CREATE_PROXY_GRANTING_TICKET_METER") @Counted(name = "CREATE_PROXY_GRANTING_TICKET_COUNTER", monotonic = true) @Override public ProxyGrantingTicket createProxyGrantingTicket(final String serviceTicketId, final AuthenticationContext context) throws AuthenticationException, AbstractTicketException { final ServiceTicket serviceTicket = this.ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class); if (serviceTicket == null || serviceTicket.isExpired()) { logger.debug("ServiceTicket [{}] has expired or cannot be found in the ticket registry", serviceTicketId); throw new InvalidTicketException(serviceTicketId); } final RegisteredService registeredService = this.servicesManager .findServiceBy(serviceTicket.getService()); verifyRegisteredServiceProperties(registeredService, serviceTicket.getService()); if (!registeredService.getProxyPolicy().isAllowedToProxy()) { logger.warn("ServiceManagement: Service [{}] attempted to proxy, but is not allowed.", serviceTicket.getService().getId()); throw new UnauthorizedProxyingException(); } final Authentication authentication = context.getAuthentication(); final ProxyGrantingTicketFactory factory = this.ticketFactory.get(ProxyGrantingTicket.class); final ProxyGrantingTicket proxyGrantingTicket = factory.create(serviceTicket, authentication); logger.debug("Generated proxy granting ticket [{}] based off of [{}]", proxyGrantingTicket, serviceTicketId); this.ticketRegistry.addTicket(proxyGrantingTicket); doPublishEvent(new CasProxyGrantingTicketCreatedEvent(this, proxyGrantingTicket)); return proxyGrantingTicket; }
@Override public void addTicket(final Ticket ticket) { if (ticket instanceof TicketGrantingTicket) { final TicketGrantingTicket ticketGrantingTicket = (TicketGrantingTicket) ticket; final String ticketId = ticketGrantingTicket.getId(); final String userName = ticketGrantingTicket.getAuthentication().getPrincipal().getId().toLowerCase(); logger.debug("Creating mapping ticket {} to user name {}", ticketId, userName); this.cache.put(ticketId, userName); } this.ticketRegistry.addTicket(ticket); }
verifyRegisteredServiceProperties(registeredService, service); final ServiceTicket serviceTicket = this.ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class); this.ticketRegistry.deleteTicket(serviceTicketId);
@Override @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) public TicketGrantingTicket createTicketGrantingTicket(final Credential... credentials) throws TicketException { final MultiFactorCredentials mfaCredentials = (MultiFactorCredentials) credentials[0]; final Authentication authentication = mfaCredentials.getAuthentication(); if (authentication == null) { throw new TicketCreationException(new RuntimeException("Authentication cannot be null")); } final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl( this.ticketGrantingTicketUniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX), authentication, this.ticketGrantingTicketExpirationPolicy); this.ticketRegistry.addTicket(ticketGrantingTicket); return ticketGrantingTicket; }
@Override /** {@inheritDoc} */ public Authentication getAuthenticationFrom(final String ticketGrantingTicketId) throws RuntimeException { final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
@Override public void deleteExpiredTicketGrantingTicket(String ticketGrantingTicketId) { if (ticketGrantingTicketExistsAndExpired(ticketGrantingTicketId)) { this.ticketRegistry.deleteTicket(ticketGrantingTicketId); } }
@Transactional(readOnly = true, transactionManager = "ticketTransactionManager") @Timed(name = "GET_TICKETS_TIMER") @Metered(name = "GET_TICKETS_METER") @Counted(name = "GET_TICKETS_COUNTER", monotonic = true) @Override public Collection<Ticket> getTickets(final Predicate<Ticket> predicate) { final Collection<Ticket> c = new HashSet<>(this.ticketRegistry.getTickets()); final Iterator<Ticket> it = c.iterator(); while (it.hasNext()) { if (!predicate.apply(it.next())) { it.remove(); } } return c; }
@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 AuthenticationContext context) throws AuthenticationException, AbstractTicketException { final Authentication authentication = context.getAuthentication(); 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; } }
@Override /** {@inheritDoc} */ public Authentication getAuthenticationFrom(String ticketGrantingTicketId) throws RuntimeException { TicketGrantingTicket tgt = (TicketGrantingTicket) this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
@Override public Integer apply(@Nullable final Ticket ticket) { int count = 0; if (ticket != null && ticket.isExpired()) { if (ticket instanceof TicketGrantingTicket) { logger.debug("Cleaning up expired ticket-granting ticket [{}]", ticket.getId()); logoutManager.performLogout((TicketGrantingTicket) ticket); count += registry.deleteTicket(ticket.getId()); } else if (ticket instanceof ServiceTicket) { logger.debug("Cleaning up expired service ticket [{}]", ticket.getId()); count += registry.deleteTicket(ticket.getId()); } else { logger.warn("Unknown ticket type [{} found to clean", ticket.getClass().getSimpleName()); } } return count; } });
@Override public List<TicketGrantingTicket> getNonExpiredTicketGrantingTickets() throws BulkRetrievalOfTicketsNotSupportedException { final List<TicketGrantingTicket> tgts = new ArrayList<TicketGrantingTicket>(); try { for (Ticket ticket : this.ticketRegistry.getTickets()) { if ((ticket instanceof TicketGrantingTicket) && !ticket.isExpired()) { tgts.add((TicketGrantingTicket) ticket); } } } catch (UnsupportedOperationException e) { throw new BulkRetrievalOfTicketsNotSupportedException("The underlying implementation of <TicketRegistry> does not support a bulk retrieval of tickets", e); } return tgts; } }
serviceTicket.getId(), service.getId(), principal.getId()); this.ticketRegistry.addTicket(serviceTicket); logger.debug("Added service ticket {} to ticket registry", serviceTicket.getId());
@Override public Authentication getAuthenticationFrom(final String ticketGrantingTicketId) throws RuntimeException { final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
logger.debug("Ticket found. Processing logout requests and then deleting the ticket..."); final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket); this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
logger.debug("Cleaning up tickets from an instance of {}", registry); final Collection<Integer> deletedTicketCounts = Collections2.transform(registry.getTickets(), new Function<Ticket, Integer>() { @Override public Integer apply(@Nullable final Ticket ticket) {
this.ticketRegistry.addTicket(proxyTicket);