How do I set a user identifier using Java in Pega?
I'm working on setting up SSO in Pega. I think I'm making some progress, but I've run into an issue I don't know how to resolve. We use an API Gateway to authenticate a user and a cookie is set containing the user's ID. I can get this ID from the cookie using Java in my authentication activity, however, I can't set the .pyUserIdentifier parameter. I'm trying to use the following code:
Just as an FYI, I grabbed this from some generated Java code from when this value was being defaulted using an Obj-Open method. However, in this case, I get an NPE because myStepPage is null.
Is there a better way for me to set the ID of the current user so that when a user connects to the system they are automatically logged in? Or, is there a way I can make sure that myStepPage is not null, such as defaulting to a reasonable value?
Do you have a model operator? If yes, you can do an obj-open and retrieve the model operator on a page, say, Operator. Read the cookie containing the User ID and set pyUserIdentifier on Operator page with the cookie value. You are basically replacing the model operator's pyUserIdentifier with the cookie value. Set Param.pyOperPage to the Operator page in your authentication activity. Check OOTB activities IACAuthentication and IACAuthVerification for how to do this.
First, regarding the model operator, I believe the answer is no. Do I need one? (Sorry, very new to Pega and followed someone else's instructions to get close to where I am.)
Second, I looked at those activities, but how they do things won't work for me. They use the @java construct, which doesn't work for me as I'm using Pega 8.2. I know the activities have that code in them, but I can't commit a change with @java in it. I posted a question regarding this about two weeks ago: https://community1.pega.com/community/pega-support/question/what-correc…
Looks like you're using PRCustom style authentication. A OTB servlet would be /PRCustom using authservice of CustomSample.
With this type of authentication your goal is to return a Clipboard page of class Data-Admin-Operator-ID. The Authentication activity is called with parameters and you return parameters for error handling or success. The pyOperPage parameter is of type Java and is expecting the Clipboard page of the user you want to login: pram.pyOperPage = @Java(myStepPage)
You can also look at activities Code-Security.AuthenticationLDAP and Code-Security.AuthenticationLDAPVerifyCredentials for examples.