Starting selfservice process from script fails

This topic has 2 replies, 2 voices, and was last updated 3 weeks, 2 days ago by Henk Schouten.

  • Author
    Posts
  • #28308
     Henk Schouten
    Participant

    Hello,

    I am trying to build a script that will start a selfservice process for account activation. It will be called for newly created users only. I have setup an activation process that I can run stage by stage using REST calls. But when I try to run it from a script it fails with a null pointer exception coming from the sendEmail stage that tries to obtain the subject and message translations. It seems that when being called from a script by using the openidm.action function it does not have a context providing Locales information.

    Is there a way to provide for instance “Accept-Language” header when using the openidm.action function?

    I have considered using an external/rest call for this purpose, since this seems to provide the possibility to add headers to the request. But it seems ugly to call an openidm service from an openidm script by taking the external route. It also would require authentication which would also make things more complex.

    Are there any other options to achieve this?

    Thanks in advance!

    Best Regards
    Henk Schouten

    ==

    Part of stacktrace of the exception thrown:
    Oct 01, 2020 6:22:47 PM org.forgerock.selfservice.core.AnonymousProcessService logAndAdaptException
    SEVERE: Exception intercepted
    java.lang.NullPointerException
    	at org.forgerock.selfservice.stages.utils.LocaleUtils.getTargetLocales(LocaleUtils.java:69)
    	at org.forgerock.selfservice.stages.utils.LocaleUtils.getTranslationFromLocaleMap(LocaleUtils.java:46)
    	at org.forgerock.selfservice.stages.email.VerifyEmailAccountStage.sendEmail(VerifyEmailAccountStage.java:166)
    	at org.forgerock.selfservice.stages.email.VerifyEmailAccountStage.lambda$sendEmail$0(VerifyEmailAccountStage.java:123)
    	at org.forgerock.selfservice.core.AnonymousProcessService.renderRequirementsWithSnapshot(AnonymousProcessService.java:265)
    	at org.forgerock.selfservice.core.AnonymousProcessService.enactContext(AnonymousProcessService.java:211)
    	at org.forgerock.selfservice.core.AnonymousProcessService.handleProgression(AnonymousProcessService.java:252)
    	at org.forgerock.selfservice.core.AnonymousProcessService.enactContext(AnonymousProcessService.java:214)
    	at org.forgerock.selfservice.core.AnonymousProcessService.progressProcess(AnonymousProcessService.java:203)
    	at org.forgerock.selfservice.core.AnonymousProcessService.handleAction(AnonymousProcessService.java:115)
    	at org.forgerock.openidm.selfservice.impl.SelfServiceProcessHandler.handleAction(SelfServiceProcessHandler.java:218)
    	at org.forgerock.json.resource.Router.handleAction(Router.java:250)
    #28309
     Jake Feasel
    Moderator

    Unfortunately, your “ugly” solution is pretty much the only one available. There is a similar example available within one of the workflows provided OOTB in contractorOnboarding.bpmn20.xml:

    
                // Automatically send the user a password reset email
                // Current limitation with supplying locale via http headers requires the call to be made via http
                openidm.action("external/rest", "call", [
                    "url": "https://localhost:"+identityServer.getProperty('openidm.port.https')+"/openidm/selfservice/reset?_action=submitRequirements",
                    "method": "POST",
                    "headers": [
                        "Content-Type": "application/json",
                        "X-OpenIDM-Username": "anonymous",
                        "X-OpenIDM-Password": "anonymous",
                        "Accept-Language": "en-US,en"
                    ],
                    "body": '{"input": {"queryFilter": "/userName eq \\\"' + newUserFromRepo.result[0].userName.replace(/"/, "\\\"") + '\\\""}}'
                ]);
    
    #28310
     Henk Schouten
    Participant

    Hi Jake,

    Thanks for your quick response. Considering the comments in the onboardingContractor example I think you are right. So I will implement it that way then.

    Thanks again.

    Henk

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

You must be logged in to reply to this topic.

©2020 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?