Package net.shibboleth.idp.cas.ticket.impl

# Class AbstractTicketService

java.lang.Object
net.shibboleth.idp.cas.ticket.impl.AbstractTicketService

All Implemented Interfaces:
  `TicketService`

Direct Known Subclasses:
  `EncodingTicketService`, `SimpleTicketService`

public abstract class AbstractTicketService extends Object implements TicketService
Abstract base class for ticket services that rely on `StorageService` for ticket storage.

Since:
  3.3.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final Map<Class<? extends Ticket>,String>`
`CONTEXT_CLASS_MAP`
Map of ticket classes to context names.
`private final org.slf4j.Logger`
`log`
Class logger.
`private static final ProxyGrantingTicketSerializer`
`PGT_SERIALIZER`
Proxy granting ticket serializer.
`private static final ProxyTicketSerializer`
`PT_SERIALIZER`
Proxy ticket serialize.
`private static final Map<Class<? extends Ticket>,StorageSerializer<? extends Ticket>>`
`SERIALIZER_MAP`
Map of ticket classes to serializers.
`private static final ServiceTicketSerializer`
`ST_SERIALIZER`
Service ticket serializer.
`private final StorageService`
`storageService`
Storage service to which ticket persistence operations are delegated.

## Constructor Summary

Constructors
Constructor
Description
`AbstractTicketService(StorageService service)`
Creates a new instance.

## Method Summary

Modifier and Type
Method
Description
`protected static String`
`context(Class<? extends Ticket> clazz)`
Gets the storage service context name for the given ticket type.
`ProxyGrantingTicket`
`createProxyGrantingTicket(String id, Instant expiry, ProxyTicket proxyTicket, String pgtUrl)`
Creates a chained proxy-granting ticket from a proxy ticket.
`ProxyGrantingTicket`
`createProxyGrantingTicket(String id, Instant expiry, ServiceTicket serviceTicket, String pgtUrl)`
Creates a top-level proxy-granting ticket from a service ticket.
`protected <T extends Ticket>
T`
`delete(String id, Class<T> clazz)`
Retrieves a ticket by ID from the storage service and then deletes it.
`ProxyGrantingTicket`
`fetchProxyGrantingTicket(String id)`
Retrieves a proxy-granting ticket by its ID.
`protected <T extends Ticket>
T`
`read(String id, Class<T> clazz)`
Retrieves a ticket by ID from the storage service.
`ProxyGrantingTicket`
`removeProxyGrantingTicket(String id)`
Removes the proxy-granting ticket with the given identifier.
`protected static <T extends Ticket>
StorageSerializer<T>`
`serializer(Class<T> clazz)`
Gets the storage service serializer for the given ticket type.
`protected <T extends Ticket>
void`
`store(T ticket)`
Stores the given ticket in the storage service.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.idp.cas.ticket.TicketService

`createProxyTicket, createServiceTicket, removeProxyTicket, removeServiceTicket`

## Field Details

### CONTEXT_CLASS_MAP

@Nonnull private static final Map<Class<? extends Ticket>,String> CONTEXT_CLASS_MAP
Map of ticket classes to context names.

### SERIALIZER_MAP

@Nonnull private static final Map<Class<? extends Ticket>,StorageSerializer<? extends Ticket>> SERIALIZER_MAP
Map of ticket classes to serializers.

### ST_SERIALIZER

@Nonnull private static final ServiceTicketSerializer ST_SERIALIZER
Service ticket serializer.

### PT_SERIALIZER

@Nonnull private static final ProxyTicketSerializer PT_SERIALIZER
Proxy ticket serialize.

### PGT_SERIALIZER

@Nonnull private static final ProxyGrantingTicketSerializer PGT_SERIALIZER
Proxy granting ticket serializer.

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### storageService

@Nonnull private final StorageService storageService
Storage service to which ticket persistence operations are delegated.

## Constructor Details

### AbstractTicketService

public AbstractTicketService(@Nonnull StorageService service)
Creates a new instance.

Parameters:
  `service` - Storage service to which tickets are persisted.

## Method Details

### createProxyGrantingTicket

@Nonnull public ProxyGrantingTicket createProxyGrantingTicket(@Nonnull String id, @Nonnull Instant expiry, @Nonnull ServiceTicket serviceTicket, @Nonnull String pgtUrl)
Creates a top-level proxy-granting ticket from a service ticket.

Specified by:
  `createProxyGrantingTicket` in interface `TicketService`
Parameters:
  `id` - ID of proxy-granting ticket to create.
  `expiry` - Expiration date of proxy-granting ticket.
  `serviceTicket` - Successfully-validated service ticket.
  `pgtUrl` - Proxy callback URL used to authenticate and identify the proxying service.
Returns:
  Created proxy-granting ticket.

### createProxyGrantingTicket

@Nonnull public ProxyGrantingTicket createProxyGrantingTicket(@Nonnull String id, @Nonnull Instant expiry, @Nonnull ProxyTicket proxyTicket, @Nonnull String pgtUrl)
Creates a chained proxy-granting ticket from a proxy ticket. The value of `ProxyTicket.getPgtId()` defines the parent of the created ticket, which in turn determines its location in the proxy chain.

Specified by:
  `createProxyGrantingTicket` in interface `TicketService`
Parameters:
  `id` - ID of proxy-granting ticket to create.
  `expiry` - Expiration date of proxy-granting ticket.
  `proxyTicket` - Successfully-validated proxy ticket.
  `pgtUrl` - Proxy callback URL used to authenticate and identify the proxying service.
Returns:
  Created proxy-granting ticket.

### fetchProxyGrantingTicket

@Nullable public ProxyGrantingTicket fetchProxyGrantingTicket(@Nonnull String id)
Retrieves a proxy-granting ticket by its ID.

Specified by:
  `fetchProxyGrantingTicket` in interface `TicketService`
Parameters:
  `id` - Proxy-granting ticket ID.
Returns:
  Proxy-granting ticket or null if not found.

### removeProxyGrantingTicket

@Nullable public ProxyGrantingTicket removeProxyGrantingTicket(@Nonnull String id)
Removes the proxy-granting ticket with the given identifier.

Specified by:
  `removeProxyGrantingTicket` in interface `TicketService`
Parameters:
  `id` - Identifier of ticket to remove.
Returns:
  Removed ticket or null if not found.

### context

@Nullable protected static String context(@Nonnull Class<? extends Ticket> clazz)
Gets the storage service context name for the given ticket type.

Parameters:
  `clazz` - Ticket class.
Returns:
  Context name for ticket type.

### serializer

@Nonnull protected static <T extends Ticket> StorageSerializer<T> serializer(@Nonnull Class<T> clazz)
Gets the storage service serializer for the given ticket type.

Type Parameters:
  `T` - type of object being serialized
Parameters:
  `clazz` - Ticket class.
Returns:
  Storage service serializer.

### store

protected <T extends Ticket> void store(@Nonnull T ticket)
Stores the given ticket in the storage service.

Type Parameters:
  `T` - Type of ticket.
Parameters:
  `ticket` - Ticket to store

### read

@Nullable protected <T extends Ticket> T read(@Nonnull String id, @Nonnull Class<T> clazz)
Retrieves a ticket by ID from the storage service.

Type Parameters:
  `T` - Type of ticket.
Parameters:
  `id` - Ticket identifier.
  `clazz` - Ticket type.
Returns:
  Ticket or null if ticket not found.

### delete

@Nullable protected <T extends Ticket> T delete(@Nonnull String id, @Nonnull Class<T> clazz)
Retrieves a ticket by ID from the storage service and then deletes it.

Type Parameters:
  `T` - Type of ticket.
Parameters:
  `id` - Ticket identifier.
  `clazz` - Ticket class
Returns:
  Deleted ticket or null if ticket not found.