Login Java Action - Custom Login

Hello Guys, Does anyone have working Login Java Action code ? If so please help me out.  Problem Statement:  1. I have a Mendix app for some enterprise application(lets say XYZ app).  2. I created a custom login page for users(anonymous) to enter their XYZ app credentials.  3. Once I receive the credentials, a REST call will be triggered to XYZ app and check If user is existed in the system.  4. If User exists in XYZ, with the same credentials Iam creating Mendix user account.  5. After creation, User should be logged in to Mendix application through Java action automatically.    Can anyone please suggest me how I can complete the step-5. [Mendix Version – 8.10.0]
1 answers

Check login methods available in https://apidocs.mendix.com/7/runtime/com/mendix/core/Core.html