Package org.forgerock.openig.el
Class ExpressionInstant
- java.lang.Object
-
- org.forgerock.openig.el.ExpressionInstant
-
public final class ExpressionInstant extends Object
A wrapper of theInstant
plus/minus functions for use in expressions. It ensures that multiple calls to the wrapped functions are always based on the same instant in time. For example, if added to the bindings asnow
:"iat": "${now.epochSeconds}", "exp": "${now.plusMinutes(30).epochSeconds}", "expires", "${now.plusSeconds(20).rfc1123}"
-
-
Constructor Summary
Constructors Constructor Description ExpressionInstant(Instant instant)
Create a newExpressionInstant
based on the passedInstant
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getEpochMillis()
Return the milliseconds since the epoch of 1970-01-01T00:00:00Z.long
getEpochSeconds()
Return the seconds since the epoch of 1970-01-01T00:00:00Z.String
getRfc1123()
Returns the current instant as a String in the Date format of RFC1123, which is the format used in aExpires
value in cookies.ExpressionInstant
minusDays(long daysToSubtract)
Return a newExpressionInstant
with the daysToSubtract subtracted from the current value of theInstant
.ExpressionInstant
minusHours(long hoursToSubtract)
Return a newExpressionInstant
with the hoursToSubtract subtracted from the current value of theInstant
.ExpressionInstant
minusMillis(long millisecondsToSubtract)
Return a newExpressionInstant
with the millisecondsToSubtract subtracted from the current value of theInstant
.ExpressionInstant
minusMinutes(long minutesToSubtract)
Return a newExpressionInstant
with the minutesToSubtract subtracted from the current value of theInstant
.ExpressionInstant
minusSeconds(long secondsToSubtract)
Return a newExpressionInstant
with the secondsToSubtract subtracted from the current value of theInstant
.ExpressionInstant
plusDays(long daysToAdd)
Return a newExpressionInstant
with the daysToAdd added to the current value of theInstant
.ExpressionInstant
plusHours(long hoursToAdd)
Return a newExpressionInstant
with the hoursToAdd added to the current value of theInstant
.ExpressionInstant
plusMillis(long millisecondsToAdd)
Return a newExpressionInstant
with the millisecondsToAdd added to the current value of theInstant
.ExpressionInstant
plusMinutes(long minutesToAdd)
Return a newExpressionInstant
with the minutesToAdd added to the current value of theInstant
.ExpressionInstant
plusSeconds(long secondsToAdd)
Return a newExpressionInstant
with the secondsToAdd added to the current value of theInstant
.
-
-
-
Method Detail
-
getEpochMillis
public long getEpochMillis()
Return the milliseconds since the epoch of 1970-01-01T00:00:00Z.- Returns:
- the milliseconds since the epoch of 1970-01-01T00:00:00Z
-
getEpochSeconds
public long getEpochSeconds()
Return the seconds since the epoch of 1970-01-01T00:00:00Z.- Returns:
- the seconds since the epoch of 1970-01-01T00:00:00Z
-
getRfc1123
public String getRfc1123()
Returns the current instant as a String in the Date format of RFC1123, which is the format used in aExpires
value in cookies.- Returns:
- the current instant as a String in the Date format of RFC1123
- See Also:
- RFC6265 section 4.1.1.
-
plusMillis
public ExpressionInstant plusMillis(long millisecondsToAdd)
Return a newExpressionInstant
with the millisecondsToAdd added to the current value of theInstant
.- Parameters:
millisecondsToAdd
- the milliseconds to add.- Returns:
- a new
ExpressionInstant
with the millisecondsToAdd added to the current value of theInstant
.
-
minusMillis
public ExpressionInstant minusMillis(long millisecondsToSubtract)
Return a newExpressionInstant
with the millisecondsToSubtract subtracted from the current value of theInstant
.- Parameters:
millisecondsToSubtract
- the milliseconds to subtract.- Returns:
- a new
ExpressionInstant
with the millisecondsToSubtract subtracted from the current value of theInstant
.
-
plusSeconds
public ExpressionInstant plusSeconds(long secondsToAdd)
Return a newExpressionInstant
with the secondsToAdd added to the current value of theInstant
.- Parameters:
secondsToAdd
- the seconds to add.- Returns:
- a new
ExpressionInstant
with the secondsToAdd added to the current value of theInstant
.
-
minusSeconds
public ExpressionInstant minusSeconds(long secondsToSubtract)
Return a newExpressionInstant
with the secondsToSubtract subtracted from the current value of theInstant
.- Parameters:
secondsToSubtract
- the seconds to subtract.- Returns:
- a new
ExpressionInstant
with the secondsToSubtract subtracted from the current value of theInstant
.
-
plusMinutes
public ExpressionInstant plusMinutes(long minutesToAdd)
Return a newExpressionInstant
with the minutesToAdd added to the current value of theInstant
.- Parameters:
minutesToAdd
- the minutes to add.- Returns:
- a new
ExpressionInstant
with the minutesToAdd added to the current value of theInstant
.
-
minusMinutes
public ExpressionInstant minusMinutes(long minutesToSubtract)
Return a newExpressionInstant
with the minutesToSubtract subtracted from the current value of theInstant
.- Parameters:
minutesToSubtract
- the minutes to subtract.- Returns:
- a new
ExpressionInstant
with the minutesToSubtract subtracted from the current value of theInstant
.
-
plusHours
public ExpressionInstant plusHours(long hoursToAdd)
Return a newExpressionInstant
with the hoursToAdd added to the current value of theInstant
.- Parameters:
hoursToAdd
- the hours to add.- Returns:
- a new
ExpressionInstant
with the hoursToAdd added to the current value of theInstant
.
-
minusHours
public ExpressionInstant minusHours(long hoursToSubtract)
Return a newExpressionInstant
with the hoursToSubtract subtracted from the current value of theInstant
.- Parameters:
hoursToSubtract
- the hours to subtract.- Returns:
- a new
ExpressionInstant
with the hoursToSubtract subtracted from the current value of theInstant
.
-
plusDays
public ExpressionInstant plusDays(long daysToAdd)
Return a newExpressionInstant
with the daysToAdd added to the current value of theInstant
.- Parameters:
daysToAdd
- the days to add.- Returns:
- a new
ExpressionInstant
with the daysToAdd added to the current value of theInstant
.
-
minusDays
public ExpressionInstant minusDays(long daysToSubtract)
Return a newExpressionInstant
with the daysToSubtract subtracted from the current value of theInstant
.- Parameters:
daysToSubtract
- the days to subtract.- Returns:
- a new
ExpressionInstant
with the daysToSubtract subtracted from the current value of theInstant
.
-
-