Java™ Platform
Standard Ed. 6

javax.security.auth.kerberos
Class KerberosTicket

java.lang.Object
  extended by javax.security.auth.kerberos.KerberosTicket
All Implemented Interfaces:
Serializable, Destroyable, Refreshable

public class KerberosTicket
extends Object
implements Destroyable, Refreshable, Serializable

This class encapsulates a Kerberos ticket and associated information as viewed from the client's point of view. It captures all information that the Key Distribution Center (KDC) sends to the client in the reply message KDC-REP defined in the Kerberos Protocol Specification (RFC 1510).

All Kerberos JAAS login modules that authenticate a user to a KDC should use this class. Where available, the login module might even read this information from a ticket cache in the operating system instead of directly communicating with the KDC. During the commit phase of the JAAS authentication process, the JAAS login module should instantiate this class and store the instance in the private credential set of a Subject.

It might be necessary for the application to be granted a PrivateCredentialPermission if it needs to access a KerberosTicket instance from a Subject. This permission is not needed when the application depends on the default JGSS Kerberos mechanism to access the KerberosTicket. In that case, however, the application will need an appropriate ServicePermission.

Note that this class is applicable to both ticket granting tickets and other regular service tickets. A ticket granting ticket is just a special case of a more generalized service ticket.

Since:
1.4
See Also:
Subject, PrivateCredentialPermission, LoginContext, GSSCredential, GSSManager, Serialized Form

Constructor Summary
KerberosTicket(byte[] asn1Encoding, KerberosPrincipal client, KerberosPrincipal server, byte[] sessionKey, int keyType, boolean[] flags, Date authTime, Date startTime, Date endTime, Date renewTill, InetAddress[] clientAddresses)
          Constructs a KerberosTicket using credentials information that a client either receives from a KDC or reads from a cache.
 
Method Summary
 void destroy()
          Destroys the ticket and destroys any sensitive information stored in it.
 boolean equals(Object other)
          Compares the specified Object with this KerberosTicket for equality.
 Date getAuthTime()
          Returns the time that the client was authenticated.
 KerberosPrincipal getClient()
          Returns the client principal associated with this ticket.
 InetAddress[] getClientAddresses()
          Returns a list of addresses from where the ticket can be used.
 byte[] getEncoded()
          Returns an ASN.1 encoding of the entire ticket.
 Date getEndTime()
          Returns the expiration time for this ticket's validity period.
 boolean[] getFlags()
          Returns the flags associated with this ticket.
 Date getRenewTill()
          Returns the latest expiration time for this ticket, including all renewals.
 KerberosPrincipal getServer()
          Returns the service principal associated with this ticket.
 SecretKey getSessionKey()
          Returns the session key associated with this ticket.
 int getSessionKeyType()
          Returns the key type of the session key associated with this ticket as defined by the Kerberos Protocol Specification.
 Date getStartTime()
          Returns the start time for this ticket's validity period.
 int hashCode()
          Returns a hashcode for this KerberosTicket.
 boolean isCurrent()
          Determines if this ticket is still current.
 boolean isDestroyed()
          Determines if this ticket has been destroyed.
 boolean isForwardable()
          Determines if this ticket is forwardable.
 boolean isForwarded()
          Determines if this ticket had been forwarded or was issued based on authentication involving a forwarded ticket-granting ticket.
 boolean isInitial()
          Determines if this ticket was issued using the Kerberos AS-Exchange protocol, and not issued based on some ticket-granting ticket.
 boolean isPostdated()
          Determines is this ticket is post-dated.
 boolean isProxiable()
          Determines if this ticket is proxiable.
 boolean isProxy()
          Determines is this ticket is a proxy-ticket.
 boolean isRenewable()
          Determines is this ticket is renewable.
 void refresh()
          Extends the validity period of this ticket.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KerberosTicket

public KerberosTicket(byte[] asn1Encoding,
                      KerberosPrincipal client,
                      KerberosPrincipal server,
                      byte[] sessionKey,
                      int keyType,
                      boolean[] flags,
                      Date authTime,
                      Date startTime,
                      Date endTime,
                      Date renewTill,
                      InetAddress[] clientAddresses)
Constructs a KerberosTicket using credentials information that a client either receives from a KDC or reads from a cache.

Parameters:
asn1Encoding - the ASN.1 encoding of the ticket as defined by the Kerberos protocol specification.
client - the client that owns this service ticket
server - the service that this ticket is for
sessionKey - the raw bytes for the session key that must be used to encrypt the authenticator that will be sent to the server
keyType - the key type for the session key as defined by the Kerberos protocol specification.
flags - the ticket flags. Each element in this array indicates the value for the corresponding bit in the ASN.1 BitString that represents the ticket flags. If the number of elements in this array is less than the number of flags used by the Kerberos protocol, then the missing flags will be filled in with false.
authTime - the time of initial authentication for the client
startTime - the time after which the ticket will be valid. This may be null in which case the value of authTime is treated as the startTime.
endTime - the time after which the ticket will no longer be valid
renewTill - an absolute expiration time for the ticket, including all renewal that might be possible. This field may be null for tickets that are not renewable.
clientAddresses - the addresses from where the ticket may be used by the client. This field may be null when the ticket is usable from any address.
Method Detail

