APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.krb5.internal

public Class KerberosTime

extends Object
Class Inheritance
Imports
sun.security.krb5.Asn1Exception, .Config, .KrbException, sun.security.util.DerInputStream, .DerOutputStream, .DerValue, java.io.IOException, java.time.Instant, java.util.Calendar, .Date, .TimeZone

Implements the ASN.1 KerberosTime type. This is an immutable class. KerberosTime ::= GeneralizedTime -- with no fractional seconds The timestamps used in Kerberos are encoded as GeneralizedTimes. A KerberosTime value shall not include any fractional portions of the seconds. As required by the DER, it further shall not include any separators, and it shall specify the UTC time zone (Z).

This definition reflects the Network Working Group RFC 4120 specification available at http://www.ietf.org/rfc/rfc4120.txt. The implementation also includes the microseconds info so that the same class can be used as a precise timestamp in Authenticator etc.

Field Summary

Modifier and TypeField and Description
private static long
private static long
private final long
private final int

Constructor Summary

AccessConstructor and Description
private
KerberosTime(long time, int micro)

public
KerberosTime(long time)

Creates a KerberosTime object from milliseconds since epoch.

public
public
KerberosTime(Date time)

Creates a KerberosTime object from a Date object.

public
KerberosTime(Instant instant)

Creates a KerberosTime object from an Instant object

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

a byte array of encoded data.
asn1Encode
()

Encodes this object to a byte array.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public static int
public int
public int
public long
public boolean
public boolean
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private boolean
inClockSkew(int clockSkew)

public boolean
public boolean
public static KerberosTime
now()

Creates a KerberosTime object for now.

public static KerberosTime

Returns:

an instance of KerberosTime.
parse
(DerInputStream
the Der input stream value, which contains one or more marshaled value.
data
,
byte
tag number.
explicitTag
,
boolean
indicates if this data field is optional
optional
)

Parse (unmarshal) a kerberostime from a DER input stream.

public Date
public String

Returns:

a string representation of this object.
toGeneralizedTimeString
()

Returns a string representation of KerberosTime object.

private static long
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public KerberosTime
withMicroSeconds(int usec)

Returns a new KerberosTime object with the original seconds and the given microseconds.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

initMicroback to summary
private static long initMicro
initMilliback to summary
private static long initMilli
kerberosTimeback to summary
private final long kerberosTime
microSecondsback to summary
private final int microSeconds

Constructor Detail

KerberosTimeback to summary
private KerberosTime(long time, int micro)
KerberosTimeback to summary
public KerberosTime(long time)

Creates a KerberosTime object from milliseconds since epoch.

KerberosTimeback to summary
public KerberosTime(String time) throws Asn1Exception
KerberosTimeback to summary
public KerberosTime(Date time)

Creates a KerberosTime object from a Date object.

KerberosTimeback to summary
public KerberosTime(Instant instant)

Creates a KerberosTime object from an Instant object

Method Detail

asn1Encodeback to summary
public byte[] asn1Encode() throws Asn1Exception, IOException

Encodes this object to a byte array.

Returns:byte[]

a byte array of encoded data.

Exceptions
Asn1Exception:
if an error occurs while decoding an ASN1 encoded data.
IOException:
if an I/O error occurs while reading encoded data.
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

getDefaultSkewback to summary
public static int getDefaultSkew()
getMicroSecondsback to summary
public int getMicroSeconds()
getSecondsback to summary
public int getSeconds()
getTimeback to summary
public long getTime()
greaterThanback to summary
public boolean greaterThan(KerberosTime time)
greaterThanWRTClockSkewback to summary
public boolean greaterThanWRTClockSkew(KerberosTime time, int clockSkew)
greaterThanWRTClockSkewback to summary
public boolean greaterThanWRTClockSkew(KerberosTime time)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
inClockSkewback to summary
private boolean inClockSkew(int clockSkew)
inClockSkewback to summary
public boolean inClockSkew()
isZeroback to summary
public boolean isZero()
nowback to summary
public static KerberosTime now()

Creates a KerberosTime object for now. It uses System.nanoTime() to get a more precise time than "new Date()".

parseback to summary
public static KerberosTime parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException

Parse (unmarshal) a kerberostime from a DER input stream. This form parsing might be used when expanding a value which is part of a constructed sequence and uses explicitly tagged type.

Parameters
data:DerInputStream

the Der input stream value, which contains one or more marshaled value.

explicitTag:byte

tag number.

optional:boolean

indicates if this data field is optional

Returns:KerberosTime

an instance of KerberosTime.

Exceptions
Asn1Exception:
on error.
toDateback to summary
public Date toDate()
toGeneralizedTimeStringback to summary
public String toGeneralizedTimeString()

Returns a string representation of KerberosTime object.

Returns:String

a string representation of this object.

toKerberosTimeback to summary
private static long toKerberosTime(String time) throws Asn1Exception
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.

withMicroSecondsback to summary
public KerberosTime withMicroSeconds(int usec)

Returns a new KerberosTime object with the original seconds and the given microseconds.