3 Replies Latest reply on Apr 22, 2008 10:38 AM by ai77

    custom authentication

    vinguye2

      Hi,
      Has anyone figured out a simple solution to customize authentication for JBoss Portal? I've searched the forum, but there seems to be no definitive answer. Would be nice if a solution was posted in the docs or Wiki by the JBoss team.

      Basically, I'd like to authenticate users against my own db. But as a start, I created a custom LoginModule and placed it in login-config.xml. The code is below, which I got by following this post:
      http://jboss.org/index.html?module=bb&op=viewtopic&t=118988

      I can successfully login with any username/password, but I still see the "Login" link at the top right of the page after I login. I am beginning to assume there is something in the original org.jboss.portal.identity.auth.IdentityLoginModule code that is specific to JBP that normal login module implementors aren't aware of. But I don't have access to the IdentifyLoginModule's source code.

      Any help is appreciated!

      public class MyLoginModule extends AbstractServerLoginModule
      {
      private String username = null;
      private Principal identity;
      private Object password;

      @Override
      protected Principal getIdentity()
      {
      System.out.println("getIdentity(): " + identity);
      return identity;
      }

      @Override
      protected Group[] getRoleSets() throws LoginException
      {
      System.out.println("getRoleSets()");
      Group rolesGroup = new SimpleGroup("Roles");
      rolesGroup.addMember(new SimplePrincipal("Authenticated"));
      rolesGroup.addMember(new SimplePrincipal("Admin"));
      rolesGroup.addMember(new SimplePrincipal("Users"));
      rolesGroup.addMember(identity);
      return new Group[] {rolesGroup};
      }

      public boolean login()
      throws LoginException
      {
      NameCallback nameCallback = new NameCallback("Enter username");
      PasswordCallback pwdCallback = new PasswordCallback("Enter password", false);
      try
      {
      callbackHandler.handle(new Callback[] {nameCallback, pwdCallback});
      username = nameCallback.getName();
      password = new String(pwdCallback.getPassword());
      identity = new SimplePrincipal(username);
      loginOk = true;

      System.out.println("Username: " + username + ", password: " + password + ", Identity: " + identity);
      return true;
      }
      catch (UnsupportedCallbackException exc)
      {
      LoginException le = new LoginException("Internal error!");
      le.initCause(exc);
      throw le;
      }
      catch (IOException exc)
      {
      LoginException le = new LoginException("Internal error!");
      le.initCause(exc);
      throw le;
      }
      }
      }

        • 1. Re: custom authentication
          vinguye2

          I forgot to mention that I'm using JBoss Portal 2.6.2 on Windows XP.

          • 2. Re: custom authentication
            sbiwal

            Hi,
            I am looking for a similar solution to my problem. Basically I am authenticating my users against some accepted Identity Providers (using Shibboleth). Now I want a user (who has successfully been authenticated) to be automatically logged into the portal.

            Have you figured out a solution to your problem ? It might be of help to me.

            Thanks in advance.

            • 3. Re: custom authentication
              ai77

              Hi,
              I have the same problem of vinguye2.
              Any news?
              Thanks in advance for ur answers