3

I tried to do an old fashioned login on WAS Liberty using LoginContext:

CallbackHandler callbackHandler = WSCallbackHandlerFactory
                .getInstance().getCallbackHandler("userName",
                        "realmName", "password", request,
                        response, null);
LoginContext loginContext = new LoginContext("system.WEB_INBOUND",
                callbackHandler);
loginContext.login();
System.out.println(loginContext.getSubject());
WSSubject.setRunAsSubject(loginContext.getSubject());

The code succeeds and the user is authenticated, but only for that specific request. I've found out that the SSO Cookie (Ltpa) is not set, so I tried to set it manually:

response.addCookie(WebSecurityHelper.getSSOCookieFromSSOToken());

Now the SSO Cookie is set, but gets deleted/reset on the next request.

When I use login-Method on HttpServletRequest, all looks the same but the cookie isn't removed.

Does anyone know how to do a programmatic login on WAS Liberty using a User Registry and SSO Cookie?

Best regards, Billie

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Billie
  • 99
  • 4

1 Answers1

2

The JAAS login process in WAS Liberty authenticates the user and creates the user subject. The cookie is created once the subject is successfully created - outside the JAAS login process.

As you have confirmed the HttpServletRequest.login does create the cookie. So should the HttpServletRequest.authenticate method. You can use either of these.

If you want the JAAS login process to create the cookie you can open a feature request (RFE) here

--Ajay

Ajay
  • 201
  • 1
  • 2