org.jasig.cas.ticket.registry
Class DefaultTicketRegistry

java.lang.Object
  extended byorg.jasig.cas.ticket.registry.DefaultTicketRegistry
All Implemented Interfaces:
TicketRegistry

public final class DefaultTicketRegistry
extends java.lang.Object
implements TicketRegistry

Implementation of the TicketRegistry that is backed by a HashMap.

The underlying HashMap is not threadsafe. Each method is synchronized but care should be taken that if multiple methods will be called, the code should be placed in a synchronize block.

Since:
3.0
Version:
$Revision$ $Date$
Author:
Scott Battaglia

Constructor Summary
DefaultTicketRegistry()
           
 
Method Summary
 void addTicket(Ticket ticket)
          Add a ticket to the registry.
 boolean deleteTicket(java.lang.String ticketId)
          Remove a specific ticket from the registry.
 Ticket getTicket(java.lang.String ticketId)
          Retrieve a ticket from the registry.
 Ticket getTicket(java.lang.String ticketId, java.lang.Class clazz)
          Retrieve a ticket from the registry.
 java.util.Collection getTickets()
          Retrieve all tickets from the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTicketRegistry

public DefaultTicketRegistry()
Method Detail

addTicket

public void addTicket(Ticket ticket)
Description copied from interface: TicketRegistry
Add a ticket to the registry. Ticket storage is based on the ticket id.

Specified by:
addTicket in interface TicketRegistry
Parameters:
ticket - The ticket we wish to add to the cache.
Throws:
java.lang.IllegalArgumentException - if the Ticket is null.

getTicket

public Ticket getTicket(java.lang.String ticketId,
                        java.lang.Class clazz)
Description copied from interface: TicketRegistry
Retrieve a ticket from the registry. If the ticket retrieved does not match the expected class, an InvalidTicketException is thrown.

Specified by:
getTicket in interface TicketRegistry
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.
Throws:
java.lang.IllegalArgumentException - if class is null.
java.lang.ClassCastException - if class does not match requested ticket class.

getTicket

public Ticket getTicket(java.lang.String ticketId)
Description copied from interface: TicketRegistry
Retrieve a ticket from the registry.

Specified by:
getTicket in interface TicketRegistry
Parameters:
ticketId - the id of the ticket we wish to retrieve
Returns:
the requested ticket.

deleteTicket

public boolean deleteTicket(java.lang.String ticketId)
Description copied from interface: TicketRegistry
Remove a specific ticket from the registry.

Specified by:
deleteTicket in interface TicketRegistry
Parameters:
ticketId - The id of the ticket to delete.
Returns:
true if the ticket was removed and false if the ticket did not exist.

getTickets

public java.util.Collection getTickets()
Description copied from interface: TicketRegistry
Retrieve all tickets from the registry.

Specified by:
getTickets in interface TicketRegistry
Returns:
collection of tickets currently stored in the registry. Tickets might or might not be valid i.e. expired.


Copyright © 2004-2005 Java Architectures Special Interest Group. All Rights Reserved.