Package org.forgerock.openig.el
Class ExpressionInstant
- java.lang.Object
-
- org.forgerock.openig.el.ExpressionInstant
-
public final class ExpressionInstant extends Object
A wrapper of theInstantplus/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 newExpressionInstantbased on the passedInstant.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetEpochMillis()Return the milliseconds since the epoch of 1970-01-01T00:00:00Z.longgetEpochSeconds()Return the seconds since the epoch of 1970-01-01T00:00:00Z.StringgetRfc1123()Returns the current instant as a String in the Date format of RFC1123, which is the format used in aExpiresvalue in cookies.ExpressionInstantminusDays(long daysToSubtract)Return a newExpressionInstantwith the daysToSubtract subtracted from the current value of theInstant.ExpressionInstantminusHours(long hoursToSubtract)Return a newExpressionInstantwith the hoursToSubtract subtracted from the current value of theInstant.ExpressionInstantminusMillis(long millisecondsToSubtract)Return a newExpressionInstantwith the millisecondsToSubtract subtracted from the current value of theInstant.ExpressionInstantminusMinutes(long minutesToSubtract)Return a newExpressionInstantwith the minutesToSubtract subtracted from the current value of theInstant.ExpressionInstantminusSeconds(long secondsToSubtract)Return a newExpressionInstantwith the secondsToSubtract subtracted from the current value of theInstant.ExpressionInstantplusDays(long daysToAdd)Return a newExpressionInstantwith the daysToAdd added to the current value of theInstant.ExpressionInstantplusHours(long hoursToAdd)Return a newExpressionInstantwith the hoursToAdd added to the current value of theInstant.ExpressionInstantplusMillis(long millisecondsToAdd)Return a newExpressionInstantwith the millisecondsToAdd added to the current value of theInstant.ExpressionInstantplusMinutes(long minutesToAdd)Return a newExpressionInstantwith the minutesToAdd added to the current value of theInstant.ExpressionInstantplusSeconds(long secondsToAdd)Return a newExpressionInstantwith 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 aExpiresvalue 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 newExpressionInstantwith the millisecondsToAdd added to the current value of theInstant.- Parameters:
millisecondsToAdd- the milliseconds to add.- Returns:
- a new
ExpressionInstantwith the millisecondsToAdd added to the current value of theInstant.
-
minusMillis
public ExpressionInstant minusMillis(long millisecondsToSubtract)
Return a newExpressionInstantwith the millisecondsToSubtract subtracted from the current value of theInstant.- Parameters:
millisecondsToSubtract- the milliseconds to subtract.- Returns:
- a new
ExpressionInstantwith the millisecondsToSubtract subtracted from the current value of theInstant.
-
plusSeconds
public ExpressionInstant plusSeconds(long secondsToAdd)
Return a newExpressionInstantwith the secondsToAdd added to the current value of theInstant.- Parameters:
secondsToAdd- the seconds to add.- Returns:
- a new
ExpressionInstantwith the secondsToAdd added to the current value of theInstant.
-
minusSeconds
public ExpressionInstant minusSeconds(long secondsToSubtract)
Return a newExpressionInstantwith the secondsToSubtract subtracted from the current value of theInstant.- Parameters:
secondsToSubtract- the seconds to subtract.- Returns:
- a new
ExpressionInstantwith the secondsToSubtract subtracted from the current value of theInstant.
-
plusMinutes
public ExpressionInstant plusMinutes(long minutesToAdd)
Return a newExpressionInstantwith the minutesToAdd added to the current value of theInstant.- Parameters:
minutesToAdd- the minutes to add.- Returns:
- a new
ExpressionInstantwith the minutesToAdd added to the current value of theInstant.
-
minusMinutes
public ExpressionInstant minusMinutes(long minutesToSubtract)
Return a newExpressionInstantwith the minutesToSubtract subtracted from the current value of theInstant.- Parameters:
minutesToSubtract- the minutes to subtract.- Returns:
- a new
ExpressionInstantwith the minutesToSubtract subtracted from the current value of theInstant.
-
plusHours
public ExpressionInstant plusHours(long hoursToAdd)
Return a newExpressionInstantwith the hoursToAdd added to the current value of theInstant.- Parameters:
hoursToAdd- the hours to add.- Returns:
- a new
ExpressionInstantwith the hoursToAdd added to the current value of theInstant.
-
minusHours
public ExpressionInstant minusHours(long hoursToSubtract)
Return a newExpressionInstantwith the hoursToSubtract subtracted from the current value of theInstant.- Parameters:
hoursToSubtract- the hours to subtract.- Returns:
- a new
ExpressionInstantwith the hoursToSubtract subtracted from the current value of theInstant.
-
plusDays
public ExpressionInstant plusDays(long daysToAdd)
Return a newExpressionInstantwith the daysToAdd added to the current value of theInstant.- Parameters:
daysToAdd- the days to add.- Returns:
- a new
ExpressionInstantwith the daysToAdd added to the current value of theInstant.
-
minusDays
public ExpressionInstant minusDays(long daysToSubtract)
Return a newExpressionInstantwith the daysToSubtract subtracted from the current value of theInstant.- Parameters:
daysToSubtract- the days to subtract.- Returns:
- a new
ExpressionInstantwith the daysToSubtract subtracted from the current value of theInstant.
-
-