Class UsagePeriod
- All Implemented Interfaces:
Serializable,Comparable<UsagePeriod>,Block,Dumpable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected longprotected Datestatic final longstatic final intstatic final intprotected UsagePeriodTypeFields inherited from class net.messagevortex.asn1.AbstractBlock
CRLF -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new object valid from this point in time for the maximum possible duration.UsagePeriod(byte[] b) Creates a new object by parsing the passed ASN.1 byte stream.UsagePeriod(long seconds) Creates a new object valid from this point in time for a duration of the specified amount of seconds.UsagePeriod(long startSeconds, long durationSeconds) Creates a new object valid from this point plus startSeconds in time for a duration of the specified amount of seconds.UsagePeriod(long startSeconds, long durationSeconds, Date reference) Constructor to create a relative usage period.UsagePeriod(Date from, Date to) Creates a new object valid from this point in time for a duration of the specified amount of seconds.Copy constructor to copy a usage period.UsagePeriod(org.bouncycastle.asn1.ASN1Encodable to) Creates a new object by parsing the passed ASN.1 object. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(UsagePeriod other) dumpValueNotation(String prefix, DumpType dumpType) Dumps the object as ASN.1 value notation.booleanlongGets the the absolute epoch of the end time.longGets the the absolute epoch of the start time.Gets the date of expiry.Gets the start of validity.inthashCode()booleanbooleaninUsagePeriod(Date reference) checks whether the reference time is within the specified usage time.protected final voidparse(org.bouncycastle.asn1.ASN1Encodable to) setNotAfter(Date pointInTime) Sets the Date for expiriy of the validity.setNotBefore(Date validityStart) Sets the start date of validity.org.bouncycastle.asn1.ASN1ObjecttoAsn1Object(DumpType dumpType) Dumps an ASN.1 representation of the object.Methods inherited from class net.messagevortex.asn1.AbstractBlock
fromBase64, fromHex, parse, prepareDump, toBase64, toBitString, toBytes, toDer, toHex
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
TAG_NOT_BEFORE
public static final int TAG_NOT_BEFORE- See Also:
-
TAG_NOT_AFTER
public static final int TAG_NOT_AFTER- See Also:
-
notBefore
protected long notBefore -
notAfter
protected long notAfter -
reference
-
type
-
-
Constructor Details
-
UsagePeriod
public UsagePeriod(long seconds) Creates a new object valid from this point in time for a duration of the specified amount of seconds.
The validity time is created as relative time to the objects creation.
- Parameters:
seconds- The number of seconds to be valid
-
UsagePeriod
public UsagePeriod(long startSeconds, long durationSeconds) Creates a new object valid from this point plus startSeconds in time for a duration of the specified amount of seconds.
The validity time is created as relative time to the objects creation.
- Parameters:
startSeconds- the number of seconds after the current time the duration startsdurationSeconds- the number of seconds of the duration
-
UsagePeriod
Constructor to create a relative usage period.
- Parameters:
startSeconds- the number of seconds after the reference to start the perioddurationSeconds- the number of seconds the duration lastsreference- the date reference
-
UsagePeriod
public UsagePeriod()Creates a new object valid from this point in time for the maximum possible duration.
-
UsagePeriod
Copy constructor to copy a usage period.
- Parameters:
p- the usage period to be copied
-
UsagePeriod
Creates a new object valid from this point in time for a duration of the specified amount of seconds.
The validity time is created as absolute time.
- Parameters:
from- the moment the object gains validityto- the moment the object validity ends
-
UsagePeriod
Creates a new object by parsing the passed ASN.1 byte stream.
- Parameters:
b- the stream to be parsed- Throws:
IOException- if parsing fails
-
UsagePeriod
Creates a new object by parsing the passed ASN.1 object.
- Parameters:
to- the stream to be parsed- Throws:
IOException- if parsing fails
-
-
Method Details
-
parse
- Specified by:
parsein classAbstractBlock- Throws:
IOException
-
getNotBefore
Gets the start of validity.
- Returns:
- the currently set start of the validity
-
setNotBefore
Sets the start date of validity.
- Parameters:
validityStart- the new point in time to be set as start for the validity- Returns:
- the previously set point in time
-
getNotAfter
Gets the date of expiry.
- Returns:
- the currently set date of expiry
-
setNotAfter
Sets the Date for expiriy of the validity.
- Parameters:
pointInTime- the new date to be set- Returns:
- the previously set date
-
getBeforeInt
public long getBeforeInt()Gets the the absolute epoch of the start time.
- Returns:
- the absolute epoch in seconds
-
getAfterInt
public long getAfterInt()Gets the the absolute epoch of the end time.
- Returns:
- the absolute epoch in seconds
-
toAsn1Object
Description copied from interface:DumpableDumps an ASN.1 representation of the object.
- Specified by:
toAsn1Objectin interfaceDumpable- Parameters:
dumpType- the dump type to be used- Returns:
- the ASN.1 string representation of the object
-
dumpValueNotation
Dumps the object as ASN.1 value notation.
- Specified by:
dumpValueNotationin interfaceBlock- Parameters:
prefix- the prefix to be prepended in front of each line- Returns:
- the string representation of the object
-
inUsagePeriod
public boolean inUsagePeriod() -
inUsagePeriod
checks whether the reference time is within the specified usage time.
- Parameters:
reference- the time to to be taken into account when checking- Returns:
- true if within bounds
-
compareTo
- Specified by:
compareToin interfaceComparable<UsagePeriod>
-
equals
-
hashCode
public int hashCode()
-