[keycloak-user] Programmatically login as a user

valsaraj pv valsarajpv at gmail.com
Fri Jun 1 05:12:37 EDT 2018


I tried following code:

> 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(mdbUsrPass);
>      }
> }
>      }
>  });
>  loginContext.login();


For following dependency issue while trying to login:

> *[Server:app-node-00] unable to find LoginModule class:
> org.keycloak.adapters.jboss.KeycloakLoginModule from [Module
> "deployment.app.ear.appEJB.jar:main" from Service Module Loader] at
> javax.security.auth.login.LoginContext (line 794)*



On Thu, May 31, 2018 at 6:11 PM, valsaraj pv <valsarajpv at gmail.com> wrote:

>
> Hi,
>
> I have web application login via Keycloak working fine. But for a
> background processing like reading messages from a queue, need to login as
> a dedicated queue user behind the scenes. For this we can't redirect to
> login page. Earlier it was done pro grammatically  by using JAAS login
> context and passing login module & credentials. Now when we switch to KC,
> what is the appropriate model to do this?
> Please advice!
>
> Thanks!
>



-- 
Life is like this: "Just when we get all the answers of life.... God
changes the question paper....

Valsaraj Viswanathan


More information about the keycloak-user mailing list