1 Reply Latest reply on Nov 6, 2009 10:44 AM by Dennis Kuehn

    Cannot use custom CallbackHandler with LoginContext

    Dennis Kuehn Newbie

      I'm connecting to a JBoss 5.1.0.GA from a standalone client. I use a custom LoginModule. This is my client side security config:

      admin-securitydomain {
       org.jboss.security.ClientLoginModule required;
      };
      


      This is my client side login code:
      URL authenticationConfigURL = getClass().getResource(AUTH_PROP_CONFIG_FILENAME);
      System.setProperty(AUTH_PROP_KEY, authenticationConfigURL.toExternalForm());
      LoginCallbackHandler callbackHandler = new LoginCallbackHandler(username, password, Role.ADMINISTRATOR, Market.de);
      LoginContext loginContext = new LoginContext(SECURITY_DOMAIN, callbackHandler);
      loginContext.login();
      


      I'd like to use my own CallbackHandler but it doesn't work as expected - the CallbackHandler that is passed into the LoginModule is of type javax.security.auth.login.LoginContext$SecureCallbackHandler.

      As a consequence, when I try to login, I get a
      javax.security.auth.callback.UnsupportedCallbackException: Unrecognized Callback
      at org.jboss.security.auth.callback.JBossCallbackHandler.handle(JBossCallbackHandler.java:126)
      at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(LoginContext.java:955)
      ...
      

      Any ideas how I can fix this?