krb5.lib
Class KerberosTime

java.lang.Object
  extended by krb5.lib.KerberosTime
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class KerberosTime
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

TODO Class Description : KerberosTime class. A modified version of the code obtained from the Open Group Research Institute.

Version:
1.1
Author:
Bojan Pajkovski
See Also:
Serialized Form

Field Summary
static boolean NOW
          Indicates whether it is NOW (default to true)
 
Constructor Summary
KerberosTime()
          Class constructor
KerberosTime(boolean initToNow)
          Class constructor
KerberosTime(java.util.Date time)
          Class constructor
KerberosTime(long time)
          Class constructor
KerberosTime(java.lang.String time)
          Class constructor
 
Method Summary
 java.lang.Object clone()
          Clones a copy of the object
 boolean equals(KerberosTime time)
          Compares two Kerberos Times
 int getMilliSeconds()
          Returns value in millisecond
 int getSeconds()
          Returns time in second unit
 long getTime()
          Returns the kerberos time value
 boolean greaterThan(KerberosTime time)
          Compares two Kerberos Times
 boolean greaterThanWRTClockSkew(KerberosTime time)
          Checks the WRT Clock Skew
 boolean greaterThanWRTClockSkew(KerberosTime time, int clockSkew)
          Checks the WRT Clock Skew
 boolean inClockSkew()
          Checks whether the kerbertime is within the clock skew
 boolean inClockSkew(int clockSkew)
          Checks whether the kerbertime is within the clock skew specified scope
 boolean isZero()
          if the time is 0
static void main(java.lang.String[] argv)
          Uses for unit testing only
 void setMilliSeconds(int usec)
          Sets the millisecond value
 void setMilliSeconds(java.lang.Integer usec)
          Sets the millisecond value
 void setNow()
          Sets to the current time
 void setSeconds(int sec)
          Sets time in second unit
 void setTime(java.util.Date time)
          Sets the kerberos time value
 void setTime(long time)
          Sets the kerberos time value
 java.util.Date toDate()
          Returns the date
 java.lang.String toGeneralizedTimeString()
          Converts the object to generalized time string
static long toKerberosTime(java.lang.String time)
          Converts time to Kerberos Time
static java.lang.String zeroPad(java.lang.String s, int length)
          Pads with 0
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOW

public static final boolean NOW
Indicates whether it is NOW (default to true)

See Also:
Constant Field Values
Constructor Detail

KerberosTime

public KerberosTime()
Class constructor


KerberosTime

public KerberosTime(long time)
Class constructor

Parameters:
time - long

KerberosTime

public KerberosTime(boolean initToNow)
Class constructor

Parameters:
initToNow - boolean

KerberosTime

public KerberosTime(java.lang.String time)
             throws KrbException
Class constructor

Parameters:
time - String
Throws:
KrbException

KerberosTime

public KerberosTime(java.util.Date time)
Class constructor

Parameters:
time - Date
Method Detail

clone

public java.lang.Object clone()
Clones a copy of the object

Overrides:
clone in class java.lang.Object
Returns:
Object

toKerberosTime

public static long toKerberosTime(java.lang.String time)
                           throws KrbException
Converts time to Kerberos Time

Parameters:
time - String
Returns:
long
Throws:
KrbException

zeroPad

public static java.lang.String zeroPad(java.lang.String s,
                                       int length)
Pads with 0

Parameters:
s - String
length - int
Returns:
String

toGeneralizedTimeString

public java.lang.String toGeneralizedTimeString()
Converts the object to generalized time string

Returns:
String

getTime

public long getTime()
Returns the kerberos time value

Returns:
long

setTime

public void setTime(java.util.Date time)
Sets the kerberos time value

Parameters:
time - Date

setTime

public void setTime(long time)
Sets the kerberos time value

Parameters:
time - long

toDate

public java.util.Date toDate()
Returns the date

Returns:
Date

setNow

public void setNow()
Sets to the current time


getMilliSeconds

public int getMilliSeconds()
Returns value in millisecond

Returns:
int

setMilliSeconds

public void setMilliSeconds(int usec)
Sets the millisecond value

Parameters:
usec - int

setMilliSeconds

public void setMilliSeconds(java.lang.Integer usec)
Sets the millisecond value

Parameters:
usec - Integer

inClockSkew

public boolean inClockSkew(int clockSkew)
Checks whether the kerbertime is within the clock skew specified scope

Parameters:
clockSkew - int
Returns:
boolean

inClockSkew

public boolean inClockSkew()
Checks whether the kerbertime is within the clock skew

Returns:
boolean

greaterThanWRTClockSkew

public boolean greaterThanWRTClockSkew(KerberosTime time,
                                       int clockSkew)
Checks the WRT Clock Skew

Parameters:
time - KerberosTime
clockSkew - int
Returns:
boolean

greaterThanWRTClockSkew

public boolean greaterThanWRTClockSkew(KerberosTime time)
Checks the WRT Clock Skew

Parameters:
time - KerberosTime
Returns:
boolean

greaterThan

public boolean greaterThan(KerberosTime time)
Compares two Kerberos Times

Parameters:
time - KerberosTime
Returns:
boolean

equals

public boolean equals(KerberosTime time)
Compares two Kerberos Times

Parameters:
time - KerberosTime
Returns:
boolean

isZero

public boolean isZero()
if the time is 0

Returns:
boolean

getSeconds

public int getSeconds()
Returns time in second unit

Returns:
int

setSeconds

public void setSeconds(int sec)
Sets time in second unit

Parameters:
sec - int

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Uses for unit testing only

Throws:
java.lang.Exception