@Override public final String getId() { return this.ticket.getId(); }
@Override public boolean apply(@Nullable final Ticket ticket) { if (ticket instanceof TicketGrantingTicket) { return !ticket.isExpired(); } return false; } });
@Override public int compareTo(final Ticket o) { return this.ticket.compareTo(o); } }
@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 final TicketGrantingTicket getGrantingTicket() { final TicketGrantingTicket old = this.ticket.getGrantingTicket(); if (old == null || !callback) { return old; } return this.ticketRegistry.getTicket(old.getId(), Ticket.class); }
@Override public final long getCreationTime() { return this.ticket.getCreationTime(); }
@Override public final int getCountOfUses() { return this.ticket.getCountOfUses(); }
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { final WebApplicationService service = this.argExtractor.extractService(request); if (service == null) { return super.handleRequest(request, response); } Ticket st = this.ticketRegistry.getTicket(service.getArtifactId()); if (st == null) { return super.handleRequest(request, response); } //Make the tgt available in ThreadLocal for access in "onSuccessfulValidation()" tgtHolder.set(st.getGrantingTicket()); return super.handleRequest(request, response); }
@Override public int compareTo(final Ticket o) { return this.id.compareTo(o.getId()); } }
@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; } }
@Override public int compareTo(final Ticket o) { return getId().compareTo(o.getId()); } }
/** * Delete a single ticket instance from the store. * * @param ticketId the ticket id * @return the boolean */ public boolean deleteSingleTicket(final Ticket ticketId) { return deleteSingleTicket(ticketId.getId()); }
if (ticket.isExpired()) { this.ticketRegistry.deleteTicket(ticketId); logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
@Override protected void updateTicket(final Ticket ticket) { try { this.cache.put(FQN_TICKET, ticket.getId(), ticket); } catch (final CacheException e) { throw new RuntimeException(e); } }
/** * {@inheritDoc} * Either the element is removed from the cache * or it's not found in the cache and is already removed. * Thus the result of this op would always be true. */ @Override public boolean deleteSingleTicket(final String ticketId) { final Ticket ticket = getTicket(ticketId); if (ticket == null) { logger.debug("Ticket {} cannot be retrieved from the cache", ticketId); return true; } if (this.ticketGrantingTicketsCache.remove(ticket.getId())) { logger.debug("Ticket {} is removed", ticket.getId()); } if (this.serviceTicketsCache.remove(ticket.getId())) { logger.debug("Ticket {} is removed", ticket.getId()); } return true; }
@Override public final boolean equals(final Object object) { if (object == null) { return false; } if (object == this) { return true; } if (!(object instanceof TicketGrantingTicket)) { return false; } final Ticket ticket = (Ticket) object; return new EqualsBuilder() .append(ticket.getId(), this.getId()) .isEquals(); } }