getClient

public final KerberosPrincipal getClient()
Returns the client principal associated with this ticket.

Returns:
the client principal.

getServer

public final KerberosPrincipal getServer()
Returns the service principal associated with this ticket.

Returns:
the service principal.

getSessionKey

public final SecretKey getSessionKey()
Returns the session key associated with this ticket.

Returns:
the session key.

getSessionKeyType

public final int getSessionKeyType()
Returns the key type of the session key associated with this ticket as defined by the Kerberos Protocol Specification.

Returns:
the key type of the session key associated with this ticket.
See Also:
getSessionKey()

isForwardable

public final boolean isForwardable()
Determines if this ticket is forwardable.

Returns:
true if this ticket is forwardable, false if not.

isForwarded

public final boolean isForwarded()
Determines if this ticket had been forwarded or was issued based on authentication involving a forwarded ticket-granting ticket.

Returns:
true if this ticket had been forwarded or was issued based on authentication involving a forwarded ticket-granting ticket, false otherwise.

isProxiable

public final boolean isProxiable()
Determines if this ticket is proxiable.

Returns:
true if this ticket is proxiable, false if not.

isProxy

public final boolean isProxy()
Determines is this ticket is a proxy-ticket.

Returns:
true if this ticket is a proxy-ticket, false if not.

isPostdated

public final boolean isPostdated()
Determines is this ticket is post-dated.

Returns:
true if this ticket is post-dated, false if not.

isRenewable

public final boolean isRenewable()
Determines is this ticket is renewable. If so, the refresh method can be called, assuming the validity period for renewing is not already over.

Returns:
true if this ticket is renewable, false if not.

isInitial

public final boolean isInitial()
Determines if this ticket was issued using the Kerberos AS-Exchange protocol, and not issued based on some ticket-granting ticket.

Returns:
true if this ticket was issued using the Kerberos AS-Exchange protocol, false if not.

getFlags

public final boolean[] getFlags()
Returns the flags associated with this ticket. Each element in the returned array indicates the value for the corresponding bit in the ASN.1 BitString that represents the ticket flags.

Returns:
the flags associated with this ticket.

getAuthTime

public final Date getAuthTime()
Returns the time that the client was authenticated.

Returns:
the time that the client was authenticated or null if not set.

getStartTime

public final Date getStartTime()
Returns the start time for this ticket's validity period.

Returns:
the start time for this ticket's validity period or null if not set.

getEndTime

public final Date getEndTime()
Returns the expiration time for this ticket's validity period.

Returns:
the expiration time for this ticket's validity period.

getRenewTill

public final Date getRenewTill()
Returns the latest expiration time for this ticket, including all renewals. This will return a null value for non-renewable tickets.

Returns:
the latest expiration time for this ticket.

getClientAddresses

public final InetAddress[] getClientAddresses()
Returns a list of addresses from where the ticket can be used.

Returns:
ths list of addresses or null, if the field was not provided.

getEncoded

public final byte[] getEncoded()
Returns an ASN.1 encoding of the entire ticket.

Returns:
an ASN.1 encoding of the entire ticket.

isCurrent

public boolean isCurrent()
Determines if this ticket is still current.

Specified by:
isCurrent in interface Refreshable
Returns:
true if this Object is currently current, false otherwise.

refresh

public void refresh()
             throws RefreshFailedException
Extends the validity period of this ticket. The ticket will contain a new session key if the refresh operation succeeds. The refresh operation will fail if the ticket is not renewable or the latest allowable renew time has passed. Any other error returned by the KDC will also cause this method to fail. Note: This method is not synchronized with the the accessor methods of this object. Hence callers need to be aware of multiple threads that might access this and try to renew it at the same time.

Specified by:
refresh in interface Refreshable
Throws:
RefreshFailedException - if the ticket is not renewable, or the latest allowable renew time has passed, or the KDC returns some error.
See Also:
isRenewable(), getRenewTill()

destroy

public void destroy()
             throws DestroyFailedException
Destroys the ticket and destroys any sensitive information stored in it.

Specified by:
destroy in interface Destroyable
Throws:
DestroyFailedException - if the destroy operation fails.


isDestroyed

public boolean isDestroyed()
Determines if this ticket has been destroyed.

Specified by:
isDestroyed in interface Destroyable
Returns:
true if this Object has been destroyed, false otherwise.

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.

hashCode

public int hashCode()
Returns a hashcode for this KerberosTicket.

Overrides:
hashCode in class Object
Returns:
a hashCode() for the KerberosTicket
Since:
1.6
See Also:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object other)
Compares the specified Object with this KerberosTicket for equality. Returns true if the given object is also a KerberosTicket and the two KerberosTicket instances are equivalent.

Overrides:
equals in class Object
Parameters:
other - the Object to compare to
Returns:
true if the specified object is equal to this KerberosTicket, false otherwise. NOTE: Returns false if either of the KerberosTicket objects has been destroyed.
Since:
1.6
See Also:
Object.hashCode(), Hashtable

Java™ Platform
Standard Ed. 6

Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.