Package org.apereo.cas.ticket.registry
Interface TicketRegistry
-
public interface TicketRegistryInterface for a registry that stores tickets. The underlying registry can be backed by anything from a normal HashMap to JGroups for having distributed registries. It is up to specific implementations to determine their clean up strategy. Strategies can include a manual clean up by a registry cleaner or a more sophisticated strategy such as LRU.- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBEAN_NAMEDefault bean name.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidaddTicket(java.util.stream.Stream<? extends Ticket> toSave)Save.voidaddTicket(Ticket ticket)Add a ticket to the registry.longcountSessionsFor(java.lang.String principalId)Count the number of single sign-on sessions that are recorded in the ticket registry for the given user name.longdeleteAll()Delete all tickets from the registry.intdeleteTicket(java.lang.String ticketId)Remove a specific ticket from the registry.intdeleteTicket(Ticket ticketId)Remove a specific ticket from the registry.TicketgetTicket(java.lang.String ticketId)Retrieve a ticket from the registry.<T extends Ticket>
TgetTicket(java.lang.String ticketId, java.lang.Class<T> clazz)Retrieve a ticket from the registry.TicketgetTicket(java.lang.String ticketId, java.util.function.Predicate<Ticket> predicate)Gets ticket from registry using a predicate.java.util.Collection<? extends Ticket>getTickets()Retrieve all tickets from the registry.default java.util.stream.Stream<? extends Ticket>getTickets(java.util.function.Predicate<Ticket> predicate)Gets tickets as a stream having applied a predicate.longserviceTicketCount()Computes the number of service tickets stored in the ticket registry.longsessionCount()Computes the number of SSO sessions stored in the ticket registry.default java.util.stream.Stream<? extends Ticket>stream()Gets tickets stream.TicketupdateTicket(Ticket ticket)Update the received ticket.
-
-
-
Field Detail
-
BEAN_NAME
static final java.lang.String BEAN_NAME
Default bean name.- See Also:
- Constant Field Values
-
-
Method Detail
-
addTicket
void addTicket(Ticket ticket) throws java.lang.Exception
Add a ticket to the registry. Ticket storage is based on the ticket id.- Parameters:
ticket- The ticket we wish to add to the cache.- Throws:
java.lang.Exception- the exception
-
addTicket
default void addTicket(java.util.stream.Stream<? extends Ticket> toSave) throws java.lang.Exception
Save.- Parameters:
toSave- the to save- Throws:
java.lang.Exception- the exception
-
getTicket
<T extends Ticket> T getTicket(java.lang.String ticketId, java.lang.Class<T> clazz)
Retrieve a ticket from the registry. If the ticket retrieved does not match the expected class, an InvalidTicketException is thrown.- Type Parameters:
T- the generic ticket type to return that extendsTicket- Parameters:
ticketId- the id of the ticket we wish to retrieve.clazz- The expected class of the ticket we wish to retrieve.- Returns:
- the requested ticket.
-
getTicket
Ticket getTicket(java.lang.String ticketId)
Retrieve a ticket from the registry.- Parameters:
ticketId- the id of the ticket we wish to retrieve- Returns:
- the requested ticket.
-
getTicket
Ticket getTicket(java.lang.String ticketId, java.util.function.Predicate<Ticket> predicate)
Gets ticket from registry using a predicate.- Parameters:
ticketId- the ticket idpredicate- the predicate that tests the ticket- Returns:
- the ticket
-
deleteTicket
int deleteTicket(java.lang.String ticketId) throws java.lang.ExceptionRemove a specific ticket from the registry. If ticket to delete is TGT then related service tickets are removed as well.- Parameters:
ticketId- The id of the ticket to delete.- Returns:
- the number of tickets deleted including children.
- Throws:
java.lang.Exception- the exception
-
deleteTicket
int deleteTicket(Ticket ticketId) throws java.lang.Exception
Remove a specific ticket from the registry. If ticket to delete is TGT then related service tickets, etc are removed as well.- Parameters:
ticketId- The id of the ticket to delete.- Returns:
- the number of tickets deleted including children.
- Throws:
java.lang.Exception- the exception
-
deleteAll
long deleteAll()
Delete all tickets from the registry.- Returns:
- the number of tickets deleted.
-
getTickets
java.util.Collection<? extends Ticket> getTickets()
Retrieve all tickets from the registry.- Returns:
- collection of tickets currently stored in the registry. Tickets might or might not be valid i.e. expired.
-
getTickets
default java.util.stream.Stream<? extends Ticket> getTickets(java.util.function.Predicate<Ticket> predicate)
Gets tickets as a stream having applied a predicate.The returning stream may be bound to an IO channel (such as database connection), so it should be properly closed after usage.
- Parameters:
predicate- the predicate- Returns:
- the tickets
-
updateTicket
Ticket updateTicket(Ticket ticket) throws java.lang.Exception
Update the received ticket.- Parameters:
ticket- the ticket- Returns:
- the updated ticket
- Throws:
java.lang.Exception- the exception
-
sessionCount
long sessionCount()
Computes the number of SSO sessions stored in the ticket registry.- Returns:
- Number of ticket-granting tickets in the registry at time of invocation or
Integer.MIN_VALUEif unknown.
-
serviceTicketCount
long serviceTicketCount()
Computes the number of service tickets stored in the ticket registry.- Returns:
- Number of service tickets in the registry at time of invocation or
Integer.MIN_VALUEif unknown.
-
stream
default java.util.stream.Stream<? extends Ticket> stream()
Gets tickets stream.The returning stream may be bound to an IO channel (such as database connection), so it should be properly closed after usage.
- Returns:
- the tickets stream
-
countSessionsFor
long countSessionsFor(java.lang.String principalId)
Count the number of single sign-on sessions that are recorded in the ticket registry for the given user name.- Parameters:
principalId- the principal id- Returns:
- the count
-
-