[keycloak-user] JAAS login context propagation issue with Keyclock

valsaraj pv valsarajpv at gmail.com
Mon Jun 4 08:16:41 EDT 2018


Hi,

I am facing issue with JAAS login context propagation when using Keyclock.
Following code is executed from Message Driven Bean to login as application
MDB user.

> loginContext = new LoginContext("keycloak", new CallbackHandler() {
>
>              @Override
>
> public void handle(Callback[] callbacks) {
>
>                  int len = callbacks.length;
>
>                  Callback cb;
>
>                  for (int i = 0; i < len; i++) {
>
>                      cb = callbacks[i];
>
>                      if (cb instanceof NameCallback) {
>
>                          NameCallback ncb = (NameCallback) cb;
>
>                          ncb.setName(mdbuserName);
>
>                      } else if (cb instanceof PasswordCallback) {
>
>                          PasswordCallback pcb = (PasswordCallback) cb;
>
>                          pcb.setPassword(mdbUserPass);
>
>                      }
>
>                  }
>
>              }
>
>          });
>
>          loginContext.login();
>
>
After that when I check the principal, I got anonymous!

> Principal p = ctx.getCallerPrincipal();
>

Is there any work around for this issue?

Thanks!


More information about the keycloak-user mailing list