Current time in milliseconds

Tagged: ,

This topic contains 4 replies, has 2 voices, and was last updated by  Dusty 2 months, 2 weeks ago.

  • Author
    Posts
  • #22671
     Dusty 
    Participant

    Hi,

    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
    Dusty

    #22672
     violette 
    Participant

    Hi,

    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,

    #22674
     Dusty 
    Participant

    Hi 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 2 months, 2 weeks ago by  Dusty.
    #22697
     violette 
    Participant

    Hello,

    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.

    #22699
     Dusty 
    Participant

    Hi 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

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

©2018 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?