Package net.shibboleth.idp.cas.ticket

# Class TicketIdentifierGenerationStrategy

java.lang.Object
net.shibboleth.idp.cas.ticket.TicketIdentifierGenerationStrategy

All Implemented Interfaces:
  `IdentifierGenerationStrategy`

public class TicketIdentifierGenerationStrategy extends Object implements IdentifierGenerationStrategy
Generates CAS protocol ticket identifiers of the form:

     [PREFIX]-[SEQUENCE_PART]-[RANDOM_PART]-[SUFFIX],

where suffix is optional. By default tickets have at least 128 bits of entropy in the random part of the identifier.

## Nested Class Summary

## Nested classes/interfaces inherited from interface net.shibboleth.shared.security.IdentifierGenerationStrategy

`IdentifierGenerationStrategy.ParameterSpec, IdentifierGenerationStrategy.ProviderType`

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.cryptacular.generator.IdGenerator`
`idGenerator`
Generator for random part of the ticket.
`private int`
`ticketLength`
Number of characters in random part of generated ticket.
`private String`
`ticketPrefix`
Ticket prefix.
`private String`
`ticketSuffix`
Ticket suffix.

## Constructor Summary

Constructors
Constructor
Description
`TicketIdentifierGenerationStrategy(String prefix, int randomLength)`
Creates a new ticket ID generator.

## Method Summary

Modifier and Type
Method
Description
`String`
`generateIdentifier()`
`String`
`generateIdentifier(boolean xmlSafe)`
`private static boolean`
`isUrlSafe(String s)`
Whether the URL is safe.
`void`
`setSuffix(String suffix)`
Sets the ticket ID suffix.

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

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

## Field Details

### idGenerator

@Nonnull private final org.cryptacular.generator.IdGenerator idGenerator
Generator for random part of the ticket.

### ticketPrefix

@Nonnull @NotEmpty private String ticketPrefix
Ticket prefix.

### ticketSuffix

@Nullable private String ticketSuffix
Ticket suffix.

### ticketLength

@Positive private int ticketLength
Number of characters in random part of generated ticket.

## Constructor Details

### TicketIdentifierGenerationStrategy

public TicketIdentifierGenerationStrategy(@Nonnull @NotEmpty @ParameterName(name="prefix") String prefix, @Positive @ParameterName(name="randomLength") int randomLength)
Creates a new ticket ID generator.

Parameters:
  `prefix` - Ticket ID prefix (e.g. ST, PT, PGT). MUST be a URL safe string.
  `randomLength` - Length in characters of random part of the ticket.

## Method Details

### setSuffix

public void setSuffix(@Nullable String suffix)
Sets the ticket ID suffix.

Parameters:
  `suffix` - Ticket suffix.

### generateIdentifier

@Nonnull public String generateIdentifier()

Specified by:
  `generateIdentifier` in interface `IdentifierGenerationStrategy`

### generateIdentifier

@Nonnull public String generateIdentifier(boolean xmlSafe)

Specified by:
  `generateIdentifier` in interface `IdentifierGenerationStrategy`

### isUrlSafe

private static boolean isUrlSafe(@Nonnull String s)
Whether the URL is safe.

Parameters:
  `s` - URL
Returns:
  whether the URL is safe