APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.jgss

public Class TokenTracker

extends Object
Class Inheritance
Imports
org.ietf.jgss.MessageProp, java.util.LinkedList

A utility class that implements a number list that keeps track of which tokens have arrived by storing their token numbers in the list. It helps detect old tokens, out of sequence tokens, and duplicate tokens. Each element of the list is an interval [a, b]. Its existence in the list implies that all token numbers in the range a, a+1, ..., b-1, b have arrived. Gaps in arrived token numbers are represented by the numbers that fall in between two elements of the list. e.g. {[a,b], [c,d]} indicates that the token numbers b+1, ..., c-1 have not arrived yet. The maximum number of intervals that we keep track of is MAX_INTERVALS. Thus, if there are too many gaps, then some older sequence numbers are deleted from the list. The earliest sequence number that exists in the list is the windowStart. The next expected sequence number, or expectedNumber, is one greater than the latest sequence number in the list. The list keeps track the first token number that should have arrived (initNumber) so that it is able to detect if certain numbers occur after the first valid token number but before windowStart. That would happen if the number of elements (intervals) exceeds MAX_INTERVALS and some initial elements had to be deleted. The working of the list is optimized for the normal case where the tokens arrive in sequence.
Author
Mayank Upadhyay
Since
1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
TokenTracker.Entry

An entry in the list that represents the sequence of received tokens.

Field Summary

Modifier and TypeField and Description
private int
private final int
private final LinkedList<TokenTracker.Entry>
pack-priv static final int
private int
private int

Constructor Summary

AccessConstructor and Description
public
TokenTracker(int initNumber)

Method Summary

Modifier and TypeMethod and Description
private void
add(int number, int prevEntryPos)

Adds the number to the list just after the entry that is currently at position prevEntryPos.

private int
getIntervalIndex(int number)

Returns the index for the entry into which this number will fit.

public final synchronized void
getProps(int number, MessageProp prop)

Sets the sequencing and replay information for the given token number.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

expectedNumberback to summary
private int expectedNumber
initNumberback to summary
private final int initNumber
listback to summary
private final LinkedList<TokenTracker.Entry> list
MAX_INTERVALSback to summary
pack-priv static final int MAX_INTERVALS
windowStartback to summary
private int windowStart
windowStartIndexback to summary
private int windowStartIndex

Constructor Detail

TokenTrackerback to summary
public TokenTracker(int initNumber)

Method Detail

addback to summary
private void add(int number, int prevEntryPos)

Adds the number to the list just after the entry that is currently at position prevEntryPos. If prevEntryPos is -1, then the number will begin a new interval at the front of the list.

getIntervalIndexback to summary
private int getIntervalIndex(int number)

Returns the index for the entry into which this number will fit. If there is none, it returns the index of the last interval which precedes this number. It returns -1 if the number needs to be a in a new interval ahead of the whole list.

getPropsback to summary
public final synchronized void getProps(int number, MessageProp prop)

Sets the sequencing and replay information for the given token number. The following represents the number line with positions of initNumber, windowStart, expectedNumber marked on it. Regions in between them show the different sequencing and replay state possibilities for tokens that fall in there. (1) windowStart initNumber expectedNumber | | ---|---------------------------|--- GAP | DUP/UNSEQ | GAP (2) initNumber windowStart expectedNumber | | | ---|---------------|--------------|--- GAP | OLD | DUP/UNSEQ | GAP (3) windowStart expectedNumber initNumber | | ---|---------------------------|--- DUP/UNSEQ | GAP | DUP/UNSEQ (4) expectedNumber initNumber windowStart | | | ---|---------------|--------------|--- DUP/UNSEQ | GAP | OLD | DUP/UNSEQ (5) windowStart expectedNumber initNumber | | | ---|---------------|--------------|--- OLD | DUP/UNSEQ | GAP | OLD (This analysis leaves out the possibility that expectedNumber passes initNumber after wrapping around. That may be added later.)

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

sun.security.jgss back to summary

pack-priv Class TokenTracker.Entry

extends Object
Class Inheritance

An entry in the list that represents the sequence of received tokens. Each entry is actually an interval of numbers, all of which have been received.

Field Summary

Modifier and TypeField and Description
private int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
Entry(int number)

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
append(int number)

pack-priv final int
compareTo(int number)

Returns -1 if this interval represented by this entry precedes the number, 0 if the number is contained in the interval, and -1 if the interval occurs after the number.

pack-priv final boolean
contains(int number)

pack-priv final int
pack-priv final int
pack-priv final void
setEnd(int end)

pack-priv final void
setInterval(int start, int end)

pack-priv final void
setStart(int start)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

endback to summary
private int end
startback to summary
private int start

Constructor Detail

Entryback to summary
pack-priv Entry(int number)

Method Detail

appendback to summary
pack-priv final void append(int number)
compareToback to summary
pack-priv final int compareTo(int number)

Returns -1 if this interval represented by this entry precedes the number, 0 if the number is contained in the interval, and -1 if the interval occurs after the number.

containsback to summary
pack-priv final boolean contains(int number)
getEndback to summary
pack-priv final int getEnd()
getStartback to summary
pack-priv final int getStart()
setEndback to summary
pack-priv final void setEnd(int end)
setIntervalback to summary
pack-priv final void setInterval(int start, int end)
setStartback to summary
pack-priv final void setStart(int start)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.