Interface TicketRegistry


  • public interface TicketRegistry
    Interface 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.String BEAN_NAME
      Default bean name.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void addTicket​(java.util.stream.Stream<? extends Ticket> toSave)
      Save.
      void addTicket​(Ticket ticket)
      Add a ticket to the registry.
      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.
      long deleteAll()
      Delete all tickets from the registry.
      int deleteTicket​(java.lang.String ticketId)
      Remove a specific ticket from the registry.
      int deleteTicket​(Ticket ticketId)
      Remove a specific ticket from the registry.
      Ticket getTicket​(java.lang.String ticketId)
      Retrieve a ticket from the registry.
      <T extends Ticket>
      T
      getTicket​(java.lang.String ticketId, java.lang.Class<T> clazz)
      Retrieve a ticket from the registry.
      Ticket getTicket​(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.
      long serviceTicketCount()
      Computes the number of service tickets stored in the ticket registry.
      long sessionCount()
      Computes the number of SSO sessions stored in the ticket registry.
      default java.util.stream.Stream<? extends Ticket> stream()
      Gets tickets stream.
      Ticket updateTicket​(Ticket ticket)
      Update the received ticket.
    • Field Detail

    • 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 extends Ticket
        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 id
        predicate - the predicate that tests the ticket
        Returns:
        the ticket
      • deleteTicket

        int deleteTicket​(java.lang.String ticketId)
                  throws java.lang.Exception
        Remove 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_VALUE if 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_VALUE if 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