Tagged: current time, IG
This topic has 4 replies, 2 voices, and was last updated 4 years ago by Dusty.
-
AuthorPosts
-
August 2, 2018 at 11:23 am #22671
Dusty
ParticipantHi,
What is the best way to get the current time in milliseconds in a route? I know I could do it with a Scriptable Filter, but It feels like killing a fly with a sledgehammer. I’m using IG 6.1.
Greets
DustyAugust 2, 2018 at 11:40 am #22672violette
ParticipantHi,
You can use the TimerDecorator (See https://backstage.forgerock.com/docs/ig/6.1/reference/#TimerDecorator).
It record time in milliseconds to process filters and handlers. In your case, add"timer": true
under your route condition.Cheers,
August 2, 2018 at 1:59 pm #22674Dusty
ParticipantHi Violette,
Thanks for your help. I already saw the TimerDecorator, but I thought it was only for timing filters, handers,… The documentation is very basic for the decorators. How can I use the current time in an expression, for example
{ "type": "HeaderFilter", "config": { "messageType": "REQUEST", "add": { "x-currenttime": [ "${???}" ] } }, "timer": true, }
-
This reply was modified 4 years ago by
Dusty.
August 3, 2018 at 9:36 am #22697violette
ParticipantHello,
Sorry, I misunderstood. I thought you wanted the elapsed time in a route but you do want to get the current system time and send it to the downstream application.
Yes, for that the TimerDecorator won’t be helpful… If you want to use expression, you will have to set env variables or system variables to retrieve the datetime. ({env['variable']}, and ${system['property']}.
).
As far as I know, there is no other way to get the current time using expressions.
A groovy script is an alternative too.August 3, 2018 at 9:50 am #22699Dusty
ParticipantHi Viollete,
This is indeed what I meant. I want to create a JWT token with the JWTTokenBuilder and add an expiry date to that token. I think I will go for the groovy script.
Thank you for your help!
Dusty -
This reply was modified 4 years ago by
-
AuthorPosts
You must be logged in to reply to this topic.