org.apache.directory.shared.kerberos
Class KerberosTime

java.lang.Object
  extended by org.apache.directory.shared.kerberos.KerberosTime
All Implemented Interfaces:
Serializable, Comparable<KerberosTime>

public class KerberosTime
extends Object
implements Comparable<KerberosTime>, Serializable

An specialization of the ASN.1 GeneralTime. The Kerberos time contains date and time up to the seconds, but with no fractional seconds. It's also always expressed as UTC timeZone, thus the 'Z' at the end of its string representation.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
static int DAY
          The number of milliseconds in a day.
static KerberosTime INFINITY
          Constant for the KerberosTime "infinity."
static int MINUTE
          The number of milliseconds in a minute.
static int WEEK
          The number of milliseconds in a week.
 
Constructor Summary
KerberosTime()
          Creates a new instance of a KerberosTime object
KerberosTime(Date time)
          Creates a new instance of KerberosTime.
KerberosTime(long date)
          Creates a new instance of a KerberosTime object
KerberosTime(String date)
          Creates a new instance of a KerberosTime object
 
Method Summary
 int compareTo(KerberosTime that)
          compares current kerberos time with the given kerberos time
 boolean equals(Object obj)
           
 byte[] getBytes()
           
 String getDate()
           
 long getTime()
          Returns the KerberosTime as a long.
static KerberosTime getTime(String zuluTime)
          Returns the KerberosTime for a given zulu time.
 boolean greaterThan(KerberosTime ktime)
          checks if the current kerberos time is greater than the given kerberos time
 int hashCode()
           
 boolean isInClockSkew(long clockSkew)
          Returns whether this KerberosTime is within the given clockskew.
 boolean isZero()
          Returns whether this KerberosTime is zero.
 boolean lessThan(KerberosTime ktime)
          checks if the current kerberos time is less or equal than the given kerberos time
 void setDate(String date)
          Sets the date if it's a valid KerberosTime
 Date toDate()
          Returns the KerberosTime as a Date.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INFINITY

public static final KerberosTime INFINITY
Constant for the KerberosTime "infinity."


MINUTE

public static final int MINUTE
The number of milliseconds in a minute.

See Also:
Constant Field Values

DAY

public static final int DAY
The number of milliseconds in a day.

See Also:
Constant Field Values

WEEK

public static final int WEEK
The number of milliseconds in a week.

See Also:
Constant Field Values
Constructor Detail

KerberosTime

public KerberosTime()
Creates a new instance of a KerberosTime object


KerberosTime

public KerberosTime(String date)
Creates a new instance of a KerberosTime object

Parameters:
date - the KerberosTime to store

KerberosTime

public KerberosTime(long date)
Creates a new instance of a KerberosTime object


KerberosTime

public KerberosTime(Date time)
Creates a new instance of KerberosTime.

Parameters:
time -
Method Detail

getTime

public long getTime()
Returns the KerberosTime as a long.

Returns:
The KerberosTime as a long.

toDate

public Date toDate()
Returns the KerberosTime as a Date.

Returns:
The KerberosTime as a Date.

getTime

public static KerberosTime getTime(String zuluTime)
                            throws ParseException
Returns the KerberosTime for a given zulu time.

Parameters:
zuluTime -
Returns:
The KerberosTime.
Throws:
ParseException

setDate

public void setDate(String date)
             throws ParseException
Sets the date if it's a valid KerberosTime

Parameters:
date - The date to store
Throws:
ParseException

getBytes

public byte[] getBytes()
Returns:
The date as a byte[]

getDate

public String getDate()
Returns:
The stored date

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

isInClockSkew

public boolean isInClockSkew(long clockSkew)
Returns whether this KerberosTime is within the given clockskew.

Parameters:
clockSkew -
Returns:
true if this KerberosTime is within the given clockskew.

compareTo

public int compareTo(KerberosTime that)
compares current kerberos time with the given kerberos time

Specified by:
compareTo in interface Comparable<KerberosTime>
Parameters:
that - the kerberos time against which the current kerberos time is compared
Returns:
0 if both times are equal,
-1 if current time is less than the given time and
1 if the given time is greater than the current time

lessThan

public boolean lessThan(KerberosTime ktime)
checks if the current kerberos time is less or equal than the given kerberos time

Parameters:
ktime - the kerberos time against which the current kerberos time needs to be compared
Returns:
true if current kerberos time is less or equal than the given kerberos time, false otherwise

greaterThan

public boolean greaterThan(KerberosTime ktime)
checks if the current kerberos time is greater than the given kerberos time

Parameters:
ktime - the kerberos time against which the currnet kerberos time needs to be compared
Returns:
true if current kerberos time is greater than the given kerberos time, false otherwise

isZero

public boolean isZero()
Returns whether this KerberosTime is zero.

Returns:
true if this KerberosTime is zero.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.