no.feide.moria.store
Class MoriaTicket

java.lang.Object
  extended by no.feide.moria.store.MoriaTicket
All Implemented Interfaces:
java.io.Serializable

final class MoriaTicket
extends java.lang.Object
implements java.io.Serializable

This class represents the tickets used as identifiers in Moria. Each ticket has a unique key, a type and an associated service. These attributes are used for validation and authorization of incoming requests.

Version:
$Revision: 1.20 $
Author:
Bjørn Ola Smievoll <b.o@smievoll.no>

Field Summary
private  MoriaStoreData data
          The data associated with this ticket.
private  java.lang.Long expiryTime
          The time when this ticket expires, stored as milliseconds since epoch.
private static long serialVersionUID
          Generated serial version UID.
private  java.lang.String servicePrincipal
          The id of the service associated with this ticket.
private  java.lang.String ticketId
          The unique identifier of this ticket.
private  MoriaTicketType ticketType
          The type of this ticket.
private  java.lang.String userorg
          The userorg associated with this ticket.
 
Constructor Summary
MoriaTicket(MoriaTicketType ticketType, java.lang.String nodeId, java.lang.String servicePrincipal, java.lang.Long expiryTime, MoriaStoreData data, java.lang.String userorg)
          Constructs a new ticket with auto-generated ticket id.
MoriaTicket(java.lang.String ticketId, MoriaTicketType ticketType, java.lang.String servicePrincipal, java.lang.Long expiryTime, MoriaStoreData data, java.lang.String userorg)
          Constructs a new ticket with the given arguments.
 
Method Summary
 boolean equals(java.lang.Object object)
          Tests if ticket is equal to another ticket.
(package private)  MoriaStoreData getData()
          Gets the data object of this ticket.
(package private)  java.lang.Long getExpiryTime()
          Gets the the expiry time for this ticket.
(package private)  java.lang.String getServicePrincipal()
          Gets the value of the service principal associated with this ticket.
(package private)  java.lang.String getTicketId()
          Gets the ticket identifier of this ticket.
(package private)  MoriaTicketType getTicketType()
          Gets the the ticket type of this ticket.
 java.lang.String getUserorg()
          Returns the userorg associated with this ticket, or null if none.
(package private)  boolean hasExpired()
          Checks the ticket's expiry time versus the current time.
 int hashCode()
          Gets the hash code of the ticket.
(package private) static java.lang.String newId(java.lang.String nodeId)
          Creates a new key that can be used as an identifier of the ticket.
 void setUserorg(java.lang.String org)
          Associates a userorg with this ticket.
 java.lang.String toString()
          Gets a string representation of the ticket.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Generated serial version UID.

See Also:
Constant Field Values

ticketId

private final java.lang.String ticketId
The unique identifier of this ticket.


ticketType

private final MoriaTicketType ticketType
The type of this ticket.


servicePrincipal

private final java.lang.String servicePrincipal
The id of the service associated with this ticket.


expiryTime

private final java.lang.Long expiryTime
The time when this ticket expires, stored as milliseconds since epoch.


data

private final MoriaStoreData data
The data associated with this ticket.


userorg

private java.lang.String userorg
The userorg associated with this ticket.

Constructor Detail

MoriaTicket

MoriaTicket(MoriaTicketType ticketType,
            java.lang.String nodeId,
            java.lang.String servicePrincipal,
            java.lang.Long expiryTime,
            MoriaStoreData data,
            java.lang.String userorg)
Constructs a new ticket with auto-generated ticket id.

Parameters:
ticketType - the type of ticket
nodeId - the id of the node creating this ticket
servicePrincipal - the id of the service this ticket relates to
expiryTime - the time when this ticket expires (in milliseconds since Epoch)
data - the data object associated with this ticket. May be null
userorg - the userorg associated with this ticket. Can be null if unknown.

MoriaTicket

MoriaTicket(java.lang.String ticketId,
            MoriaTicketType ticketType,
            java.lang.String servicePrincipal,
            java.lang.Long expiryTime,
            MoriaStoreData data,
            java.lang.String userorg)
Constructs a new ticket with the given arguments.

Parameters:
ticketId - A key identifying this ticket.
ticketType - The type of ticket.
servicePrincipal - The id of the service this ticket relates to. Must be null for SSO tickets, but not null or zero length for other ticket types.
expiryTime - The time when this ticket expires (in milliseconds since Epoch).
data - The data object associated with this ticket. May be null. Must be MoriaAuthnAttempt for login and service tickets, and CachedUserData for SSO, TGT and proxy tickets.
userorg - The userorg associated with this ticket. Can be null if unknown.
Throws:
java.lang.IllegalArgumentException - If ticketId is null or zero length, if ticketType is null, if servicePrincipal or data is inappropriate for the ticketType or if expiryTime is in the past.
Method Detail

getTicketId

java.lang.String getTicketId()
Gets the ticket identifier of this ticket.

Returns:
The key identifying the ticket.

getTicketType

MoriaTicketType getTicketType()
Gets the the ticket type of this ticket.

Returns:
The type of ticket.

getServicePrincipal

java.lang.String getServicePrincipal()
Gets the value of the service principal associated with this ticket.

Returns:
The service principal.

hasExpired

boolean hasExpired()
Checks the ticket's expiry time versus the current time.

Returns:
True if the ticket has exceeded its time to live.

getExpiryTime

java.lang.Long getExpiryTime()
Gets the the expiry time for this ticket.

Returns:
The expiry time in milliseconds since epoch.

getData

MoriaStoreData getData()
Gets the data object of this ticket.

Returns:
An instance of MoriaStoreData, or null if no data object is associated with this ticket.

equals

public boolean equals(java.lang.Object object)
Tests if ticket is equal to another ticket. Equality is defined on basis of the ticketId value. Same id, same ticket.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare with.
Returns:
True if equal.
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Gets the hash code of the ticket. The hash code is the hash code of the ticketId String.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Gets a string representation of the ticket.

Overrides:
toString in class java.lang.Object
Returns:
A comma separated string of all the internal values.

newId

static java.lang.String newId(java.lang.String nodeId)
Creates a new key that can be used as an identifier of the ticket.

Returns:
A new unique identifier.

getUserorg

public java.lang.String getUserorg()
Returns the userorg associated with this ticket, or null if none.

Returns:
The userorg.

setUserorg

public void setUserorg(java.lang.String org)
Associates a userorg with this ticket.

Parameters:
org - The userorg.


Copyright © 2001-2006 UNINETT FAS. All Rights Reserved.