@Override public final boolean isExpired() { final TicketGrantingTicket tgt = getGrantingTicket(); return this.expirationPolicy.isExpired(this) || (tgt != null && tgt.isExpired()) || isExpiredInternal(); }
@Override public <T extends TicketGrantingTicket> T create(final Authentication authentication) { final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl( this.ticketGrantingTicketUniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX), authentication, ticketGrantingTicketExpirationPolicy); return (T) ticketGrantingTicket; }
@Override public <T extends ProxyGrantingTicket> T create(final ServiceTicket serviceTicket, final Authentication authentication) { final String pgtId = this.ticketGrantingTicketUniqueTicketIdGenerator.getNewTicketId( ProxyGrantingTicket.PROXY_GRANTING_TICKET_PREFIX); final ProxyGrantingTicket proxyGrantingTicket = serviceTicket.grantProxyGrantingTicket(pgtId, authentication, this.ticketGrantingTicketExpirationPolicy); return (T) proxyGrantingTicket; }
@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 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 boolean isExpired() { if (!callback) { return this.ticket.isExpired(); } final TicketGrantingTicket t = getGrantingTicket(); return this.ticket.isExpired() || (t != null && t.isExpired()); }
/** * {@inheritDoc} * <p>The state of the ticket is affected by this operation and the * ticket will be considered used. The state update subsequently may * impact the ticket expiration policy in that, depending on the policy * configuration, the ticket may be considered expired. */ @Override public final synchronized ServiceTicket grantServiceTicket(final String id, final Service service, final ExpirationPolicy expirationPolicy, final boolean credentialsProvided, final boolean onlyTrackMostRecentSession) { final ServiceTicket serviceTicket = new ServiceTicketImpl(id, this, service, this.getCountOfUses() == 0 || credentialsProvided, expirationPolicy); updateServiceAndTrackSession(serviceTicket.getId(), service, onlyTrackMostRecentSession); return serviceTicket; }
/** * 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()); }
@Override public final String getId() { return this.ticket.getId(); }
@Override public ProxyTicket grantProxyTicket(final String id, final Service service, final ExpirationPolicy expirationPolicy, final boolean onlyTrackMostRecentSession) { final ProxyTicket serviceTicket = new ProxyTicketImpl(id, this, service, this.getCountOfUses() == 0, expirationPolicy); updateServiceAndTrackSession(serviceTicket.getId(), service, onlyTrackMostRecentSession); return serviceTicket; }
@Override public boolean apply(@Nullable final Ticket ticket) { if (ticket instanceof TicketGrantingTicket) { return !ticket.isExpired(); } return false; } });
@Override public ProxyGrantingTicket grantProxyGrantingTicket( final String id, final Authentication authentication, final ExpirationPolicy expirationPolicy) { synchronized (this) { if(this.grantedTicketAlready) { throw new IllegalStateException( "PGT already generated for this ST. Cannot grant more than one TGT for ST"); } this.grantedTicketAlready = Boolean.TRUE; } final ProxyGrantingTicket pgt = new ProxyGrantingTicketImpl(id, this.service, this.getGrantingTicket(), authentication, expirationPolicy); getGrantingTicket().getProxyGrantingTickets().add(pgt); return pgt; }
/** * Return if the TGT has no parent. * * @return if the TGT has no parent. */ @Override public final boolean isRoot() { return this.getGrantingTicket() == null; }
@Override public final TicketGrantingTicket getRoot() { TicketGrantingTicket current = this; TicketGrantingTicket parent = current.getGrantingTicket(); while (parent != null) { current = parent; parent = current.getGrantingTicket(); } return current; }
@Override public int compareTo(final Ticket o) { return this.ticket.compareTo(o); } }
@Override public final long getCreationTime() { return this.ticket.getCreationTime(); }
@Override public final int getCountOfUses() { return this.ticket.getCountOfUses(); }
@Override public final String toString() { return this.getId(); }
@Override public int compareTo(final Ticket o) { return this.id.compareTo(o.getId()); } }