public class UsagePeriod extends AbstractBlock implements Serializable, Comparable<UsagePeriod>
Modifier and Type | Field and Description |
---|---|
protected long |
notAfter |
protected long |
notBefore |
protected Date |
reference |
static long |
serialVersionUID |
static int |
TAG_NOT_AFTER |
static int |
TAG_NOT_BEFORE |
protected UsagePeriodType |
type |
CRLF
Constructor and Description |
---|
UsagePeriod()
Creates a new object valid from this point in time for the maximum possible duration.
|
UsagePeriod(org.bouncycastle.asn1.ASN1Encodable to)
Creates a new object by parsing the passed ASN.1 object.
|
UsagePeriod(byte[] b)
Creates a new object by parsing the passed ASN.1 byte stream.
|
UsagePeriod(Date from,
Date to)
Creates a new object valid from this point in time for a duration of the specified amount of
seconds.
|
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(UsagePeriod p)
Copy constructor to copy a usage period.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(UsagePeriod other) |
String |
dumpValueNotation(String prefix,
DumpType dumpType)
Dumps the object as ASN.1 value notation.
|
boolean |
equals(Object o) |
long |
getAfterInt()
Gets the the absolute epoch of the end time.
|
long |
getBeforeInt()
Gets the the absolute epoch of the start time.
|
Date |
getNotAfter()
Gets the date of expiry.
|
Date |
getNotBefore()
Gets the start of validity.
|
int |
hashCode() |
boolean |
inUsagePeriod() |
boolean |
inUsagePeriod(Date reference)
checks whether the reference time is within the specified usage time.
|
protected void |
parse(org.bouncycastle.asn1.ASN1Encodable to) |
Date |
setNotAfter(Date pointInTime)
Sets the Date for expiriy of the validity.
|
Date |
setNotBefore(Date validityStart)
Sets the start date of validity.
|
org.bouncycastle.asn1.ASN1Object |
toAsn1Object(DumpType dumpType)
Dumps an ASN.1 representation of the object.
|
fromBase64, fromHex, parse, prepareDump, toBase64, toBitString, toBytes, toDer, toHex
public static final long serialVersionUID
public static final int TAG_NOT_BEFORE
public static final int TAG_NOT_AFTER
protected long notBefore
protected long notAfter
protected Date reference
protected UsagePeriodType type
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.
seconds
- The number of seconds to be validpublic 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.
startSeconds
- the number of seconds after the current time the duration startsdurationSeconds
- the number of seconds of the durationpublic UsagePeriod(long startSeconds, long durationSeconds, Date reference)
Constructor to create a relative usage period.
startSeconds
- the number of seconds after the reference to start the perioddurationSeconds
- the number of seconds the duration lastsreference
- the date referencepublic UsagePeriod()
Creates a new object valid from this point in time for the maximum possible duration.
public UsagePeriod(UsagePeriod p)
Copy constructor to copy a usage period.
p
- the usage period to be copiedpublic UsagePeriod(Date from, Date to)
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.
from
- the moment the object gains validityto
- the moment the object validity endspublic UsagePeriod(byte[] b) throws IOException
Creates a new object by parsing the passed ASN.1 byte stream.
b
- the stream to be parsedIOException
- if parsing failspublic UsagePeriod(org.bouncycastle.asn1.ASN1Encodable to) throws IOException
Creates a new object by parsing the passed ASN.1 object.
to
- the stream to be parsedIOException
- if parsing failsprotected final void parse(org.bouncycastle.asn1.ASN1Encodable to) throws IOException
parse
in class AbstractBlock
IOException
public Date getNotBefore()
Gets the start of validity.
public Date setNotBefore(Date validityStart)
Sets the start date of validity.
validityStart
- the new point in time to be set as start for the validitypublic Date getNotAfter()
Gets the date of expiry.
public Date setNotAfter(Date pointInTime)
Sets the Date for expiriy of the validity.
pointInTime
- the new date to be setpublic long getBeforeInt()
Gets the the absolute epoch of the start time.
public long getAfterInt()
Gets the the absolute epoch of the end time.
public org.bouncycastle.asn1.ASN1Object toAsn1Object(DumpType dumpType)
Dumpable
Dumps an ASN.1 representation of the object.
toAsn1Object
in interface Dumpable
dumpType
- the dump type to be usedpublic String dumpValueNotation(String prefix, DumpType dumpType)
Dumps the object as ASN.1 value notation.
dumpValueNotation
in interface Block
prefix
- the prefix to be prepended in front of each linepublic boolean inUsagePeriod()
public boolean inUsagePeriod(Date reference)
checks whether the reference time is within the specified usage time.
reference
- the time to to be taken into account when checkingpublic int compareTo(UsagePeriod other)
compareTo
in interface Comparable<UsagePeriod>
Copyright © 2023. All rights reserved.